Jump to content

Car color


JoZeFSvK

Recommended Posts

Hey i dont know where is problem debugscript dont says error. Script is good, when player spawn i see dafault car colors... where is these?. Its for gamemode Race.

Thank you

addEventHandler("onPlayerSpawn",root,function () 
local vehicle = getPedOccupiedVehicle(source) 
if vehicle then 
setVehicleColor(vehicle,math.random(255),math.random(255),math.random(255)) 
end 
end) 

Link to comment

try

addEventHandler("onPlayerSpawn",root,  
function (vehicle, uPlayer) 
    if isPedInVehicle( uPlayer ) then 
        local vehicle = getPedOccupiedVehicle( uPlayer ) 
        if vehicle then 
            local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) 
            setVehicleColor( vehicle, r, g, b ) 
        end 
    end 
end 
) 

@NodZen : what did you changed? -.-

Edited by Guest
Link to comment

Sorry i forget the timer

addEventHandler("onPlayerSpawn",root,  
function (vehicle, uPlayer) 
    if isPedInVehicle( uPlayer ) then 
        local vehicle = getPedOccupiedVehicle( uPlayer ) 
        if vehicle then 
            local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) 
            setTimer( setVehicleColor( vehicle, r, g, b ), 1000, 0 ) 
        end 
    end 
end 
) 
Link to comment

he created a vehicles i guess

addEventHandler("onPlayerSpawn",root,  
function (vehicle) 
    if not isPedInVehicle( uPlayer ) then 
    warpPedIntoVehicle ( uPlayer, vehicle ) 
        local vehicle = getPedOccupiedVehicle( uPlayer ) 
        if vehicle then 
            local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) 
            setTimer( setVehicleColor( vehicle, r, g, b ), 500, 0 ) 
        end 
    end 
end 
) 

Link to comment
he created a vehicles i guess
addEventHandler("onPlayerSpawn",root,  
function (vehicle) 
    if not isPedInVehicle( uPlayer ) then 
    warpPedIntoVehicle ( uPlayer, vehicle ) 
        local vehicle = getPedOccupiedVehicle( uPlayer ) 
        if vehicle then 
            local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) 
            setTimer( setVehicleColor( vehicle, r, g, b ), 500, 0 ) 
        end 
    end 
end 
) 

uPlayer is not define.

And he not said want timer !!

And how the player have car if he spawn ?>?

Edit #:

function(player) 
    if getElementType(player) == 'player' then 
        if isPedInVehicle(player) then 
            local vehicle = getPedOccupiedVehicle( player ) 
                if vehicle then 
                    local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) 
                        setTimer(setVehicleColor,1000,0,vehicle, r, g, b ) 
            end 
        end 
    end 
end 
Edited by Guest
Link to comment
addEventHandler ( "onVehicleEnter", root, 
    function ( ) 
        setVehicleColor ( source, math.random ( 255 ), math.random ( 255 ), math.random ( 255 ) ) 
    end 
) 

Good but all players have 1 colors :x i want etc.

player 1 red

player 2 green

player 3 yellow

...

Link to comment
Each vehicle will have a random code with that, it won't use the same one for all of them.

Hmn then why all cars have same color ?

Maybe you have another script setting the color aswell.

Try this:

addEventHandler ( "onVehicleEnter", root, 
    function ( ) 
        setTimer ( setVehicleColor, 1000, 1, source, math.random ( 255 ), math.random ( 255 ), math.random ( 255 ) ) 
    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...