Annas Posted May 12, 2015 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
Dealman Posted May 12, 2015 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. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Walid Posted May 12, 2015 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) Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
Annas Posted May 12, 2015 Author 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
Walid Posted May 12, 2015 Posted May 12, 2015 Thx , Mr.Walid You are welcome Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
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