function onPlayerQuit ( )
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in
local playerclass = getElementData ( source, "Class" ) -- get the player data
setAccountData ( playeraccount, "class.data", playerclass ) -- save it in his account
end
end
function onPlayerLogin (_, playeraccount )
-- when a player logins, retrieve his money amount from his account data and set it
if ( playeraccount ) then
local playerclass = getAccountData ( playeraccount, "class.data" )
if ( playerclass ) then
setElementData ( source, "Class", playerclass )
end
end
end
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin)