Jump to content

setVehicleColor


-Jigsaw

Recommended Posts

So, I got a code that's supposed to set the vehicle's color to white if the source aint in a team. Problem is that sometimes when the player spawns the vehicle is a different and random color. What's wrong with it? Thank you in advance

addEventHandler("onPlayerSpawn", getRootElement(),  
function() 
    if  isPedInVehicle(source) then 
        local team = getPlayerTeam(source) 
        local vehicle = getPedOccupiedVehicle(source) 
        if team then return end 
        setVehicleColor(vehicle, 255, 255, 255) 
    end 
end 
) 

Link to comment

You may want to set it when he enters the vehicle instead.

addEventHandler ( "onVehicleEnter", getRootElement(), 
    function ( player ) 
        local team = getPlayerTeam ( player ) 
        if ( not team ) then 
            setVehicleColor ( source, 255, 255, 255 ) 
        end 
    end 
) 

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...