-- SERVER
function setTeam( player, team ) -- Use this function to change players team.
local acc = getPlayerAccount( player )
local log = isGuestAccount( acc )
if ( player and team ) and not ( log ) then
local _team = getTeamFromName( team )
if ( _team ) then
setPlayerTeam( player, _team )
setAccountData( acc, "team", _team )
outputChatBox( "Your team has been changed to: " .. team, player, 255, 0, 0 )
end
end
end
function assignTeam( _, a )
if ( a ) then
local team = getAccountData( a, "team" ) or nil
if ( team ) then
setPlayerTeam( source, team )
end
end
end
addEventHandler( "onPlayerLogin", root, assignTeam )
function deathTeam()
local acc = getPlayerAccount( source )
local log = isGuestAccount( acc )
if not ( log ) then
local team = getAccountData( acc, "team" )
setPlayerTeam( source, team )
end
end
addEventHandler( "onPlayerWasted", root, deathTeam )