Imposter Posted July 8, 2012 Posted July 8, 2012 Hi guys, im making a derby server, I need help with storing info to the user's account, some of the information i need to store is, the player's rank from all the players in the server based on points(which also needs to be stored) and the players chosen skin, and car colour/headlight color. Help Please and thank you Eat My Dust - DM/Deathmatch
Castillo Posted July 8, 2012 Posted July 8, 2012 You can use the account data functions, that would be easier for you. getAccountData setAccountData San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Imposter Posted July 8, 2012 Author Posted July 8, 2012 You can use the account data functions, that would be easier for you. getAccountData setAccountData YOU can do that?? Thanks!! Eat My Dust - DM/Deathmatch
Castillo Posted July 9, 2012 Posted July 9, 2012 Of course you can. You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Imposter Posted July 9, 2012 Author Posted July 9, 2012 Of course you can.You're welcome. Just one more thing, how do i get the cars headlight color? Eat My Dust - DM/Deathmatch
Castillo Posted July 9, 2012 Posted July 9, 2012 https://wiki.multitheftauto.com/wiki/Get ... LightColor San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Imposter Posted July 9, 2012 Author Posted July 9, 2012 playerAccount = getPlayerAccount ( source ) playerVehicle = getPlayerOccupiedVehicle ( playerSource ) function saveColours () if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) local r, g, b = getVehicleHeadLightColor ( playerVehicle ) setAccountData ( playerAccount, "idd.ccolor1", colour1 ) setAccountData ( playerAccount, "idd.ccolor2", colour2 ) setAccountData ( playerAccount, "idd.ccolor3", colour3 ) setAccountData ( playerAccount, "idd.ccolor4", colour4 ) setAccountData ( playerAccount, "idd.cchcr", r) setAccountData ( playerAccount, "idd.cchcg", g) setAccountData ( playerAccount, "idd.cchcb", b) end end addCommandHandler("saveColours", getRootElement(), setColours) function setCarColours() local color1 = getAccountData ( playerAccount, "idd.ccolor1") local color2 = getAccountData ( playerAccount, "idd.ccolor2") local color3 = getAccountData ( playerAccount, "idd.ccolor3") local color4 = getAccountData ( playerAccount, "idd.ccolor4") local r = getAccountData ( playerAccount, "idd.cchcr" ) local g = getAccountData ( playerAccount, "idd.cchcg" ) local b = getAccountData ( playerAccount, "idd.cchcb" ) setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) getVehicleHeadLightColor ( playerVehicle, r,g,b) end addEventHandler("",getRootElement(),setCarColours) This should work right? but what handler do i use for the colours, when a car is spawned, i am using the resource race. Eat My Dust - DM/Deathmatch
Castillo Posted July 9, 2012 Posted July 9, 2012 function saveColours ( playerSource ) local playerAccount = getPlayerAccount ( playerSource ) local playerVehicle = getPlayerOccupiedVehicle ( playerSource ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) local r, g, b = getVehicleHeadLightColor ( playerVehicle ) setAccountData ( playerAccount, "idd.ccolor1", colour1 ) setAccountData ( playerAccount, "idd.ccolor2", colour2 ) setAccountData ( playerAccount, "idd.ccolor3", colour3 ) setAccountData ( playerAccount, "idd.ccolor4", colour4 ) setAccountData ( playerAccount, "idd.cchcr", r) setAccountData ( playerAccount, "idd.cchcg", g) setAccountData ( playerAccount, "idd.cchcb", b) end end addCommandHandler("saveColours", saveColours) function setCarColours(_, playerAccount) local playerVehicle = getPlayerOccupiedVehicle ( source ) local color1 = getAccountData ( playerAccount, "idd.ccolor1") local color2 = getAccountData ( playerAccount, "idd.ccolor2") local color3 = getAccountData ( playerAccount, "idd.ccolor3") local color4 = getAccountData ( playerAccount, "idd.ccolor4") local r = getAccountData ( playerAccount, "idd.cchcr" ) local g = getAccountData ( playerAccount, "idd.cchcg" ) local b = getAccountData ( playerAccount, "idd.cchcb" ) setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) getVehicleHeadLightColor ( playerVehicle, r,g,b) end addEventHandler("onPlayerLogin",getRootElement(),setCarColours) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
50p Posted July 9, 2012 Posted July 9, 2012 You could use onMapStarting (https://wiki.multitheftauto.com/wiki/Resource:Race) and check if player is logged in. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Imposter Posted July 9, 2012 Author Posted July 9, 2012 You could use onMapStarting (https://wiki.multitheftauto.com/wiki/Resource:Race) and check if player is logged in. how would i do it, do i have to add, addEvent somewhere? or do i have to change my meta to load the dependancy? Eat My Dust - DM/Deathmatch
Imposter Posted July 9, 2012 Author Posted July 9, 2012 oh sorry, i get it. in my meta i need to pu addon="race" and in my script i need to do addEvent("onMapStarting") and in the event handler i put onMapStarting,right? Eat My Dust - DM/Deathmatch
50p Posted July 9, 2012 Posted July 9, 2012 Yeah, that's correct. If you want your addon to start with race then you have to change race meta.xml. In the settings section you will find addons that start with race. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Imposter Posted July 9, 2012 Author Posted July 9, 2012 Yeah, that's correct. If you want your addon to start with race then you have to change race meta.xml. In the settings section you will find addons that start with race. If i understand you correctly, this is what i am suppoesed to do right? but i get this message in the console: "WARNING: [gamemodes]\[race]\[addons]\gr_stats\server.lua:32: Bad arguement @ 'addEventHandler' [Expected at argument 2, got function]" Here is my meta... <meta> <info name="IDD Stats" addon="race" /> <script src="server.lua" type="server" /> </meta> Here is my code... addEvent ( "onMapStarting" ) function saveColours ( playerSource ) local playerAccount = getPlayerAccount ( playerSource ) local playerVehicle = getPlayerOccupiedVehicle ( playerSource ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) local r, g, b = getVehicleHeadLightColor ( playerVehicle ) setAccountData ( playerAccount, "idd.ccolor1", colour1 ) setAccountData ( playerAccount, "idd.ccolor2", colour2 ) setAccountData ( playerAccount, "idd.ccolor3", colour3 ) setAccountData ( playerAccount, "idd.ccolor4", colour4 ) setAccountData ( playerAccount, "idd.cchcr", r) setAccountData ( playerAccount, "idd.cchcg", g) setAccountData ( playerAccount, "idd.cchcb", b) outputChatBox ( "Your Chosen Colours have Been Saved!", source) end end addCommandHandler("saveColours", saveColours) function setCarColours(_, playerAccount) local playerVehicle = getPlayerOccupiedVehicle ( source ) local color1 = getAccountData ( playerAccount, "idd.ccolor1") local color2 = getAccountData ( playerAccount, "idd.ccolor2") local color3 = getAccountData ( playerAccount, "idd.ccolor3") local color4 = getAccountData ( playerAccount, "idd.ccolor4") local r = getAccountData ( playerAccount, "idd.cchcr" ) local g = getAccountData ( playerAccount, "idd.cchcg" ) local b = getAccountData ( playerAccount, "idd.cchcb" ) setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) getVehicleHeadLightColor ( playerVehicle, r,g,b) end addEventHandler ( "onMapStarting" ,setCarColours ) Eat My Dust - DM/Deathmatch
Wei Posted July 9, 2012 Posted July 9, 2012 addEvent ( "onMapStarting" ) function saveColours ( playerSource ) local playerAccount = getPlayerAccount ( playerSource ) local playerVehicle = getPlayerOccupiedVehicle ( playerSource ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) local r, g, b = getVehicleHeadLightColor ( playerVehicle ) setAccountData ( playerAccount, "idd.ccolor1", colour1 ) setAccountData ( playerAccount, "idd.ccolor2", colour2 ) setAccountData ( playerAccount, "idd.ccolor3", colour3 ) setAccountData ( playerAccount, "idd.ccolor4", colour4 ) setAccountData ( playerAccount, "idd.cchcr", r) setAccountData ( playerAccount, "idd.cchcg", g) setAccountData ( playerAccount, "idd.cchcb", b) outputChatBox ( "Your Chosen Colours have Been Saved!", source) end end addCommandHandler("saveColours", saveColours) function setCarColours(_, playerAccount) local playerVehicle = getPlayerOccupiedVehicle ( source ) local color1 = getAccountData ( playerAccount, "idd.ccolor1") local color2 = getAccountData ( playerAccount, "idd.ccolor2") local color3 = getAccountData ( playerAccount, "idd.ccolor3") local color4 = getAccountData ( playerAccount, "idd.ccolor4") local r = getAccountData ( playerAccount, "idd.cchcr" ) local g = getAccountData ( playerAccount, "idd.cchcg" ) local b = getAccountData ( playerAccount, "idd.cchcb" ) setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) getVehicleHeadLightColor ( playerVehicle, r,g,b) end addEventHandler ( "onMapStarting", getRootElement(),setCarColours ) -- For EVERY Event in server you need to have root here. Diet with russian vodka, lose 3 days in one week !
Imposter Posted July 9, 2012 Author Posted July 9, 2012 addEvent ( "onMapStarting" ) function saveColours ( playerSource ) local playerAccount = getPlayerAccount ( playerSource ) local playerVehicle = getPlayerOccupiedVehicle ( playerSource ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local color1, color2, color3, color4 = getVehicleColor ( playerVehicle ) local r, g, b = getVehicleHeadLightColor ( playerVehicle ) setAccountData ( playerAccount, "idd.ccolor1", colour1 ) setAccountData ( playerAccount, "idd.ccolor2", colour2 ) setAccountData ( playerAccount, "idd.ccolor3", colour3 ) setAccountData ( playerAccount, "idd.ccolor4", colour4 ) setAccountData ( playerAccount, "idd.cchcr", r) setAccountData ( playerAccount, "idd.cchcg", g) setAccountData ( playerAccount, "idd.cchcb", b) outputChatBox ( "Your Chosen Colours have Been Saved!", source) end end addCommandHandler("saveColours", saveColours) function setCarColours(_, playerAccount) local playerVehicle = getPlayerOccupiedVehicle ( source ) local color1 = getAccountData ( playerAccount, "idd.ccolor1") local color2 = getAccountData ( playerAccount, "idd.ccolor2") local color3 = getAccountData ( playerAccount, "idd.ccolor3") local color4 = getAccountData ( playerAccount, "idd.ccolor4") local r = getAccountData ( playerAccount, "idd.cchcr" ) local g = getAccountData ( playerAccount, "idd.cchcg" ) local b = getAccountData ( playerAccount, "idd.cchcb" ) setVehicleColor ( playerVehicle, color1, color2, color3, color4 ) getVehicleHeadLightColor ( playerVehicle, r,g,b) end addEventHandler ( "onMapStarting", getRootElement(),setCarColours ) -- For EVERY Event in server you need to have root here. Thank you blazy, that worked, but i need this last bit of info, i get a warning saying that getPedOccupidVehicle on line 2 is not a valid arg, why?? here is the code\ addEvent ( "onMapStarting" ) theVehicle = getPedOccupiedVehicle ( source ) function setLightColours ( source, commandName, r, g, b ) local playerAccount = getPlayerAccount ( source ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then setAccountData ( playerAccount, "idd.cchcr", r) setAccountData ( playerAccount, "idd.cchcg", g) setAccountData ( playerAccount, "idd.cchcb", b) setVehicleHeadLightColor ( theVehicle, r,g,b) setVehicleOverrideLights ( theVehicle, 2 ) outputChatBox ( "Your Chosen Light Colours have Been Saved!", source) end end addCommandHandler("setLightColours", setLightColours) function setCarColours () local playerAccount = getPlayerAccount ( source ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local color1, color2, color3, color4 = getVehicleColor ( theVehicle ) setAccountData ( playerAccount, "idd.ccolor1", colour1 ) setAccountData ( playerAccount, "idd.ccolor2", colour2 ) setAccountData ( playerAccount, "idd.ccolor3", colour3 ) setAccountData ( playerAccount, "idd.ccolor4", colour4 ) local crdone = outputChatBox ( "Your Current Car Colours have Been Saved!", source) end end addCommandHandler("setCarColours", setCarColours) function setAllColours(_, playerAccount) outputChatBox ("Broken!",source) local color1 = getAccountData ( playerAccount, "idd.ccolor1") local color2 = getAccountData ( playerAccount, "idd.ccolor2") local color3 = getAccountData ( playerAccount, "idd.ccolor3") local color4 = getAccountData ( playerAccount, "idd.ccolor4") local r = getAccountData ( playerAccount, "idd.cchcr" ) local g = getAccountData ( playerAccount, "idd.cchcg" ) local b = getAccountData ( playerAccount, "idd.cchcb" ) local cr = tonumber ( r ) local cg = tonumber ( g ) local cb = tonumber ( b ) setVehicleColor ( theVehicle, color1, color2, color3, color4 ) setVehicleHeadLightColor ( theVehicle, cr,cg,cb) end addCommandHandler ( "restoreColours", setAllColours) addEventHandler ( "onMapStarting", getRootElement(),setAllColours ) Eat My Dust - DM/Deathmatch
Fury Posted July 9, 2012 Posted July 9, 2012 addEvent ( "onMapStarting" ) function setLightColours ( source, commandName, r, g, b ) theVehicle = getPedOccupiedVehicle ( source ) if theVehicle then local playerAccount = getPlayerAccount ( source ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then setAccountData ( playerAccount, "idd.cchcr", r) setAccountData ( playerAccount, "idd.cchcg", g) setAccountData ( playerAccount, "idd.cchcb", b) setVehicleHeadLightColor ( theVehicle, r,g,b) setVehicleOverrideLights ( theVehicle, 2 ) outputChatBox ( "Your Chosen Light Colours have Been Saved!", source) else outputChatBox ( "You are not logged in!", source) end else outputChatBox ( "You do not have a Vehicle!", source) end end addCommandHandler("setLightColours", setLightColours) function setCarColours () theVehicle = getPedOccupiedVehicle ( source ) if theVehicle then local playerAccount = getPlayerAccount ( source ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local color1, color2, color3, color4 = getVehicleColor ( theVehicle ) setAccountData ( playerAccount, "idd.ccolor1", colour1 ) setAccountData ( playerAccount, "idd.ccolor2", colour2 ) setAccountData ( playerAccount, "idd.ccolor3", colour3 ) setAccountData ( playerAccount, "idd.ccolor4", colour4 ) local crdone = outputChatBox ( "Your Current Car Colours have Been Saved!", source) else outputChatBox ( "You are not logged in!", source) end else outputChatBox ( "You do not have a Vehicle!", source) end end addCommandHandler("setCarColours", setCarColours) function setAllColours(_, playerAccount) theVehicle = getPedOccupiedVehicle ( source ) if theVehicle then local playerAccount = getPlayerAccount ( source ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then outputChatBox ("Broken!",source) local color1 = getAccountData ( playerAccount, "idd.ccolor1") local color2 = getAccountData ( playerAccount, "idd.ccolor2") local color3 = getAccountData ( playerAccount, "idd.ccolor3") local color4 = getAccountData ( playerAccount, "idd.ccolor4") local r = getAccountData ( playerAccount, "idd.cchcr" ) local g = getAccountData ( playerAccount, "idd.cchcg" ) local b = getAccountData ( playerAccount, "idd.cchcb" ) local cr = tonumber ( r ) local cg = tonumber ( g ) local cb = tonumber ( b ) setVehicleColor ( theVehicle, color1, color2, color3, color4 ) setVehicleHeadLightColor ( theVehicle, cr,cg,cb) else outputChatBox ( "You are not logged in!", source) end else outputChatBox ( "You do not have a Vehicle!", source) end end addCommandHandler ( "restoreColours", setAllColours) addEventHandler ( "onMapStarting", getRootElement(),setAllColours ) Destruction Derby
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