Jump to content

Server side setVehicleColor doesn't always work


Tuna

Recommended Posts

Again cause there is no bug reporting system I'm posting here...

After getting a report that my vehicle system was not setting vehicle colours correctly I had to investigate. The vehicle is created on login, and then the model, colours, paintjob, location, rotation, health, upgrades are set.

Yet players are seeing different colours. In runcode the vehicle colour is set correctly on the server, but on the client the colour is not being set the same.

I guess i'll have to make a client event just to set the colour of a vehicle right.

Link to comment

It may be to do with the paintjob.

  
function reproduceMTABug(player) 
    local createdVeh = createVehicle(535, unpack({getElementPosition(player)})) 
    if (createdVeh) then 
        setVehicleColor(createdVeh, 51, 1, 0, 0) 
        setVehiclePaintjob(createdVeh, 2) 
    end 
end 
addCommandHandler("vehiclebug", reproduceMTABug) 
  

When sat in the same vehicle:

Server side:

getVehicleColor(getPedOccupiedVehicle(getPlayerFromName("yourName")))

Command results: 51 [number], 1 [number], 0 [number], 0 [number]

Client side:

getVehicleColor(getPedOccupiedVehicle(getPlayerFromName("yourName")))

Command results: 97 [number], 1 [number], 0 [number], 0 [number]

Link to comment

It turns out the problem is setVehiclePaintjob.

setVehiclePaintjob gives your vehicle a random colour so the colour has to be set after the paintjob. Would be nice if setVehiclePaintjob got the current colour and set that once it has changed the paint job.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...