Jump to content

Occupation Save


Annas

Recommended Posts

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 . :fadein: and thx

Link to comment

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...