Adde Posted June 18, 2013 Share Posted June 18, 2013 Hello, how should I do if I want to save the text from scoreboardColumn "Class" onPlayerQuit and then set that text back in same scoreboardColumn onPlayerLogin? Is this near right? function openClass() thePlayer = getPlayerAccount(source) if (thePlayer) then getAccountData(thePlayer, "theClass") setElementData(thePlayer, "theClass", Class) end end addEventHandler("onPlayerLogin",getRootElement(), openClass) function saveClass() thePlayer = getPlayerAccount(source) if (thePlayer) then local theClass = getElementData(source, "Class") setAccountData(thePlayer,"theClass", theClass) end end addEventHandler("onPlayerQuit",getRootElement(), saveClass) Thankfull for answears Link to comment
PaiN^ Posted June 18, 2013 Share Posted June 18, 2013 function openClass( _,acc ) if not isGuestAccount( acc ) then local class = getAccountData(thePlayer, "theClass") if class then setElementData( source, "theClass", class ) end end end addEventHandler( "onPlayerLogin", getRootElement( ), openClass ) function saveClass( ) local thePlayer = getPlayerAccount( source ) if not isGuestAccount( thePlayer ) then local theClass = getElementData( source, "Class" ) setAccountData( thePlayer, "theClass", theClass ) end end addEventHandler( "onPlayerQuit", getRootElement( ), saveClass ) Link to comment
K4stic Posted June 18, 2013 Share Posted June 18, 2013 function openClass() local thePlayer = getPlayerAccount(source) if (thePlayer) then local Class = getAccountData(thePlayer, "theClass") setElementData(source, "theClass", Class) end end addEventHandler("onPlayerLogin",getRootElement(), openClass) function saveClass( ) if (isGuestAccount ( getPlayerAccount ( source ) ) ) then else local account = getPlayerAccount (source) if (account) then local theClass = getElementData(source, "Class") setAccountData(thePlayer,"theClass", theClass) end end addEventHandler("onPlayerQuit", root, saveClass) Link to comment
K4stic Posted June 18, 2013 Share Posted June 18, 2013 sorry for double post but Pαίй and me post almost at same time Link to comment
iPrestege Posted June 18, 2013 Share Posted June 18, 2013 (edited) function openClass( _,acc ) if not isGuestAccount( acc ) then local class = getAccountData(thePlayer, "theClass") if class then setElementData( source, "theClass", class ) end end end addEventHandler( "onPlayerLogin", getRootElement( ), openClass ) function saveClass( ) local thePlayer = getPlayerAccount( source ) if not isGuestAccount( thePlayer ) then local theClass = getElementData( source, "Class" ) setAccountData( thePlayer, "theClass", theClass ) end end addEventHandler( "onPlayerQuit", getRootElement( ), saveClass ) thePlayer O_o = acc There's no need to check guest account. Edited June 18, 2013 by Guest Link to comment
PaiN^ Posted June 18, 2013 Share Posted June 18, 2013 I had an error at line 3, Re-read the code thePlayer is the account . Corrected code : function openClass( _,acc ) if not isGuestAccount( acc ) then local class = getAccountData( acc, "theClass" ) if class then setElementData( source, "theClass", class ) end end end addEventHandler( "onPlayerLogin", getRootElement( ), openClass ) function saveClass( ) local acc = getPlayerAccount( source ) if not isGuestAccount( acc ) then local theClass = getElementData( source, "Class" ) setAccountData( acc, "theClass", theClass ) end end addEventHandler( "onPlayerQuit", getRootElement( ), saveClass ) Link to comment
Adde Posted June 19, 2013 Author Share Posted June 19, 2013 I had an error at line 3, Re-read the code thePlayer is the account .Corrected code : function openClass( _,acc ) if not isGuestAccount( acc ) then local class = getAccountData( acc, "theClass" ) if class then setElementData( source, "theClass", class ) end end end addEventHandler( "onPlayerLogin", getRootElement( ), openClass ) function saveClass( ) local acc = getPlayerAccount( source ) if not isGuestAccount( acc ) then local theClass = getElementData( source, "Class" ) setAccountData( acc, "theClass", theClass ) end end addEventHandler( "onPlayerQuit", getRootElement( ), saveClass ) It doesn´t work The scoreboardColumn "Class" is still empty for me when I log on to the server after I left it with text in that column. Link to comment
bandi94 Posted June 19, 2013 Share Posted June 19, 2013 I left MTA 4-5 month ago but i am planning to come back in 2-3 week's. But if i remember well you can't use Account Data with "onPlayerQuit" it will return NULL (it's to late when the function is called the player already left the server so you can't get his account). If i am wrong then somebody corect me how i told it was long time ago Link to comment
PaiN^ Posted June 19, 2013 Share Posted June 19, 2013 @ bandi94 : You can use it with onPlayerQuit ( as far as i know ) @Adde : I don't see where you're adding the scoreboard column in that code, Post your full code . Link to comment
Adde Posted July 4, 2013 Author Share Posted July 4, 2013 @ bandi94 :You can use it with onPlayerQuit ( as far as i know ) @Adde : I don't see where you're adding the scoreboard column in that code, Post your full code . I have a whole spawn script with that column, and I add your suggestion into that 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