Stylez Posted February 18, 2013 Share Posted February 18, 2013 Hey, guys need some help function cham(thePlayer, cmdName, r,g,b) local Vehicle = getPedOccupiedVehicle(thePlayer) if isPedInVehicle(thePlayer) then local r,g,b = math.random(0,255) outputChatBox(tonumber(r,g,b)) end end addCommandHandler("cham", cham) This is my script, and i want it to output to chabox 3 colors like that "12 57 96" not just 1 color "154" as it does now. Link to comment
Michcio Posted February 18, 2013 Share Posted February 18, 2013 function cham(thePlayer, cmdName) local Vehicle = getPedOccupiedVehicle(thePlayer) if isPedInVehicle(thePlayer) then local r = math.random(0,255) local g = math.random(0,255) local b = math.random(0,255) outputChatBox(tostring(r)..","..tostring(g)..","..tostring(b)) end end addCommandHandler("cham", cham) EDITED I think you want to choose random color ids? Link to comment
Stylez Posted February 18, 2013 Author Share Posted February 18, 2013 Nah, it is just what i need. Thanks Link to comment
Stylez Posted February 18, 2013 Author Share Posted February 18, 2013 well.. i dont understand what is wrong here. debug keeps saying bad argument @ isPedInVehicle I am trying to make a car color change script.. where color of the car changes slowly.. function cham(thePlayer) if isPedInVehicle(thePlayer) then local vehicle = getPedOccupiedVehicle(thePlayer) if vehicle then local r,g,b = math.random(255), math.random(255), math.random(255) setVehicleColor(vehicle, r,g,b) end end end addCommandHandler("cham", cham) setTimer(cham, 5000, 0) Link to comment
Jaysds1 Posted February 18, 2013 Share Posted February 18, 2013 if this is client-sided, then the 'thePlayer' var isn't a player, it's the command name, use localPlayer instead. Here: function cham() if isPedInVehicle(localPlayer) then local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then local r,g,b = math.random(255), math.random(255), math.random(255) setVehicleColor(vehicle, r,g,b) end end end addCommandHandler("cham", cham) setTimer(cham, 5000, 0) Link to comment
Stylez Posted February 18, 2013 Author Share Posted February 18, 2013 I was trying to do it Server-side Link to comment
csiguusz Posted February 18, 2013 Share Posted February 18, 2013 You are getting this error because of the timer, it doesn't give a player element to the function. If you really want to do it on server-side then do it so: function cham( thePlayer ) if isPedInVehicle( thePlayer ) then local vehicle = getPedOccupiedVehicle( thePlayer ) if vehicle then local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) setVehicleColor(vehicle, r, g, b) end end end addCommandHandler("cham", cham) setTimer( function() for i, v in ipairs( getElementsByType( "player" ) ) do cham( v ) end end, 5000, 0 ) Link to comment
Stylez Posted February 18, 2013 Author Share Posted February 18, 2013 Thanks it works now, but i wanted to colors change slowly within 5 sec. Not instantly after 5 sec. Link to comment
csiguusz Posted February 18, 2013 Share Posted February 18, 2013 Thanks it works now, but i wanted to colors change slowly within 5 sec. Not instantly after 5 sec. Edit: It's maybe also possible with a shader instead of setVehicleColor, but sorry, I don't know shaders. Link to comment
Jaysds1 Posted February 18, 2013 Share Posted February 18, 2013 Try this: function cham( thePlayer ) if isPedInVehicle( thePlayer ) then local vehicle = getPedOccupiedVehicle( thePlayer ) if vehicle then local r, g, b = math.random( 255 ), math.random( 255 ), math.random( 255 ) setVehicleColor(vehicle, r, g, b) end end end addCommandHandler("cham", cham) setTimer( function() for i, v in ipairs( getElementsByType( "player" ) ) do cham( v ) end end, math.random(1,5)*1000, 0 ) that will give a random number instead of always choosing 5secs Link to comment
Stylez Posted February 20, 2013 Author Share Posted February 20, 2013 No, you dont get it. i want the color of the car to change slowly, just like in FFS when you buy that(i dont know what its called.) Link to comment
Stylez Posted February 21, 2013 Author Share Posted February 21, 2013 Ok, i see nobody can help me with this. So maybe theres is any resource with this script? 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