AlliedModders (
-   Plugins (
-   -   [CS:GO] Skill Auto Balance (v3.1.1, 2020-6-11) (

Effeff 05-25-2019 03:26

[CS:GO] Skill Auto Balance (v3.1.1, 2020-6-11)

A configurable automated team manager.

Related Plugins

Admin Player Team Switch and Scramble Menu by r5053
[CS:S/GO+DoD:S] Auto Team Scrambler 2 (Updated 27-12-2012 @ DODS/CSGO) by RedSword
[ANY MOD] SwapTeam v1.2.6 (Updated 30/09/12) by bobbobagan
CS:S Team Balance by dalto
RankMe RankScramble by eyal282
Team Join Manager by GetRektByNoob
Block Team Changes by sdz
TeamChange Unlimited by Sheepdude
[CSGO] Auto Assign Team by SM9


Version 3 changelog

3.1.1 -
This time, for sure, the correct amount of players will be swapped now. The bug is, there were duplicate clients being created in my list of clients. They were created after sorting. In my list of clients, there were some extra empty indices with 0's, and those 0's were being replaced with other client indices.
Also fixed other broken logic related to determining which players count as outliers.

3.1.0 -
The correct amount of players will be swapped now. (closed issues #8 and #11)<br>
ForceJoinTeam convar changed to be an int and has 3 options now (disabled: 0, optional: 1, forced: 2)
Added new cvars to balance teams after map change and after a certain amount of players join/leave, or even to balance every single round.
Added a scale. Basically, lower scale = more outliers.
Translations updated.

3.0.2 -
Scores are updated correctly.
BalanceSkill now only occurs after all scores are updated.
Disabling "teammenu" now only occurs after mapstart to prevent errors.
Balance should no longer cause teams to be horribly misbalanced. (imagine making an autobalance that just makes teams worse :oops: )
Spawn bug (may) be fixed after implementing "[CSGO] Auto Assign Team by SM9". Forcing players to join teams now uses ClientCommand for "jointeam". Thanks to MAMAC for showing me and both SM9+MAMAC for creating this. **I say "may" be fixed because the problem was already rare and so it is possible that I have just not seen or been notified of it happening when it does.

Sorting method combines two ideas now. I call them "closest sums" and "alternating".
"Closest sums" makes the sum of points on both teams as close as possible.
"Alternating" alternates players between teams as it goes down the sorted list.
Read about it here:
Added support for Level Ranks
A fork of the plugin on github has support for NC RPG. I added but shortly after removed support because their include file has a lot of extra includes that I don't want to add as a requirement for this plugin to be installed.
BlockTeamSwitch convar changed to be an int and has 3 options now (disabled: 0, enabled but can spectate: 1, enabled with no switching at all: 2)

3.0.1 - Changed sorting method when sorting by gameME or RankMe. Using gameME or RankMe, get client's skill rather than their rank. This way, I can sort all of the score types in the same way.

3.0.0 - I've been making lots of minor changes to this plugin over the last month.
In general, it consists of:
Function optimization
Improving code readability
Adding / removing features
Trying out various solutions to the bug I've been trying to fix for awhile now (see Bugs section).
Added RankMe Kento Edition support.

Version 2 changelog

Version 1 changelog:



Extract the GitHub repository into your ./csgo/addons/sourcemod/ directory.
If you have used this plugin in the past, replace these two old files with the new ones ./csgo/cfg/SkillAutoBalance.cfg and ./sourcemod/translations/skillautobalance.phrases.txt


Third party include files you need in order to compile are:
  • kento_rankme/
  • NCIncs directory
  • smrpg directory

Compatible Plugins
RankMe Kento Edition untested
LVL Ranks untested
SMRPG untested


None at the moment. If there is interest, I could try to support games other than CS:GO. I think it will be difficult for me though.


No bugs at the moment :D

Bara 05-25-2019 07:45

Re: [CS:GO] Skill Auto Balance (v1.0.2, 2019-5-25)

Get Plugin doesn't work and I'm not sure how to make it work but I put the .smx in attached files as well.
SMLib isn't provided with SourceMod, that's the reason.

You could replace Client_RemoveAllWeapons with something like that:


void RemoveClientWeapons(int client)
    int iEnt;
    for (int i = CS_SLOT_PRIMARY; i <= CS_SLOT_C4; i++)
        while ((iEnt = GetPlayerWeaponSlot(client, i)) != -1)
            SafeRemoveWeapon(client, iEnt, i);

stock bool SafeRemoveWeapon(int client, int weapon, int slot)
    if (HasEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"))
        int iDefIndex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
        if (iDefIndex < 0 || iDefIndex > 700)
            return false;
    if (HasEntProp(weapon, Prop_Send, "m_bInitialized"))
        if (GetEntProp(weapon, Prop_Send, "m_bInitialized") == 0)
            return false;
    if (HasEntProp(weapon, Prop_Send, "m_bStartedArming"))
        if (GetEntSendPropOffs(weapon, "m_bStartedArming") > -1)
            return false;
    if (GetPlayerWeaponSlot(client, slot) != weapon)
        return false;
    if (!RemovePlayerItem(client, weapon))
        return false;
    int iWorldModel = GetEntPropEnt(weapon, Prop_Send, "m_hWeaponWorldModel");
    if (IsValidEdict(iWorldModel) && IsValidEntity(iWorldModel))
        if (!AcceptEntityInput(iWorldModel, "Kill"))
            return false;
    if (weapon == GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"))
        SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", -1);
    AcceptEntityInput(weapon, "Kill");
    return true;

Effeff 05-25-2019 20:57

Re: [CS:GO] Skill Auto Balance (v1.0.3, 2019-5-25)
Fixed Client index 0 problem for real this time
- The "fix" from 1.0.2 was not related to GetScore(), and rather, it was a problem that happened because of my 1.0.1 fix which also was not a correct fix.
- The real problem was, I was calculating "swapAmount" incorrectly, so there were more players being added to the pool than there were players on the server.
Removed the SMLib include, and replaced relevant code with what Bara suggested.
- Thank you Bara.

Effeff 05-26-2019 13:50

Re: [CS:GO] Skill Auto Balance (v1.0.4, 2019-5-26)
Fixed swapping the wrong players on the losing team
- I had a > where there should have been a <. I'm a genius.

xSLOW 05-26-2019 15:59

Re: [CS:GO] Skill Auto Balance (v1.0.4, 2019-5-26)
Nice release!
I've been looking for a plugin like this!

Effeff 05-26-2019 18:55

Re: [CS:GO] Skill Auto Balance (v1.0.4, 2019-5-26)
Added cvar: sab_minrounddiff. Disabled by default.
- sab_minrounddiff "0" //The number of rounds the team that is in the lead must be ahead by in order for a swap to occur. So, if the team that is behind goes on a winstreak, they must first win enough rounds to be ahead in score of the other team before they will be swapped"

Soon I would like to do this which I wrote in plans:

- I would like to do what "mp_autoteambalance 1" does, but more immediate at the end of the round so that at the start of every round the teams should never have unmatched numbers beyond 1 player.

Effeff 05-27-2019 22:56

Re: [CS:GO] Skill Auto Balance (v1.0.5, 2019-5-26)
Fixed mistake with previous update calculating round difference incorrectly.
- I was subtracting the difference b/w the streaks of each team, rather than subtracting the difference in rounds won.
- So I added a counter that increases at the end of a round whenever a team wins, and this now uses the difference between those two numbers to determine the round difference, as it should have to begin with.

Changed the way players are chosen to be swapped, from "every other player in each array" to "N/2 random players in each array".
- I found out I could randomize the order of the array by using Sort_Random as the SortOrder.

Effeff 05-28-2019 10:00

Re: [CS:GO] Skill Auto Balance (v1.0.7, 2019-5-28)
Reset the round win count for each team to 0 on map change (forgot to do this for previous update).
Added a BalanceTeamCount function.
- While the teams are uneven by more than 1 player, the most recently connected player on the team with more players is swapped to the other team.

it's pretty late for me, I haven't tested this enough because I don't have a test server and I didn't feel like switching the config values on my own server to see what may/may not be working.

Effeff 05-29-2019 02:01

Re: [CS:GO] Skill Auto Balance (v1.0.7, 2019-5-28)
Added convar:

sab_truerandom "0" //If true, will choose randomly from the pool of highest and lowest players. If false, will choose every other player.

Reason being, I'm not confident in my implementation of randomly choosing from the pool. If the top two players end up on the same team, they have been carrying and triggering the swap and repeatedly these two players kept getting moved together. Having it choose every other player as it had before would prevent that I believe.

Effeff 05-29-2019 02:41

Re: [CS:GO] Skill Auto Balance (v1.0.9, 2019-5-29)
Fixed bug w/ swapping randomly.
- It would swap twice as many players as it was supposed to.

>_< sorry for spam

All times are GMT -4. The time now is 22:06.

Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.