Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: freestyler on June 05, 2011, 06:24:29 pm

Title: cube v1.6.1 - CTF/INF Ultimate Balancer
Post by: freestyler on June 05, 2011, 06:24:29 pm
(http://oko.im/script/cube/cube.png) (http://oko.im/script/dl.php?s=cube)



script name: cube, or ctf/inf ultimate balancer
short description: pretty complex team balancer + a few teams-related things
original author: fri (http://oko.im/scripts)
core version: 2.7.6



longer description:
Unlike most balancers you've seen, cube balances teams based on the difference in number of players AND team scores.

Regular balancers check whether the difference in number of players is greater than 2, and moves a random player to the opposite team if it is. cube doesn't stop at such a plain check - this is where team scores, swaps and player choosing methods go into play.

features list:
- works with CTF and Infiltration gamemodes
- uses seven methods of choosing the player to be moved, including "least caps", "worst k/d ratio", and more
- avoids flag carriers not to ruin the game
- automatically puts new players into weaker team
- gives some "immunity time" to moved players, so they won't be moved again too soon
- disables itself in the last 10 seconds of a map (to avoid "wrong map version" problems)
- supports some well-known triggers such as !alpha, !spec (+aliases), and, of course, !balance (!bal, teams, ...)
- "team-changing" triggers can be disabled or limited to X uses per player per map
- locks the recenly moved players in their new teams, so they won't fight the system and go back
- in case of a big unbalance, admins can shuffle the teams using one simple command (/mix)
- admins can swap the teams of two or all players at once
- you can exclude some people from the balance by putting their nicknames or HWIDs on the exclusion list
- can keep teams' scores even if all players left (optional)
- (dev) the code is commented and thus fairly easy to understand

Uses Explode function by CurryWurst and Curt.

commands list:
all players:
!balance, teams - trigger balance
/bal - trigger balance without disclosing who triggered it
!alpha, !1 - go to alpha team
!bravo, !2 - go to bravo team
!spec, !5 - go to spectator team
!join, !j - join weaker team (spec only)
(plus a few aliases of all these triggers/commands)
additional commands (admins only):
/swap ID1 ID2 - swap teams of specified players
/swap all - swap everyone
/mix or /shuffle - shuffle teams
/hwid ID - show hardware ID of specified player
/exclude ID - exclude specified player from balancing
/kickbots, /kickspec - kick all bots / spectators
/cubeinfo - shows current info about version, balances, config, etc.

You can test cube on Bonecrusher's servers, e.g here: 80.72.37.10:23073 (server 2.7.6, cube v1.5).

If you have any suggestions, please post them here. Have fun!



(http://oko.im/script/dl.png) (http://oko.im/script/dl.php?s=cube)



Changes 1.6 -> 1.6.1:
fixed: a terrible bug which rendered /exclude command useless (it excluded the user, not the specified ID)
modified: simplified a bit of logic

Changes 1.5 -> 1.6:
added: /exclude ID command for admins, to exclude players for the duration of their visit on the server
added: /cubeinfo command for admins - shows current cube info (version, config, number of balances)
added: a message that shows up if cube could not choose any player to move; you should not see it anyway
added: public messages show current balance status, e.g. 'Teams balanced. [3v2 4:7]'
added: option to make swap ignore the number of flag captures when choosing players
fixed: a bug that caused spectators to be moved to alpha team when /swap all was used
modified: reworked the whole config to make it even clearer
modified: some default values in config
modified: bots are now ignored by cube
modified: excluding now makes people completely immune to cube's effects
modified: colors of some messages
modified: /hwid ID command also works with nicknames

full changelog is in the readme.txt file
Title: Re: cube v0.4b (updated)
Post by: Bonecrusher on June 08, 2011, 08:24:59 pm
best balance script there is
Title: Re: cube v0.4b (updated)
Post by: L[0ne]R on June 08, 2011, 10:19:58 pm
sounds promising, hoping that most servers will switch to it.

As for the name:
Ctf Ultimate BalancEr?
Ctf Ultimate Balance Enhancer?
Title: Re: cube v0.5b
Post by: freestyler on June 11, 2011, 06:43:06 pm
Version 0.5b is now available. (http://tehoko.info/script/dl.php?s=cube)


Changes 0.5 -> 0.5b:
added: fifth method - choosing player with no caps and worst k/d ratio. if it fails - least caps; it's the default method now
modified: balance won't trigger in the last 10 seconds of a map to avoid wrong map version problems
modified: the !alpha-like triggers won't work in the last two seconds of a map

I'm still open to suggestions and feature requests.
Title: Re: cube v0.5b
Post by: Furai on June 11, 2011, 07:05:11 pm
Quote
5v5, 8:0 -> one player from Alpha moved to Bravo, because Alpha is definitely too strong
In situations like this I'd rather see swapping best player from alpha with worst player from bravo. I dislike any situations where there's difference between teams greater than 2. In my opinion 6vs4 is unbalanced and it's like your Cube was flawed but it's for sure superior.
Title: Re: cube v0.6
Post by: freestyler on June 12, 2011, 12:42:25 pm
Version 0.6 is out. (http://tehoko.info/script/dl.php?s=cube)


Changes 0.5b -> 0.6:
added: optional (and enabled by default) method of dealing with 5v5 situations: swap best and weakest player's teams instead of moving one causing 4v6 (idea by Wookash)
added: another method - fewest kills and no caps (new default)
modified: swap is now a separate procedure - swap(caller, id1, id2);
Title: Re: cube v0.6
Post by: demoniac93 on June 12, 2011, 03:13:35 pm
I love you man. No homo.
Now all you need to do is make one like this for Inf, and I will forever be in your debt.
Title: Re: cube v0.6
Post by: PKS|Shooter on June 14, 2011, 08:17:10 am
Code: [Select]
(15:13:52)  [*] [Error] cube -> (OnPlayerSpeak): Out of Global Vars range
(15:13:52)  [*] [Error] cube -> (AppOnIdle): Access violation at address 080A0B43, accessing address 0000010D
(15:13:53)  [*] [Error] cube -> (OnPlayerSpeak): Access violation at address 080A0BCC, accessing address 0000010D
(15:13:53)  [*] [Error] cube -> (AppOnIdle): Access violation at address 080A0BCC, accessing address 00000120

uncool :<
Title: Re: cube v0.6
Post by: freestyler on June 14, 2011, 01:01:08 pm
When reporting bugs please add info about number of players in each team, team scores and config (if not default). This way I can reproduce it and fix the issue.

I'm working on 0.7 with automatic Inf support, but it needs a lot of testing and time, which I do not have.
Title: Re: cube v0.6
Post by: dnmr on June 14, 2011, 02:29:38 pm
Code: [Select]
(15:13:52)  [*] [Error] cube -> (OnPlayerSpeak): Out of Global Vars range
(15:13:52)  [*] [Error] cube -> (AppOnIdle): Access violation at address 080A0B43, accessing address 0000010D
(15:13:53)  [*] [Error] cube -> (OnPlayerSpeak): Access violation at address 080A0BCC, accessing address 0000010D
(15:13:53)  [*] [Error] cube -> (AppOnIdle): Access violation at address 080A0BCC, accessing address 00000120

uncool :<

linux?
Title: Re: cube v0.6
Post by: Mighty on June 14, 2011, 03:30:05 pm
Quote from: brad cZe
One thing i'd change. After map changes, if you got balanced you get kicked by server
Title: Re: cube v0.7 (CTF+INF)
Post by: freestyler on June 14, 2011, 05:44:04 pm
Quote from: brad cZe
One thing i'd change. After map changes, if you got balanced you get kicked by server
This was fixed in 0.5b, where balance doesn't trigger in the last 10 seconds of a map. I suggest downloading newer version.


Version 0.7 is out. (yay, Infiltration!) (http://tehoko.info/script/dl.php?s=cube)


Changes 0.6 -> 0.7:
added: detect Infiltration / Capture The Flag and use respective Weight and MinDiff
added: 'teams?', 'balance?' and 'bal?' triggers
modified: can't swap spectators now
modified: "Teams balanced." won't show up after automatic swap anymore
modified: fixed bug with not balancing 4v6 when one team is stronger and SwapOnUnbal is true
modified: now balance autotriggers if (Interval*n) minutes passed since last balance
 (used to trigger every <Interval> minutes, no matter if other (requested) balances occured or not)
modified: if the last balance was swap then multiply the interval by 1.5 (to avoid another swap too soon after last one)
modified: player can't use !teams until 15 seconds since last successful balance pass
Title: Re: cube v0.7 (CTF+INF)
Post by: L[0ne]R on June 14, 2011, 07:00:47 pm
I'd say "Add TDM support too" but nobody plays 4-team TDM anyway. <_<
Title: Re: cube v0.7 (CTF+INF)
Post by: demoniac93 on June 14, 2011, 07:19:40 pm
You are now officially a hero.
Also, as Loner said, this would rock with TDM, except nobody plays it anymore, but I think it would come in handy for the soldat forums meet-ups.
Title: Re: cube v0.7 (CTF+INF)
Post by: freestyler on June 15, 2011, 02:14:25 am
As you said, nobody plays TDM. Even if some players do, there's not that many people, so the balance is not needed. If there were servers filled with 20 people playing TDM then I would reconsider it.

I also don't know how it would calculate the balance. Standard deviation or what?
Title: Re: cube v0.7 (CTF+INF)
Post by: PKS|Shooter on June 16, 2011, 06:25:25 am
Code: [Select]
(15:13:52)  [*] [Error] cube -> (OnPlayerSpeak): Out of Global Vars range
(15:13:52)  [*] [Error] cube -> (AppOnIdle): Access violation at address 080A0B43, accessing address 0000010D
(15:13:53)  [*] [Error] cube -> (OnPlayerSpeak): Access violation at address 080A0BCC, accessing address 0000010D
(15:13:53)  [*] [Error] cube -> (AppOnIdle): Access violation at address 080A0BCC, accessing address 00000120

uncool :<

linux?
yes debian 64x soldat mode : Realistic survival CTF
Title: Re: cube v0.7 (CTF+INF)
Post by: Falcon` on June 16, 2011, 08:26:38 am
welcome to linux<->soldatserver cooperation hell. Make yourself comfortable.
Title: Re: cube v0.8
Post by: freestyler on June 19, 2011, 01:22:51 pm
Grab the new, shiny v0.8 now! (http://tehoko.info/script/dl.php?s=cube)


Changes 0.7 -> 0.8:
added: /mix (or /shuffle) admin-only command to shuffle the teams
added: cube recompiles itself after /gamemode x
added: aliases for /gamemode x. no need to remember their numbers anymore
added: info about number of players and scores, shown with every balance (admin console only)
added: !a, !b, !s triggers (changing team)
modified: don't balance when one team has won the round and map hasn't changed yet (in addition to timeleft = 0)
modified: final fix for 4v6, no weird balance should happen anymore (on default config at least)
removed: IncludeFlags is hardcoded now (not optional anymore). if it was set to false, cube was no different from any other balancer. most of cube's code used team scores with no regard to this option anyway
Title: Re: cube v0.8
Post by: Beowulf Agate on June 19, 2011, 03:01:09 pm
theres still v0.7 at that shiny v0.8's link :)

not anymore :F
Title: Re: cube v0.9
Post by: freestyler on June 24, 2011, 04:52:42 pm
v0.9 is out. We're close to the finale! (http://tehoko.info/script/dl.php?s=cube)


Changes 0.8 -> 0.9:
added: limiting number of swaps per map (default: 2). if it's reached, teams are considered balanced (in situations where swap would normally occur, of course)
modified: less /setteam-ing for shuffle - don't move player if he's already in his 'destined team'
modified: shuffle locks players in teams for LockTime*60 seconds
modified: little changes in messages
modified: player choosing method defaults to 1 again (random player). it's more fun this way

Please post what features would you like to see in this script. I want to make v1.0 as useful as possible.
Title: Re: cube v0.9
Post by: Furai on June 24, 2011, 05:23:15 pm
If you really would like to add something then I was thinking of some team randomiser - command only for admins. Sometimes teams are so unballanced that nothing can be really done or people want just to shuffle teams. I'd really like to see a feature allowing you to shuffle teams keeping server ballanced.
Title: Re: cube v0.9
Post by: freestyler on June 25, 2011, 04:08:36 am
um

Quote
Changes 0.7 -> 0.8:
added: /mix (or /shuffle) admin-only command to shuffle the teams
Quote
And in case of a big unbalance that lasts for a longer period of time, you can shuffle the teams (put the players, from most kills to fewest kills, to alternating teams)
Title: Re: cube v0.9
Post by: Furai on June 25, 2011, 05:00:30 am
um

Quote
Changes 0.7 -> 0.8:
added: /mix (or /shuffle) admin-only command to shuffle the teams
Quote
And in case of a big unbalance that lasts for a longer period of time, you can shuffle the teams (put the players, from most kills to fewest kills, to alternating teams)

Damn, and I thought I read the first post carefully enough...my bad. Sorry.
Title: Re: cube v0.9
Post by: PKS|Shooter on July 21, 2011, 03:48:08 pm
Quote
(22:37:20) [Error] cube -> (OnPlayerCommand): Type Mismatch
(22:37:20) Connection to the server lost

:o
Title: cube v1.2b
Post by: freestyler on October 27, 2011, 05:41:27 pm
cube v1.2b is out! (http://tehoko.info/script/dl.php?s=cube)


Changes 1.1b -> 1.2:
added: '/kickbots' and '/kickspec' commands to kick all bots/spectators from the server
added: option to keep team's score even if everyone from that team left (Soldat itself clears the score if a team is empty). said option (named KeepTeamScore) is disabled by default
added: some checks for incorrect values of Weight and MinDiff
added: more '!balance' aliases
modified: fixed incorrect balancing when Weight and MinDiff are small and there are few players (e.g. 3v0, 0:5, W=2, MD=2 - cube thought it was balanced) (reported by Vampir)
modified: in-game admins can now use '/bal' command even if they're in the spectator team
modified: enriched readme.txt and divided config in cube.pas into categories to make it neater


Changes 1.2 -> 1.2b:
modified: fixed double writeconsole message when an admin uses /bal
modified: /bal now properly returns error messages when used by remote admin
modified: automatic balance won't trigger right after map change now (at least 5 seconds must pass first)
Title: Re: cube v1.2b
Post by: Mighty on November 06, 2011, 03:58:42 pm
Code: [Select]
21:57:07 [Fromage] !Bal
►            > Checking team balance (request by player)... [6v2 7:1]
►            > Performing another balance check... [5v3 7:1]
►            > Performing another balance check... [4v4 7:1]
►            > Performing another balance check... [3v5 7:1]
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►            > Everyone in Bravo Team is immune to balance. Using alternative method.
►            > Performing another balance check... [4v4 7:1]
►            > Everyone in Alpha Team is immune to balance. Using alternative method.
►            > Performing another balance check... [3v5 7:1]
►   21:57:08 > Teams balanced.
►            [.huhu// Xar0ne] huhu
Title: Re: cube v1.2b
Post by: freestyler on November 06, 2011, 05:18:33 pm
Would be nice if you specified what is your config (Weight and MinDiff), because without those I can't replicate this. On default values it works properly (balances to 4v4).
Title: Re: cube v1.2b
Post by: Mighty on November 07, 2011, 02:20:43 am
Quote
Weight_CTF  = 4;          // don't set it higher than MinDiff
MinDiff_CTF = 5;

:)
Title: Re: cube v1.2b
Post by: freestyler on November 07, 2011, 02:48:18 am
I can't replicate this - I checked a few times in identical situation (6v2, 7:1) and the script balanced it to 4v4 in two iterations. If SwapOnUnbal is false then it balances to 3v5. Which version are you using?

Also, links revived - my host magically erased contents of dl.php.
Title: Re: cube v1.2b
Post by: Mighty on November 07, 2011, 03:32:40 pm
It's 1.1

Anyway, just wanted you to know something like that occured, it's not really something that makes me mad or whatever. Happened once till now.
Title: Re: cube v1.5 - major update
Post by: freestyler on November 25, 2011, 01:07:36 pm
After a lot of tests, re-tests and re-re-tests I present you with the newest version, which is now so feature-rich it needed a significant version number change.

cube v1.5 - get it while it's hot! (http://oko.im/script/dl.php?s=cube)

Changes 1.2b -> 1.5:
removed: hardcoded four config values: Balance3v1, SwapOnUnbal, Weight and MinDiff. cube started to grow dangerously big while struggling with compatibility issues. Some new features wouldn't work correctly on non-default config anyway.
added: !join trigger for spectators - joins weaker team (one with fewer players and points)
added: new players are now forced to join weaker team (except they're on the exclusion list)
added: iteration limiter to only balance as many times as it's needed
added: a few more aliases to already existing triggers
modified: balance procedure rewritten and simplified a bit; main stress moved to another function (CalcWeakerTeam)
modified: recently moved (locked) players get unlocked if they're trying to join weaker team (this one was annoying: you couldn't fix unbalanced teams yourself, because cube moved you back)
modified: players that are on the exclusion list have more rights: they can switch team and use team-change triggers without limits
modified: swap doesn't touch players that have capped the flag (except everyone did - in such cases it chooses one who capped fewest times)
modified: all players' lock timers are reset before manual /shuffle or /mix
modified: AppOnIdle is now compatible with Falcon's modified server binary (60 Hz)
modified: improved performance a bit and fixed some omissions that could cause bugs
Title: Re: cube v1.5 - major update
Post by: homerofgods on November 25, 2011, 04:22:52 pm
I will defenetly get this if I get a server up. It's great that you have made this unique balancer and care about it, it makes me care about it too. Good job
Title: Re: cube v1.5 - major update
Post by: Bonecrusher on November 25, 2011, 06:49:40 pm
Keep up the good job fri
Title: Re: cube v1.5 - major update
Post by: Irlandec on December 05, 2011, 05:57:42 am
Suggestion: Adding AFK handling would be great addition for the balancer. Also, for example, script could use TF2-like function: if team scores insanely fast for X minutes, vote for /mix is called. Hoper you got the point.

Still, good job there,definately using it!
Title: Re: cube v1.5 - major update
Post by: Leo on February 25, 2012, 04:17:54 am
I enabled this for inf server but I get endless spam in logs with this: "Too few players. Balance is disabled."   ???
Title: Re: cube v1.5 - major update
Post by: Mighty on February 25, 2012, 10:18:04 am
Also, the way your script works disables team changing even performed by admin (Meaning, /setteamX X doesnt work). That's a bit annoying.
Title: Re: cube v1.5 - major update
Post by: Bonecrusher on January 09, 2013, 06:53:42 am
Unforutnately it's not as good in balancing as it used to be. I would be grateful if someone went through the code and find out what might be wrong. Mostly fails with swapping best player with the weakest one, what I think is wrong it excludes players who scored a cap from balancing.
Title: Re: cube v1.5 - major update
Post by: Bonecrusher on July 10, 2013, 03:11:21 pm
@up anyone?
Title: Re: cube v1.5 - major update
Post by: freestyler on July 10, 2013, 05:43:30 pm
That might have been the intended behavior (I don't remember now), but you can change it by modifying the code a tiny bit. The changes are really minimal:

Locate line 305 (it's inside "method 0"):
Code: [Select]
for i := 1 to j do if (GetPlayerStat(player[i], 'Flags') = 0) then begin
Change it to:
Code: [Select]
for i := 1 to j do begin
---

Locate line 571 (inside "swaps limit not reached, swap the players!"):
Code: [Select]
pl2 := ChoosePlayer(iif(temp=11, 1, 2), 5);
Change "5" to "2":
Code: [Select]
pl2 := ChoosePlayer(iif(temp=11, 1, 2), 2);
---

That's it. Swap will now ignore player's caps and only count kills.
Title: Re: cube v1.5 - major update
Post by: Bonecrusher on July 11, 2013, 03:37:26 am
(10:37:17) 
Title: Re: cube v1.5 - major update
Post by: freestyler on July 12, 2013, 07:58:13 am
Not possible, the code compiles. Check that you properly deleted the if (GetPlayerStat(player[​i], 'Flags') = 0) then part, including both if and then.
Title: Re: cube v1.5 - major update
Post by: KoGAi on July 29, 2013, 08:36:32 pm
Hi, is there a work around the errors the legacy compiler shows for cube?
The error that the legacy compiler is showing in Linux is [Error] (183:19): Semicolon (';') expected. I checked the code and it appears to be correct.

Thank You,
K-
Title: Re: cube v1.5 - major update
Post by: Bydlak on July 30, 2013, 02:12:58 pm
Hello

There is a problem with last cube version. When I mix a teams using command /mix, some of the mixed players respawn in the enemy base when the map change. Is there any way to fix it?
Title: Re: cube v1.5 - major update
Post by: Moneymaker on October 09, 2013, 03:56:10 am
Cube is good script, but too complicated. I need a simple script... only balance, when one team have 2 players more... do you know something that?
Title: Re: cube v1.5 - major update
Post by: rOy on October 09, 2013, 02:47:39 pm
Cube is good script, but too complicated. I need a simple script... only balance, when one team have 2 players more... do you know something that?

I know one more script

Name: CTF Team Balancer
Author: Swompie (©2o1o) - Modified by StayAlive (@2012)
Recoder: rOy

This script is a modified for version 2.7.5 server

Commands:
!balance
Every 60 sec. automaticaly balanced teams

Download here:
Title: Re: cube v1.6 - CTF/INF Ultimate Balancer
Post by: freestyler on March 31, 2014, 05:58:26 pm
cube v1.6 is out, after over two years! (http://oko.im/script/dl.php?s=cube)

Changes 1.5 -> 1.6:
added: /exclude ID command for admins, to exclude players for the duration of their visit on the server
added: /cubeinfo command for admins - shows current cube info (version, config, number of balances)
added: a message that shows up if cube could not choose any player to move; you should not see it anyway
added: public messages show current balance status, e.g. 'Teams balanced. [3v2 4:7]'
added: option to make swap ignore the number of flag captures when choosing players
fixed: a bug that caused spectators to be moved to alpha team when /swap all was used
modified: reworked the whole config to make it even clearer
modified: some default values in config
modified: bots are now ignored by cube
modified: excluding now makes people completely immune to cube's effects
modified: colors of some messages
modified: /hwid ID command also works with nicknames

Hotfix: added spaces before ShowPlayers(); in public messages, and fixed typo in message shown after swapping.
Title: Re: cube v1.6 - CTF/INF Ultimate Balancer
Post by: PKS|Shooter on April 18, 2014, 08:49:01 am
where is the dl link?
Title: Re: cube v1.6 - CTF/INF Ultimate Balancer
Post by: Bonecrusher on April 19, 2014, 06:44:25 am
cube v1.6 is out, after over two years! - click that
Title: Re: cube v1.6.1 - CTF/INF Ultimate Balancer
Post by: freestyler on April 25, 2014, 03:25:48 pm
1.6.1 is out! Grab the latest version by clicking here. (http://oko.im/script/dl.php?s=cube)

Changes 1.6 -> 1.6.1:
fixed: a terrible bug which rendered /exclude command useless (it excluded the user, not the specified ID)
modified: simplified a bit of logic
Title: Re: cube v1.6.1 - CTF/INF Ultimate Balancer
Post by: Mittsu on May 02, 2014, 01:06:34 pm
could you, pretty pretty please, include settings for survival? Balance should be done ONLY in between rounds, otherwise the players get pissed off as team change kills them and they have to wait for a new round
Title: Re: cube v1.6.1 - CTF/INF Ultimate Balancer
Post by: freestyler on May 05, 2014, 03:05:58 pm
Sure, but is there any reliable way of detecting round end? I found no scripting event (http://wiki.soldat.pl/index.php/Category:Server_Scripting_Events) for this. Is checking if everyone's dead the only way?
Title: Re: cube v1.6.1 - CTF/INF Ultimate Balancer
Post by: Mittsu on May 11, 2014, 02:39:58 am
i have no idea about coding, but maybe this script will help? It prevents from scoring with flag caps after the round is already won by killing the other team:

Code: [Select]
var
  Double, Alone, Messages: boolean;
  PlayerPnts, TeamPnts: byte;
  Color: longint;

function AlivePlayers(Team: shortint): byte;
var
  i: byte;
begin
  for i := 1 to 32 do if (GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Alive') = true) and ((Team = -1) or (GetPlayerStat(i,'Team') = Team)) then Result := Result + 1;
end;

procedure ActivateServer();
begin
  try
    if ReadINI('scripts/' + ScriptName + '/settings.ini','General','Message','true') = 'true' then Messages := true else Messages := false;
    Color := StrtoInt(ReadINI('scripts/' + ScriptName + '/settings.ini','General','MsgColor','$FFFFFFFF'));
    PlayerPnts := StrtoInt(ReadINI('scripts/' + ScriptName + '/settings.ini','General','PlayerPnts','5'));
    TeamPnts := StrtoInt(ReadINI('scripts/' + ScriptName + '/settings.ini','General','TeamPnts','1'));
    if ReadINI('scripts/' + ScriptName + '/settings.ini','General','DoubleCap','false') = 'true' then Double := true else Double := false;
    if ReadINI('scripts/' + ScriptName + '/settings.ini','General','AloneCap','false') = 'true' then Alone := true else Alone := false;
  except
    WriteLn('Error while loading settings.');
  end;
end;

procedure OnFlagScore(ID, TeamFlag: byte);
var
  i: byte;
begin
  if iif(TeamFlag = 1,AlphaPlayers,BravoPlayers) = 0 then begin
    if Alone = false then begin
      SetTeamScore(iif(TeamFlag = 1,2,1),iif(TeamFlag = 1,BravoScore,AlphaScore) - 1);
      if Messages then WriteConsole(ID,'Capturing while alone has no effect.',Color);
    end else begin
      SetTeamScore(iif(TeamFlag = 1,2,1),iif(TeamFlag = 1,BravoScore,AlphaScore) - 1 + TeamPnts);
    end;
  end else if AlivePlayers(TeamFlag) = 0 then begin
    if Double = false then begin
      SetTeamScore(iif(TeamFlag = 1,2,1),iif(TeamFlag = 1,BravoScore,AlphaScore) - 1);
      if Messages then WriteConsole(ID,'Double capturing has no effect.',Color);
    end else begin
      SetTeamScore(iif(TeamFlag = 1,2,1),iif(TeamFlag = 1,BravoScore,AlphaScore) - 1 + TeamPnts);
    end;
  end else begin
    SetTeamScore(iif(TeamFlag = 1,2,1),iif(TeamFlag = 1,BravoScore,AlphaScore) - 1 + TeamPnts);
  end;
end;
Title: Re: cube v1.6.1 - CTF/INF Ultimate Balancer
Post by: rOy on May 09, 2022, 07:36:06 am
Hey,
freestyler's script again uploaded! (cube v1.6.1)
The link has long since disappeared!
But here you have the file pin!