All pastes #90562 Raw Edit

Unnamed

public text v1 · immutable
#90562 ·published 2006-07-17 20:13 UTC
rendered paste body
--Who's on what team?
VIP = {}
ADMIN = {"STEAM_0:0:9973804"}
MASTER = {}
MINGE = {}
 
--TeamNames
_ServerCommand("gm_sv_teamplay 1\n")
_TeamSetName(5,"Admins")
_TeamSetName(3,"VIPs")
_TeamSetName(4,"Master Builders")
_TeamSetName(2,"Users")
_TeamSetName(0,"MingeBags")
_ServerCommand("gm_sv_setrules\n") 
 
--Admin?
function isAdmin(userid)
    for i,v in ipairs(ADMIN) do
        if (userid) and (userid > 0) then
            if (string.lower(v) == string.lower(_PlayerInfo(userid,"networkid"))) then
                return true;
            end
        end
    end
    return false;
end
 
--Team Changes, for concommands
function addTeam(userid, args)
    if (isAdmin(userid)) then
        local arg=explode(" ", args)
        local id = arg[1]
        local team=arg[2]
        if string.lower(team) == "admin" then
            _PlayerChangeTeam(id,5)
			table.insert(ADMIN, _PlayerInfo(id,"networkid"))
        elseif string.lower(team) == "vip" then
            _PlayerChangeTeam(id,3)
			table.insert(VIP, _PlayerInfo(id,"networkid"))
        elseif string.lower(team) == "master" then
            _PlayerChangeTeam(id,4)
			table.insert(MASTER, _PlayerInfo(id,"networkid"))
        elseif string.lower(team) == "minge" then
            _PlayerChangeTeam(id,0)
			table.insert(MINGE, _PlayerInfo(id,"networkid"))
        elseif string.lower(team) == "clear" then
            _PlayerChangeTeam(id,2)
        end
    end
end
 
 
--Check Admins
function isTeamAdmin(userid)
    for i,v in ipairs(ADMIN) do
        if (userid) and (userid > 0) then
            if (string.lower(v) == string.lower(_PlayerInfo(userid,"networkid"))) then
                _PlayerChangeTeam(userid,TEAM_RED)
            end
        end
    end
    isTeamVIP(userid)
end
 
--Check VIPs
function isTeamVIP(userid)
    for i,v in ipairs(VIP) do
        if (userid) and (userid > 0) then
            if (string.lower(v) == string.lower(_PlayerInfo(userid,"networkid"))) then
                _PlayerChangeTeam(userid,TEAM_YELLOW)
            end
        end
    end
    isTeamMasters(userid)
end
 
--Check Master Builders
function isTeamMasters(userid)
    for i,v in ipairs(MASTER) do
        if (userid) and (userid > 0) then
            if (string.lower(v) == string.lower(_PlayerInfo(userid,"networkid"))) then
                _PlayerChangeTeam(userid,TEAM_GREEN)
            end
        end
    end
    isTeamMinges(userid)
end
 
--Check MingeBags
function isTeamMinges(userid)
    for i,v in ipairs(MINGE) do
        if (userid) and (userid > 0) then
            if (string.lower(v) == string.lower(_PlayerInfo(userid,"networkid"))) then
                _PlayerChangeTeam(userid,TEAM_UNASSIGNED)
            end
        end
    end
    _PlayerChangeTeam(userid,TEAM_BLUE)
end
 
function explode( d, p )
    t = {}
    local ll = 0
    while true do
        local l = string.find( p, d, ll + 1, true )
        if l ~= nil then
            table.insert( t, string.sub( p, ll, l - 1 ) )
            ll = l + 1
        else
            table.insert( t, string.sub( p, ll ) )
            break
        end
    end
    return t
end
 
HookEvent("eventPlayerSpawn", isTeamAdmin)
CONCOMMAND("addTeam",addTeam)