Fantanic Posted February 6, 2014 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
TAPL Posted February 6, 2014 Posted February 6, 2014 onPlayerQuit -> getElementData -> setAccountData onPlayerLogin -> getAccountData -> setElementData
Fantanic Posted February 6, 2014 Author 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)
TAPL Posted February 6, 2014 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)
myonlake Posted February 6, 2014 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.
myonlake Posted February 6, 2014 Posted February 6, 2014 In the 'loadwanted' function, switch 'playerAccount' to 'playeraccount'. Simply the typo causes it not to work.
Fantanic Posted February 6, 2014 Author 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)
myonlake Posted February 6, 2014 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.
Fantanic Posted February 6, 2014 Author 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
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