Jump to content

Save team


Memory

Recommended Posts

Hi,

I have this code

function setTeam() 
local account = getPlayerAccount(source) -- gets players account 
local team = getAccountData (account, "team") -- gets players team 
if (team) and getTeamFromName(team) then 
      setPlayerTeam(source, getTeamFromName(team)) -- sets players team 
     end 
end 
addEventHandler("onPlayerLogin",root,setTeam) -- sets players team on login 
  
function save() 
 local team = getPlayerTeam(source) -- Gets the players team 
local account = getPlayerAccount(source) 
if (team) and not isGuestAccount(account) then -- Checks to see if the player is a guest or not 
setAccountData(account, "team", getTeamName(team)) --saves team 
 end 
    end 
addEventHandler("onPlayerQuit", getRootElement(), save) 

But if remove player, he after reconnect again in team, problem with the save.

Function for to removed players.

function unassignTeam ( source, commandName ) 
local account = getPlayerAccount(source) 
local team = getAccountData (account, "team") -- Check if the player is on a team 
  if team then                          -- this player is on a team, so we can remove them from it 
    setPlayerTeam ( source, nil )    -- remove the player from the current team 
  end 
end 
addCommandHandler ( "takeawaymyteam", unassignTeam ) 

I try use this, but doesn't work.

function delete( source, commandName ) 
 local team = getPlayerTeam(source)  
local account = getPlayerAccount(source) 
if (team) and not isGuestAccount(account) then  
setAccountData(account, "team", nil) 
 end 
    end 
addCommandHandler ( "remove", delete ) 

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