• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Feature Auto Team Balance

Heres the functions;


Code:
function getSmallestTeam()
    local ret = 0
    if teamCount.get(1) > teamCount.get(2) then
        ret = 2
    else
        ret = 1
    end
    return ret
end

playerTeam = {
    get = function(cid)
        if getPlayerStorageValue(cid, PLAYER_STORAGE.TEAM_INFO) == GLOBAL_STORAGE.TEAMS[1] then
            return 1
        else
            return 2
        end
    end,

    set = function(cid, id)
        return setPlayerStorageValue(cid, PLAYER_STORAGE.TEAM_INFO, id)
    end
}

and

Code:
doPlayerSetTeam = {
    login = function (cid)
--        print("getSmallestTeam(): "..getSmallestTeam())
        if  getSmallestTeam() == FALSE then
            return FALSE
        end

        if getPlayerAccess(cid) < 3 then
            local team = getSmallestTeam()
            if team > 0 then
                local teamColor = TEAM_COLOR[team]
                playerTeam.set(cid, GLOBAL_STORAGE.TEAMS[team])
                doCreatureChangeOutfit(cid, {lookType = getCreatureOutfit(cid).lookType, lookHead = teamColor, lookBody = teamColor, lookLegs = teamColor, lookFeet = teamColor, lookTypeEx = color, lookAddons = 3})
                local temple = TEMPLES[playerTeam.get(cid)][areaId.get()]
                doPlayerSetTown(cid, temple)
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
                teamCount.add(team, 1)
                doPlayerAddSoul(cid, -getPlayerSoul(cid))
                doSendMagicEffect(getCreaturePosition(cid), 37)
            end
        end

Code:
logout = function (cid)
        if getPlayerAccess(cid) < 3 then
            local team = playerTeam.get(cid)
--            print("getPlayerTeam(cid): "..team)
            if team > 0 then
                teamCount.rem(team, 1)
                playerTeam.set(cid, FALSE)
--                print("Team 1 count: "..teamCount.get(1).."\nTeam 2 count: "..teamCount.get(2))
            end
        end
        return TRUE
    end

and then

Code:
function onLogin(cid)
    return doPlayerSetTeam.login(cid)
end

function onLogout(cid)
    return doPlayerSetTeam.logout(cid)
end
Someone could explain where i can put this codes? (i know creaturescripts but all 4 codes there?)
This is a auto balanced of accounts?
for example: "we have 2 teams 1/1 and 2/2 everyone logs at 1/1 and the script sends you to the team with less people" its right?
 
Back
Top