Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SkillAutoBalance

Skill-based round-end team balancer for CS2 servers running ModSharp.

ModSharp CS2 Stars


A CS2 port of the SourceMod plugin SkillAutoBalance by Justin (NotJustin). At round end it rearranges teams using a Close Team Point Sums (CTPS) algorithm with IQR-based outlier detection, so the per-team skill totals end up as close as possible while keeping the number of swaps to a minimum. It can also trigger on win streaks, uneven teams, or a fixed round/player-change cadence, and optionally keeps swapped players alive until the next round.

🚀 Install

Copy the build output into your ModSharp install (<sharp> = your sharp directory):

From To
.build/modules/SkillAutoBalance/ <sharp>/modules/SkillAutoBalance/
.build/locales/skillautobalance.json <sharp>/locales/skillautobalance.json

Restart the server (or change map) to load. On first run the plugin writes an editable config to <sharp>/configs/skillautobalance.cfg and disables mp_autoteambalance / mp_limitteams automatically.

⌨️ Commands

Chat commands (enabled when sab_chatchangeteam 1):

Command Aliases Description
!join !j, !play, !p Join the game (auto-assigned a team)
!spec !s, !spectate Move to spectators

Admin commands:

Command Permission Description
sab_balance @skillautobalance/balance Force a balance now
sab_setteam <player> <t|ct|spec> @skillautobalance/setteam Move a player to a team

⚙️ Configuration

Edit <sharp>/configs/skillautobalance.cfg (generated on first run):

ConVar Default Meaning
sab_botsareplayers 0 Treat bots as players for scoring
sab_keepplayersalive 1 Keep swapped players alive (god mode until next round)
sab_minplayers 5 Minimum active players required to balance
sab_balanceafternrounds 0 Balance after N rounds from map start
sab_balanceafternplayerschange 0 Balance after N join/leave events
sab_balanceeveryround 0 Balance every round
sab_decayamount 1.5 Win-streak decay per loss
sab_minstreak 3 Win streak needed to trigger a balance
sab_nobalancelastnminutes 0 No balance in the last N minutes of the map
sab_nobalancelastnrounds 2 No balance in the last N rounds of the map
sab_balancecheckinterval 0 Run a balance check every N rounds regardless of streak (0=off)
sab_usedecay 1 Decay a losing streak (1) or reset it (0)
sab_blockteamswitch 0 0=allow, 1=same-team only, 2=block completely
sab_chatchangeteam 1 Enable !join / !spec chat commands
sab_enableplayerteammessage 1 Show player-team-change messages
sab_forcejointeam 2 0=off, 1=optional, 2=forced on connect
sab_maxteamsize 0 Max players per team (requires sab_blockteamswitch 2)
sab_teammenu 1 Show the join-team menu
sab_scale 1.5 IQR scale for outlier detection
sab_prefix [SAB] Chat prefix

🔧 How it works

Each round end the balancer scores active players (kills/deaths/assists from in-game match stats), flags outliers with an IQR test scaled by sab_scale, and searches for the team split whose point sums are closest while minimising the number of players moved. Balancing fires when teams are uneven, on a configured cadence (sab_balanceeveryround / sab_balanceafternrounds / sab_balanceafternplayerschange), or when a win streak passes sab_minstreak (with optional decay via sab_usedecay / sab_decayamount). When sab_keepplayersalive is on, swapped players are kept alive with god mode and their attack input is blocked until the next round.

📦 Build

dotnet build -c Release

Outputs .build/modules/SkillAutoBalance/SkillAutoBalance.dll and .build/locales/skillautobalance.json.

📄 Licence

Deliberately unlicensed, because the upstream is. NotJustin/SkillAutoBalance declares no licence, so there is no grant to pass on and asserting one here would claim rights this project does not hold. Published for transparency and for use on our own servers; if you want to reuse it, ask Justin first.

If the upstream adds a licence, this repo will adopt it.

🙏 Credits

Port of NotJustin/SkillAutoBalance by Justin (NotJustin).

Porting notes

A few SourceMod features have no CS2/ModSharp equivalent and are not ported:

  • External ranking systems (gameME, HLstatsX, …) — no CS2 equivalent; scoring falls back to in-game match stats (kills/deaths/assists).
  • Admin menu integration — ModSharp's admin menu differs from SourceMod's TopMenu.
  • Auto-join client cookie — no equivalent cookie API in ModSharp 2.x.
  • Last-N-minutes no-balance window — only the round-count guard (sab_nobalancelastnrounds) is wired; the time-remaining guard needs an engine time API.

Made with ❤️ by cs2-server-plugins

⭐ Star this repo if you find it useful!

About

Skill-based round-end team balancer for CS2 servers running ModSharp — CTPS algorithm with IQR outlier detection.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages