Desaster Posted October 21, 2013 Share Posted October 21, 2013 hello , it me again asking for help I hope you don't get annoyed from me I made this could you tell me what is the problem ? ----------------------------------------Color Saver-------------------------------------- function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local veh = getElementData (source, "hisCar1") local rgb = getVehicleColor(veh) -- get the player money setAccountData ( playeraccount, "color", rgb ) -- save it in his account end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local color = getAccountData ( playeraccount, "color" ) local veh = getElementData (source, "hisCar1") -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( color ) then setVehicleColor ( veh, color, 0 ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Link to comment
HunT Posted October 21, 2013 Share Posted October 21, 2013 Check it : https://wiki.multitheftauto.com/wiki/GetVehicleColor r,g,b and not rgb Link to comment
Desaster Posted October 21, 2013 Author Share Posted October 21, 2013 function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local veh = getElementData (source, "hisCar1") local r, g, b = getVehicleColor(veh) -- get the player money setAccountData ( playeraccount, "color", ""..r, g, b ) -- save it in his account end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local r, g, b = getAccountData ( playeraccount, "color" ) local veh = getElementData (source, "hisCar1") -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( color ) then setVehicleColor ( veh, r, g, b, 255 ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) still don't work maybe the problem is that the vehicle will be spawned after ? Link to comment
Jusonex Posted October 21, 2013 Share Posted October 21, 2013 You can't receive several returns from getAccountData. getAccountData returns always a string. Thus, the first version is almost correct. If you take a look at the wiki page, you'll find that the non-rgb version requires each of the four available vehicle colors: bool setVehicleColor ( vehicle theVehicle, int color1, int color2, int color3, int color4 ) ==> Line 20 of the first version should look like this: setVehicleColor ( veh, color, 0, 0, 0 ) 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