explOdeR Posted July 20, 2012 Posted July 20, 2012 Hey bros I have a problem with my script i made that but when i take a changuevehicle the team color changue to random colour please help function onSetTeamColorToCar(thePlayer) if isPedInVehicle (thePlayer) then local hisTeam = getPlayerTeam(thePlayer) if (hisTeam) then local r,g,b = getTeamColor(hisTeam) local hisVehicle = getPedOccupiedVehicle(thePlayer) setVehicleColor(hisVehicle,tonumber(r),tonumber(g),tonumber(b)) else -- if player not have team then local r,g,b = math.random(255),math.random(255),math.random(255) local hisVehicle = getPedOccupiedVehicle(thePlayer) setVehicleColor(hisVehicle,r,g,b) end end end function onWaitingForLaggers() --Delay it a bit to allow players to warp in their vehicle setTimer(onSetTeamColorToCar,2000,1,source) end addEventHandler("onNotifyPlayerReady",getRootElement(),onWaitingForLaggers) addEventHandler("onPlayerPickUpRacePickup",getRootElement(),onSetTeamColorToCar) addEventHandler("onPlayerReachCheckpoint",getRootElement(),onSetTeamColorToCar) addEventHandler("onResourceStart",getRootElement(),onSetTeamColorToCar)
Castillo Posted July 20, 2012 Posted July 20, 2012 function onSetTeamColorToCar ( thePlayer ) local hisVehicle = getPedOccupiedVehicle ( thePlayer ) local hisTeam = getPlayerTeam ( thePlayer ) if ( hisTeam ) then local r, g, b = getTeamColor ( hisTeam ) setVehicleColor ( hisVehicle, r, g, b ) else -- if player not have team then local r, g, b = math.random ( 255 ), math.random ( 255 ), math.random ( 255 ) setVehicleColor ( hisVehicle, r, g, b ) end end addEventHandler ( "onVehicleEnter", getRootElement(), onSetTeamColorToCar ) addEvent ( "onPlayerPickUpRacePickup", true ) addEventHandler ( "onPlayerPickUpRacePickup", getRootElement(), function ( ) onSetTeamColorToCar ( source ) end ) addEvent ( "onPlayerReachCheckpoint", true ) addEventHandler ( "onPlayerReachCheckpoint", getRootElement(), function ( ) onSetTeamColorToCar ( source ) end ) The first argument of 'onPlayerPickUpRacePickup' is the pickup ID. The first argument 'onPlayerReachCheckpoint' is the checkpoint ID. You forgot about addEvent.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now