So this is my code. When i quit from the game and go back to game, i go to the staff team every time i login. Even when i quit on another team but it still goes to the staff team. It looks like it doesn't not save the stats when i quit. Any help is welcome!
function SaveTeamOnLogOut()
local playerTeam = getPlayerTeam ( source )
local TeamName = getTeamName ( playerTeam )
local playerAccount = getPlayerAccount(source)
local r,g,b = getPlayerNametagColor ( source )
setAccountData(playerAccount, "Team", TeamName )
setAccountData(playerAccount, "Tag", r,g,b )
setAccountData(playerAccount, "Occupation", getElementData( source, "Occupation") )
end
addEventHandler("onPlayerQuit",getRootElement(),SaveTeamOnLogOut)
function LoadSaveOnLogin()
local playerAccount = getPlayerAccount(source)
local r,g,b = getAccountData(playerAccount, "Tag")
setPlayerTeam( source, getTeamFromName(getAccountData(playerAccount, "Team")))
setPlayerNametagColor ( source, r, g, b )
setElementData( source, "Occupation",(getAccountData(playerAccount, "Occupation")), true )
end
addEventHandler("onPlayerLogin",getRootElement(),LoadSaveOnLogin)
And the errors that script output:
WARNING: Bad argument @ 'setPlayerNametagColor' [Expected number at argument 3, got nil]