• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua TFS 1.0 balance teams

narko

vertrauenswürdig ~
Joined
Oct 19, 2008
Messages
1,317
Solutions
2
Reaction score
132
Location
Unknown
I have been adapting some scripts from 0.4 to 1.0 and never have any problem but when I was trying to adapt Rush Event i've got some issues here there are:

The problem is when the event starts everybody are from the Red Team and starts at the same position
(No console bugs btw)

This setStorage function supposes to set a storage or team to the player depending on the Players Count
Code:
setPlayerStorageValue(cid, configRushEvent.storages.player, doCountPlayersRushEvent()[3] >= doCountPlayersRushEvent()[2] and 'blue' or 'red')

function:
Code:
function doCountPlayersRushEvent()
                local x, blue, red = 0,0,0
                for _, cid in ipairs(Game.getPlayers()) do
                    local p = tostring(getPlayerStorageValue(cid, configRushEvent.storages.player))
                    if p ~= '' then
                        if p ~= 'blue' then
                            red = red + 1
                        else
                            blue = blue + 1
                        end
                        x = x + 1
                    end
                end
                return {x, blue, red}
            end

The whole RushLib.lua:
http://pastebin.com/u22Ja0dz
 
In TFS 1+ storage values may only be numbers, so you can't set the storage to 'red' or 'blue'. Any string seems to result in the value being set to 0.
You're right, I didn't remember that but how can I make it work properly?
 
You're right, I didn't remember that but how can I make it work properly?
I would use variables containing numbers instead of 'blue' and 'red'. Something like this:
Code:
local BLUE, RED = 1, 2

setPlayerStorageValue(cid, configRushEvent.storages.player, doCountPlayersRushEvent()[3] >= doCountPlayersRushEvent()[2] and BLUE or RED)

function doCountPlayersRushEvent()
    local x, blue, red = 0,0,0
    for _, cid in ipairs(Game.getPlayers()) do
        local p = getPlayerStorageValue(cid, configRushEvent.storages.player)
        if p ~= -1 then
            if p ~= BLUE then
                red = red + 1
            else
                blue = blue + 1
            end
            x = x + 1
        end
    end
    return {x, blue, red}
end
 
H2qFuUxlW.png

Still bugged everyone's on the red team.
 
Back
Top