• 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!

Auto team balance.

Bogart

...has super panda powers
Senator
Joined
Jun 21, 2009
Messages
8,007
Solutions
27
Reaction score
566
Location
Panda Land!
Hello, im requesting an auto team balance like this one
if you guys ask why i dont use Slaktaren's one, its coz it doesn't work for me.
it doesnt change the addon colors.and it doesn't change me the temple, i always re spawn on the same temple even if i log 10 characters
 
humm, only team balance? Like when guy log he go team 1 , with blue outfit , then other one goes to team 2 with red outfit?
 
Not everything needed but some of it.
This will just teleport a player to team1Temple if team2 have more players than team1 and reverse

Code:
local config = {
    team1Name = "Red team",
    team2Name = "Blue team",
    team1 = 1000, -- Storage
    team2 = 1001, -- Storage
    team1Temple = {x = 123, y = 123, z = 7},
    team2Temple = {x = 123, y = 123, z = 7},
    }

function onLogin(cid)
    if getGlobalStorageValue(config.team1) > getGlobalStorageValue(config.team2) then
        doTeleportThing(cid, config.team2Temple)
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team2Name .. "!")
        setGlobalStorageValue(config.team2, getGlobalStorageValue(config.team2)+1)
    else
        doTeleportThing(cid, config.team1Temple)
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team1Name .. "!")
        setGlobalStorageValue(config.team1, getGlobalStorageValue(config.team1)+1)
    end
return true
end
 
Last edited:
There should be a logout one too, the remove storage on logging out from the team storage, cause maybe like 3 logs out this means the number indicated by the team storage isn't correct. :p
 
i have 3 cities.
the map changes every 10 minutes, so i should use this
Code:
        [1] = {mapName = "Thais", redTemple = {x = 32369, y = 32241, z = 7}, blueTemple = {x = 32335, y = 32199, z = 7}},
        [2] = {mapName = "Carlin", redTemple = {x = 32360, y = 31782, z = 7}, blueTemple = {x = 32387, y = 31821, z = 6}},
        [3] = {mapName = "Venore", redTemple = {x = 32451, y = 32464, z = 7}, blueTemple = {x = 32449, y = 32410, z = 6}},
instead of this
Code:
    team1Temple = {x = 123, y = 123, z = 7}, {x = 123, y = 123, z = 7}, {x = 123, y = 123, z = 7},
    team2Temple = {x = 123, y = 123, z = 7}, {x = 123, y = 123, z = 7}, {x = 123, y = 123, z = 7},
?
 
Last edited:
ye, i suppose when u change map you give a globalstorage the id of the map so it wouldb elike that
LUA:
local config = {
    team1Name = "Red team",
    team2Name = "Blue team",
    team1 = 1000, -- Storage
    team2 = 1001, -- Storage
    }
local towns = 	{
					[1] = {mapName = "Thais", redTemple = {x = 32369, y = 32241, z = 7}, blueTemple = {x = 32335, y = 32199, z = 7}},
					[2] = {mapName = "Carlin", redTemple = {x = 32360, y = 31782, z = 7}, blueTemple = {x = 32387, y = 31821, z = 6}},
					[3] = {mapName = "Venore", redTemple = {x = 32451, y = 32464, z = 7}, blueTemple = {x = 32449, y = 32410, z = 6}},
				}
function onLogin(cid)
	local current = towns[getStorage(townid)] -- this should be the storage which store the curren map id
	
    if getGlobalStorageValue(config.team1) > getGlobalStorageValue(config.team2) then
        doTeleportThing(cid, current.redTemple)
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team2Name .. "!")
        setGlobalStorageValue(config.team2, getGlobalStorageValue(config.team2)+1)
    else
        doTeleportThing(cid, current.blueTemple)
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team1Name .. "!")
        setGlobalStorageValue(config.team1, getGlobalStorageValue(config.team1)+1)
    end
return true
end
 
ye, i suppose when u change map you give a globalstorage the id of the map so it wouldb elike that
LUA:
local config = {
    team1Name = "Red team",
    team2Name = "Blue team",
    team1 = 1000, -- Storage
    team2 = 1001, -- Storage
    }
local towns = 	{
					[1] = {mapName = "Thais", redTemple = {x = 32369, y = 32241, z = 7}, blueTemple = {x = 32335, y = 32199, z = 7}},
					[2] = {mapName = "Carlin", redTemple = {x = 32360, y = 31782, z = 7}, blueTemple = {x = 32387, y = 31821, z = 6}},
					[3] = {mapName = "Venore", redTemple = {x = 32451, y = 32464, z = 7}, blueTemple = {x = 32449, y = 32410, z = 6}},
				}
function onLogin(cid)
	local current = towns[getStorage(townid)] -- this should be the storage which store the curren map id
	
    if getGlobalStorageValue(config.team1) > getGlobalStorageValue(config.team2) then
        doTeleportThing(cid, current.redTemple)
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team2Name .. "!")
        setGlobalStorageValue(config.team2, getGlobalStorageValue(config.team2)+1)
    else
        doTeleportThing(cid, current.blueTemple)
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team1Name .. "!")
        setGlobalStorageValue(config.team1, getGlobalStorageValue(config.team1)+1)
    end
return true
end

well, my current script is like this
LUA:
local config = {
    team1Name = "Blue Bangbabies",
    team2Name = "Red Rageboys",
    team1 = 1002, -- Storage
    team2 = 1003, -- Storage
    }

local conditionBlue = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
        setConditionParam(conditionRed, CONDITION_PARAM_TICKS, 1800 * 1000)
        addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})

