JoZeFSvK Posted July 12, 2013 Posted July 12, 2013 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)
MIKI785 Posted July 12, 2013 Posted July 12, 2013 use onVehicleEnter instead, player might get spawned before the vehicle is created
iMr.3a[Z]eF Posted July 12, 2013 Posted July 12, 2013 do you mean you want to set it random colours when he entered the car or spawn him?
JoZeFSvK Posted July 12, 2013 Author Posted July 12, 2013 do you mean you want to set it random colours when he entered the car or spawn him? When spawn, but colors dont work i see defauld
NodZen Posted July 12, 2013 Posted July 12, 2013 Try it: addEventHandler("onPlayerSpawn",root, function () local car = getPedOccupiedVehicle(source) if car then setVehicleColor(car,math.random(0,255),math.random(0,255),math.random(0,255)) end end )
iMr.3a[Z]eF Posted July 12, 2013 Posted July 12, 2013 (edited) 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 July 12, 2013 by Guest
iMr.3a[Z]eF Posted July 12, 2013 Posted July 12, 2013 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 )
فاّرس Posted July 12, 2013 Posted July 12, 2013 (edited) ??????????? Parameters float posX, float posY, float posZ, float spawnRotation, team theTeam, int theSkin, int theInterior, int theDimension and tell me how the player have car if he spawn? Edited July 12, 2013 by Guest
فاّرس Posted July 12, 2013 Posted July 12, 2013 what are you talking about? uPlayer = ?? vehicle = ??? ,,
iMr.3a[Z]eF Posted July 12, 2013 Posted July 12, 2013 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 )
فاّرس Posted July 12, 2013 Posted July 12, 2013 (edited) 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 July 12, 2013 by Guest
iMr.3a[Z]eF Posted July 12, 2013 Posted July 12, 2013 This is set one random colors Also the function is no't named use setTimer setTimer ( 1000, 0, functionName)
PaiN^ Posted July 12, 2013 Posted July 12, 2013 This is set one random colorsAlso the function is no't named use setTimer setTimer ( 1000, 0, functionName) setTimer( functionName, 1000, 0 )
iMr.3a[Z]eF Posted July 12, 2013 Posted July 12, 2013 This is set one random colorsAlso the function is no't named use setTimer setTimer ( 1000, 0, functionName) setTimer( functionName, 1000, 0 ) lol my bad
JoZeFSvK Posted July 13, 2013 Author Posted July 13, 2013 Lol i dont need timer .. i dont wan chenage carcolors when maps run i want ... changes vehicle color to random color everytime the player spawn
Castillo Posted July 13, 2013 Posted July 13, 2013 addEventHandler ( "onVehicleEnter", root, function ( ) setVehicleColor ( source, math.random ( 255 ), math.random ( 255 ), math.random ( 255 ) ) end )
JoZeFSvK Posted July 14, 2013 Author Posted July 14, 2013 addEventHandler ( "onVehicleEnter", root, function ( ) setVehicleColor ( source, math.random ( 255 ), math.random ( 255 ), math.random ( 255 ) ) end ) Good but all players have 1 colors i want etc. player 1 red player 2 green player 3 yellow ...
Castillo Posted July 14, 2013 Posted July 14, 2013 Each vehicle will have a random code with that, it won't use the same one for all of them.
JoZeFSvK Posted July 15, 2013 Author Posted July 15, 2013 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 ?
فاّرس Posted July 15, 2013 Posted July 15, 2013 Try the timer, setTimer(setVehicleColor,1000,0,source, math.random ( 255 ), math.random ( 255 ), math.random ( 255 ) )
Castillo Posted July 15, 2013 Posted July 15, 2013 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 )
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