Annas Posted May 12, 2015 Share Posted May 12, 2015 hi , i have a big problem : Occupation not saved .. how can i know the DATABASE of the Occupation ? when i do ./criminal , it showed in the TAB : |OCCUPATION| |Criminal| when i dead , the occupation saved , when i kill some one occupation saved , but when i reconnect or disconnect + when i back in game , the occupation will not saved .. and there are no any occupation in the OCCUPATION in Scoreboard pls help me ! the database : function createTeamsOnStart () teamCriminal = createTeam ( "Criminal", 255, 0, 0 ) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) function goCrim ( player, command ) setPlayerTeam ( player, teamCriminal ) setPlayerNametagColor ( player, 255,0,0 ) setElementData(player, "Occupation", "Criminal") end addCommandHandler ( "criminal", goCrim ) setElementData(player, "Occupation", "Criminal") i wanna it when i be in any Occupation , it will be saved when i reconnect . and thx Link to comment
Dealman Posted May 12, 2015 Share Posted May 12, 2015 If you read the Wiki thoroughly you'd find out that Element Data is not saved. Whenever you leave the server, this data is lost. You'll want to use setAccountData for the data to be stored in the database. This data is then bound to that account. Works pretty much the same way as Element Data. Link to comment
Walid Posted May 12, 2015 Share Posted May 12, 2015 Try to use this function SaveOccupation() local occupation = getElementData(source, "Occupation") or "" local account = getPlayerAccount(source) if account and not isGuestAccount(account) then setAccountData(account,"Occupation",occupation) end end addEventHandler("onPlayerQuit",root,SaveOccupation) function LoadOccupation(_,cur) local occupation = getAccountData(cur, "Occupation") if occupation then setElementData(source,"Occupation",tostring(occupation)) end end addEventHandler("onPlayerLogin",root,LoadOccupation) Link to comment
Annas Posted May 12, 2015 Author Share Posted May 12, 2015 Try to use this function SaveOccupation() local occupation = getElementData(source, "Occupation") or "" local account = getPlayerAccount(source) if account and not isGuestAccount(account) then setAccountData(account,"Occupation",occupation) end end addEventHandler("onPlayerQuit",root,SaveOccupation) function LoadOccupation(_,cur) local occupation = getAccountData(cur, "Occupation") if occupation then setElementData(source,"Occupation",tostring(occupation)) end end addEventHandler("onPlayerLogin",root,LoadOccupation) Thx , Mr.Walid 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