Jump to content

save team


BorderLine

Recommended Posts

Posted

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) 
  

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted (edited)

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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

Perfect :)

can delete script, or thieves will steal

thanks a loot bro :)

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted
Perfect :)

can delete script, or thieves will steal

thanks a loot bro :)

u can edit your post ^_^

357ac0078264.jpg

- Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]

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