Albinix Posted October 6, 2010 Posted October 6, 2010 Hi i'm trying making a carcolor script. When i login with script 1 the car color changes but when i add a timer to script 2 (to prevent the carcolor from change when i drive trough a vehicle pickup) the carcolor don't change. debug script 2 says "bad argument @ 'setVehicleColor'" and "bad argument @ 'getPedOccupiedVehicle'" script 1 function carcolor() local veh = getPedOccupiedVehicle( source ) setVehicleColor( veh, 0, 0, 0, 0 ) end addEventHandler( "onPlayerLogin", root, carcolor ) script 2 function carcolor() setTimer ( function() local veh = getPedOccupiedVehicle( source ) setVehicleColor( veh, 0, 0, 0, 0 ) end , 50, 0 ) end addEventHandler( "onPlayerLogin", root, carcolor )
dzek (varez) Posted October 6, 2010 Posted October 6, 2010 function loginHandler() setTimer(function(connected_player) local veh = getPedOccupiedVehicle(connected_player) if (veh) then setVehicleColor(veh,0,0,0) else outputDebugString("something is wrong! car cannot be found!") end end, 50, 0, source) end addEventHandler("onPlayerLogin", root, loginHandler) but this way can be bandwidth (lags!) and cpu (even more lags) consuming! better change car color on pickup pick up (race resource is triggering some event on this), or just onPlayerVehicleEnter tip: arguments for handling function of this event are: vehicle theVehicle, int seat, player jacked
Albinix Posted October 6, 2010 Author Posted October 6, 2010 Thanks for help Now i have a new problem -.-' I think this part is enough to show my problem If u do command and enter color 0 and 6 i want the messages to show but insted it change the colors to 0 and 6 but i don't want that -.- function carcolor( player, command, col1, col2 ) else if col1 == 0 and col2 == 6 then outputChatBox("* ERROR: You can't use admin colors!",player,255,0,0)
Castillo Posted October 6, 2010 Posted October 6, 2010 i don't get a word of what do you mean, maybe re-explain?
dzek (varez) Posted October 6, 2010 Posted October 6, 2010 function and then else if (btw: its elseif in lua, without space)? or if its a part of code - post whole code. most ppl think they can show only part of code and we will know the bug, but mostly they are showing wrong part of code
Castillo Posted October 6, 2010 Posted October 6, 2010 function and then else if (btw: its elseif in lua, without space)?or if its a part of code - post whole code. most ppl think they can show only part of code and we will know the bug, but mostly they are showing wrong part of code elseif its a complete word no spaces needed o_O
Albinix Posted October 7, 2010 Author Posted October 7, 2010 I want it to be when u do command /vehcolor 0 6 it will say "ERROR only admins can use that!" but it won't it just change the color to Black and orange anyways function carcolor( player, command, col1, col2 ) local veh = getPedOccupiedVehicle(player) local playeraccount = getPlayerAccount ( player ) if not col1 or not col2 then outputChatBox("* ERROR: Command is /vehcolor [vehicle color 1] [vehicle color 2]",player,255,0,0) elseif col1 == 0 and col2 == 6 then outputChatBox("* ERROR: You can't use admin colors!",player,255,0,0) else setAccountData (playeraccount, "xss.vehcolor1", col1) setAccountData (playeraccount, "xss.vehcolor2", col2) setVehicleColor(veh,col1,col2,0,0) outputChatBox("* VEHCOLOR: You succesful changed your vehicle colors!",player,0,255,0) end end addCommandHandler("vehcolor",carcolor)
Castillo Posted October 7, 2010 Posted October 7, 2010 function carcolor( player, command, col1, col2 ) local veh = getPedOccupiedVehicle(player) local playeraccount = getPlayerAccount ( player ) local accountname = getAccountName(getPlayerAccount(player)) if not col1 or not col2 then outputChatBox("* ERROR: Command is /vehcolor [vehicle color 1] [vehicle color 2]",player,255,0,0) elseif col1 == "0" and col2 == "6" then if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" )) then setAccountData (playeraccount, "xss.vehcolor1", col1) setAccountData (playeraccount, "xss.vehcolor2", col2) setVehicleColor(veh,col1,col2,0,0) outputChatBox("* VEHCOLOR: You succesful changed your vehicle colors!",player,0,255,0) else outputChatBox("* ERROR: You can't use admin colors!",player,255,0,0) end end 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