local Timer = { }
addCommandHandler ( "random_color" , function ( Player )
if ( getPedOccupiedVehicle ( Player ) ) then
if ( isTimer ( Timer [ Player ] ) ) then
killTimer ( Timer [ Player ] )
return
end
Timer [ Player ] = setTimer ( function ( Player )
if ( getPedOccupiedVehicle ( Player ) ) then
local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 )
setVehicleColor( getPedOccupiedVehicle ( Player ) , r , g , b )
end
end,300,0,Player)
end
end
)
function removeTimer ( )
if ( isTimer ( Timer [ source ] ) ) then
killTimer ( Timer [ source ] )
Timer [ source ] = nil
end
end
addEventHandler("onPlayerQuit",root,removeTimer)
addEventHandler("onPlayerWasted",root,removeTimer)