Fantanic Posted February 6, 2014 Share Posted February 6, 2014 Hello. I got a little problem , im trying to save an elementdata and load it on playerLogin. The elementdata is 'wanted' . Thank you Link to comment
TAPL Posted February 6, 2014 Share Posted February 6, 2014 onPlayerQuit -> getElementData -> setAccountData onPlayerLogin -> getAccountData -> setElementData Link to comment
Fantanic Posted February 6, 2014 Author Share Posted February 6, 2014 Thank you i wil try it Link to comment
Fantanic Posted February 6, 2014 Author Share Posted February 6, 2014 Like this? or do i have to add the setwantedlevel or? function savewanted() local user = getPlayerFromName(player) getElementData(user,"wanted") local playeraccount = getPlayerAccount ( source ) setAccountData ( playeraccount, "wanted", wanted ) end addEventHandler("onPlayerQuit", getRootElement(), savewanted) function loadwanted (_, playeraccount) local playerAccount = getPlayerAccount(source) -- get his account if ( playerAccount ) then local wanted = getAccountData(playerAccount, "wanted") if (wanted) then end end end addEventHandler("onPlayerLogin", getRootElement(), loadwanted) Link to comment
TAPL Posted February 6, 2014 Share Posted February 6, 2014 function savewanted() local playeraccount = getPlayerAccount(source) if playeraccount and not isGuestAccount(playeraccount) then local wanted = getElementData(source, "wanted") if wanted then setAccountData(playeraccount, "wanted", wanted) end end end addEventHandler("onPlayerQuit", getRootElement(), savewanted) function loadwanted(_, playeraccount) local wanted = getAccountData(playerAccount, "wanted") if (wanted) then setElementData(source, "wanted", wanted) end end addEventHandler("onPlayerLogin", getRootElement(), loadwanted) Link to comment
myonlake Posted February 6, 2014 Share Posted February 6, 2014 It should work. Make sure the script is server-side since the account functions can only be triggered from the server. Link to comment
Fantanic Posted February 6, 2014 Author Share Posted February 6, 2014 Jep here is the meta : Link to comment
myonlake Posted February 6, 2014 Share Posted February 6, 2014 In the 'loadwanted' function, switch 'playerAccount' to 'playeraccount'. Simply the typo causes it not to work. Link to comment
Fantanic Posted February 6, 2014 Author Share Posted February 6, 2014 Thanks it works but is it posible to add a exported function for setting the wantedlevel? Cause im using it if ur wanted the stars get up but now u only see it in tab that u are wanted.(it works it detects ur wanted but the stars arent coming up) example : function savewanted() local playeraccount = getPlayerAccount(source) if playeraccount and not isGuestAccount(playeraccount) then local wanted = getElementData(source, "wanted") if wanted then setAccountData(playeraccount, "wanted", wanted) end end end addEventHandler("onPlayerQuit", getRootElement(), savewanted) function loadwanted(_, playeraccount) local wanted = getAccountData(playeraccount, "wanted") if (wanted) then setElementData(source, "wanted", wanted) end setPlayerWanted(source,amount) end addEventHandler("onPlayerLogin", getRootElement(), loadwanted) Link to comment
myonlake Posted February 6, 2014 Share Posted February 6, 2014 Switch setPlayerWanted to setPlayerWantedLevel. And what do you mean by exported function? You can just use setAccountData whenever you need to. Link to comment
Fantanic Posted February 6, 2014 Author Share Posted February 6, 2014 It didnt worked , i dont rlly think 'amount' is defined? but its showing in tab but the stars arent showing up Solved Thanks 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