Jump to content

save team


BorderLine

Recommended Posts

i was searching on forum but i didnt find .

Is about save team

Anyone know why this dont work?

debug dont show errors

server

  
function onPlayerQuit ( ) 
       
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then  
            local playerteam = getPlayerTeam ( source ) 
            setAccountData ( playeraccount, "team", playerteam ) 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
     if ( playeraccount ) then 
            local playerteam = getAccountData ( playeraccount, "team" ) 
          if ( playerteam ) then 
            setPlayerTeam ( source, playerteam ) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) 
  

Link to comment

You save userdata but should save team name.

On quit.

getTeamName 

On login.

getTeamFromName 

Because you save team name string ( in event onPlayerQuit ) and you need get team from string ( in event onPlayerLogin ).

function fSaveManager ( ) 
    local uAccount = getPlayerAccount ( source ) 
    if uAccount and not isGuestAccount ( uAccount ) then  
        if eventName == 'onPlayerLogin' then 
            local sTeamName = getAccountData ( uAccount, 'team' ) 
            if sTeamName then 
                setPlayerTeam ( source, getTeamFromName( sTeamName ) ) 
            end 
        elseif eventName == 'onPlayerQuit' then 
            local uTeam = getPlayerTeam( source ) 
            if uTeam then 
                uTeam = getTeamName( uTeam ) 
            end 
            setAccountData ( uAccount, 'team', uTeam ) 
        end 
    end 
end  
addEventHandler ( 'onPlayerQuit', root,     fSaveManager ) 
addEventHandler ( 'onPlayerLogin', root,    fSaveManager ) 

Ask questions if you not understand something.

Edited by Guest
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...