JoZeFSvK Posted July 12, 2013 Share 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) Link to comment
MIKI785 Posted July 12, 2013 Share Posted July 12, 2013 use onVehicleEnter instead, player might get spawned before the vehicle is created Link to comment
JoZeFSvK Posted July 12, 2013 Author Share Posted July 12, 2013 Hmm i try but dont work Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share Posted July 12, 2013 do you mean you want to set it random colours when he entered the car or spawn him? Link to comment
JoZeFSvK Posted July 12, 2013 Author Share 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 Link to comment
NodZen Posted July 12, 2013 Share 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 ) Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share 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 Link to comment
NodZen Posted July 12, 2013 Share Posted July 12, 2013 @6ArHxiMr'3a[Z]eF: variables and the math.random Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share 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 ) Link to comment
فاّرس Posted July 12, 2013 Share 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 Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share Posted July 12, 2013 what are you talking about? Link to comment
فاّرس Posted July 12, 2013 Share Posted July 12, 2013 what are you talking about? uPlayer = ?? vehicle = ??? ,, Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share 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 ) Link to comment
فاّرس Posted July 12, 2013 Share 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 Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share Posted July 12, 2013 This is set one random colors Also the function is no't named use setTimer setTimer ( 1000, 0, functionName) Link to comment
PaiN^ Posted July 12, 2013 Share 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 ) Link to comment
iMr.3a[Z]eF Posted July 12, 2013 Share 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 Link to comment
JoZeFSvK Posted July 13, 2013 Author Share 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 Link to comment
Castillo Posted July 13, 2013 Share Posted July 13, 2013 addEventHandler ( "onVehicleEnter", root, function ( ) setVehicleColor ( source, math.random ( 255 ), math.random ( 255 ), math.random ( 255 ) ) end ) Link to comment
JoZeFSvK Posted July 14, 2013 Author Share 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 ... Link to comment
Castillo Posted July 14, 2013 Share Posted July 14, 2013 Each vehicle will have a random code with that, it won't use the same one for all of them. Link to comment
JoZeFSvK Posted July 15, 2013 Author Share 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 ? Link to comment
فاّرس Posted July 15, 2013 Share Posted July 15, 2013 Try the timer, setTimer(setVehicleColor,1000,0,source, math.random ( 255 ), math.random ( 255 ), math.random ( 255 ) ) Link to comment
Castillo Posted July 15, 2013 Share 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 ) Link to comment
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