local towns = {
					[1] = {mapName = "Thais", redTemple = {x = 32369, y = 32241, z = 7}, blueTemple = {x = 32335, y = 32199, z = 7}},
					[2] = {mapName = "Carlin", redTemple = {x = 32360, y = 31782, z = 7}, blueTemple = {x = 32387, y = 31821, z = 6}},
					[3] = {mapName = "Venore", redTemple = {x = 32451, y = 32464, z = 7}, blueTemple = {x = 32449, y = 32410, z = 6}},
				}


function onLogin(cid)
	local current = towns[getGlobalStorageValue(100)] 

setPlayerStorageValue(cid, 1002, 0)
setPlayerStorageValue(cid, 1003, 0)
        if getGlobalStorageValue(1000) > getGlobalStorageValue(1001) then
            setPlayerStorageValue(cid, 1003, 1)
            doAddCondition(cid, conditionBlue)
            doTeleportThing(cid, current.blueTemple)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            setGlobalStorageValue(1001, getGlobalStorageValue(1001)+1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team1Name .. "!")          
        else
            setPlayerStorageValue(cid, 1002, 1)
            doAddCondition(cid, conditionRed)
            doTeleportThing(cid, current.redTemple)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            setGlobalStorageValue(1000, getGlobalStorageValue(1000)+1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been sent to play for the " .. config.team2Name .. "!")
        end
return true
end

and it doesn't work.
 
Last edited:
You need to make a script on startUp that sets the globalstorage 100 to 1 and 1000, 1001 to 0.
Also a globalevent that will change the globalstorage 100 to +1 every X minute and also teleporthing all players to the next town. Got no time to help you right now, going to school.
 
You need to make a script on startUp that sets the globalstorage 100 to 1 and 1000, 1001 to 0.
Also a globalevent that will change the globalstorage 100 to +1 every X minute and also teleporthing all players to the next town. Got no time to help you right now, going to school.
LUA:
function onThink(interval, lastExecution, thinkInterval)
    local maps = {
        [1] = {mapName = "Thais", redTemple = {x = 32369, y = 32241, z = 7}, blueTemple = {x = 32335, y = 32199, z = 7}},
        [2] = {mapName = "Carlin", redTemple = {x = 32360, y = 31782, z = 7}, blueTemple = {x = 32387, y = 31821, z = 6}},
        [3] = {mapName = "Venore", redTemple = {x = 32451, y = 32464, z = 7}, blueTemple = {x = 32449, y = 32410, z = 6}},
    }
    
    local teams = {
        blueName = "Blue Bangbabies",
        redName = "Red Rageboys",
        blueScore = 101,
        redScore = 102,
        bluePlayerScore = 1004,
        redPlayerScore = 1006,
    }
    
    local map = maps[getGlobalStorageValue(100)]

    if getGlobalStorageValue(100) <= 0 then
        setGlobalStorageValue(100, 1)
    elseif getGlobalStorageValue(100) >= math.max(1, #maps) then
        setGlobalStorageValue(100, 1)
    elseif getGlobalStorageValue(100) >= 1 then
        setGlobalStorageValue(100, getGlobalStorageValue(100)+1)
    end
    
    if map then
        for _, cid in ipairs(getPlayersOnline()) do
            if getPlayerStorageValue(cid, 1002) == 1 then
                doTeleportThing(cid, map.blueTemple)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            elseif getPlayerStorageValue(cid, 1003) == 1 then
                doTeleportThing(cid, map.redTemple)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
            end
            if getGlobalStorageValue(teams.blueScore) > getGlobalStorageValue(teams.redScore) then
                str = "\n\nThe " .. teams.blueName .. "  won!\n\nScores:\n" .. teams.blueName .. " " ..  getGlobalStorageValue(blueScore) .. " - " ..  getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
            elseif getGlobalStorageValue(teams.redScore) > getGlobalStorageValue(teams.blueScore) then
                str = "\n\nThe " .. teams.redName .. "  won!\n\nScores:\n" .. teams.blueName .. " " ..  getGlobalStorageValue(blueScore) .. " - " ..  getGlobalStorageValue(redScore) .. " " .. teams.redName .. "."
            end
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Map has  been changed to " .. map.mapName .. "! Next map in 30 minutes!" .. str)
        end
        setGlobalStorageValue(teams.blueScore, 0)
        setGlobalStorageValue(teams.redScore, 0)
    end
return true
end
?
 
I can give u an advanced one pm me.

the script u gave me >>1150936 doesn't work.
it gives me this error..
qiE0CcjlJo.png
 
As i said in script the town id should be the variable that store the current town id and the id should also be in relevant with the arrangement of the

town array keys so the values would be right:

map changed , town id storage variable holder should be changed to the new town id and that id will be the representer to the array key where the

values would be extracted from it.
 
As i said in script the town id should be the variable that store the current town id and the id should also be in relevant with the arrangement of the

town array keys so the values would be right:

map changed , town id storage variable holder should be changed to the new town id and that id will be the representer to the array key where the

values would be extracted from it.

blah, I did edit, tho, now I'm using a mod to change the map, and a script to set addons/team.

BUT there is one big problem, i can attack my own team.
I have this script (made by Slaktaren)
and it doesn't work.

LUA:
function onCombat(cid, target)
    if isPlayer(attacker) and isPlayer(target) then
        if getPlayerStorageValue(attacker, 1003) == 1 and getPlayerStorageValue(target, 1003) == 1 then
            return doPlayerSendCancel(cid, "You may not attack your teammates.") and false
        elseif getPlayerStorageValue(attacker, 1002) == 1 and getPlayerStorageValue(target, 1002) == 1 then
            return doPlayerSendCancel(cid, "You may not attack your teammates.") and false
        end
    end
    return true
end
 
Back
Top