Raised This Month: $12 Target: $400
 3% 

Simple Team Balancer for TFC


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Team Fortress Classic        Category:   General Purpose        Approver:   Arkshine (91)
pizzahut
Senior Member
Join Date: Oct 2004
Old 04-06-2010 , 08:46   Simple Team Balancer for TFC
Reply With Quote #1

A team balancer for TFC

When joining a team, it checks the number of human players in all teams, and only allows joining if this wouldn't unbalance the teams.

Note: Because the plugin is based on human player count, bots should be set to even the teams. With FoxBot, use these settings in file "foxbot\tfc\foxbot.cfg":
Code:
# Bot team balance (0 off, 1 on)
# Turn this on to have the bots auto switch when teams become uneven
bot_team_balance 1

# Bot to human balance (0 off, 1 on)
# Turn this on to balance the teams in a bot to human ratio (May be buggy)
bot_bot_balance 0
Unbalanced teams can still happen by players leaving or joining the spectator team.
The human-to-human ratio can get messed up if people use auto assign while bots are present. (This is fixed in the beta.)

CVARS

stb_on (1/0) - enable the plugin (default: 1)
stb_teams (1 .. 4) - number of teams the current map has (default: 2)
stb_version - version number (visible in server rules)

Code:
Simple team balance plugin for TFC

Can be configured to work with 4 teams via cvar (stb_teams).
Put stb_teams "4" into the corresponding map cfg file (e.g. rats).

For maps where the teams are supposed to be uneven (e.g. the TFC map "hunted"),
the plugin can be disabled via map cfg file. Put stb_on "0" into the map cfg in
addons/amxmodx/configs/maps/.

Admins with immunity can switch to any team.

tfc_autoteam should be disabled when there are bots (but can be enabled for maps
like hunted), because the plugin is based on human players, which tfc_autoteam
is not.

If the cvars are changed in map configs, then the default values for the cvars
should be put into amxx.cfg or server.cfg. Else the cvars will not reset to
default after map change.
Note that only the beta is compatible with maps which feature uneven teams, e.g. hunted, ukfootie. All other plugins (stb, utw, fts) need to be configured as described above!

Beta changes

No need for map specific configs

Available teams and team size limits are detected automatically, map specific configs setting stb_on and stb_teams aren't necessary any more.

Cvar stb_handle_auto_assign

Handling auto assign prevents human players getting stacked in one team when bots are present.

0 = let TFC handle auto assign
1 = move player to the team with the least humans (default)
2 = disable auto assign

Cvar stb_immunity

Only check immunity if this cvar is "true" (1), which is the default.

Cvar stb_debug

Debug infos in console and hint in chat, off by default.

To do
  • Announcement if teams are uneven (EDIT: This is currently implemented as an alternative plugin (UTW - uneven teams warning).)
  • When a player selects auto assign (5), this command should be blocked / exchanged with the appropriate team according to human count. (Since auto assign doesn't differentiate between bots and humans.) (EDIT: This is currently in beta.)
  • Determine number of teams through pfn_keyvalue forward / function copy_keyvalue. Check which teams are used by spawns (entity class info_player_teamspawn), check entity (class) info_tfdetect for team size limits. (EDIT: This is currently in beta.)
  • "Team switch denied" sound (like the Admin Mod plugin)
  • Optional forced switching if teams become uneven Use "fts" plugin instead of "utw".
  • Perhaps a vote trigger to allow a humans vs. bots mode.
  • Optionally ignoring admin immunity (cvar). (EDIT: This is currently in beta.)
  • Scramble / shuffle teams
(There's probably more to do which I don't remember right now.)
Attached Files
File Type: sma Get Plugin or Get Source (stb.sma - 2126 views - 3.0 KB)
File Type: sma Get Plugin or Get Source (utw.sma - 1637 views - 1.7 KB)
File Type: sma Get Plugin or Get Source (fts6.sma - 1112 views - 4.3 KB)
File Type: sma Get Plugin or Get Source (shuffle_teams.sma - 1069 views - 3.4 KB)
File Type: sma Get Plugin or Get Source (stb_beta6.sma - 113 views - 6.6 KB)
__________________
My AMXX plugins (content date 2007-03-29, link check 2017-04-26)

Plugins for the Royston Vasey TFC server - These are UNSUPPORTED, except those which have been published at AMX Mod X.

Last edited by pizzahut; 07-13-2023 at 15:16. Reason: Bug fix stb_beta: Teams on avanti style maps are now detected.
pizzahut is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-06-2010 , 09:01   Re: Simple Team Balancer
Reply With Quote #2

Quote:
The code will produce one warning that can be ignored. It says that jointeam doesn't return a value, but this isn't true.
Simply put return PLUGIN_CONTINUE at the end.


btw, you provide a "beta" but you don't say what are the changes.
__________________
Arkshine is offline
NiQu
Veteran Member
Join Date: Nov 2009
Old 04-06-2010 , 13:33   Re: Simple Team Balancer
Reply With Quote #3

EDIT: sry didnt notice it was for TFC sorry.
__________________
My Projects
  • RoTAPI V0.0.1 ------- Private
    • Progress - [||||||||||]
  • CashMod V0.0.6 ----- Public
    • Progress - [||||||||||]
  • CashMod V0.0.7 ----- Public
    • Progress - [||||||||||]
NiQu is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 04-06-2010 , 15:10   Re: Simple Team Balancer for Team Fortress Classic (TFC)
Reply With Quote #4

Moved the return command from the if-then-else clauses to the end of the function.

Removed the beta.

Added TFC heading to the thread title.

Several minor changes to the source code.
__________________
My AMXX plugins (content date 2007-03-29, link check 2017-04-26)

Plugins for the Royston Vasey TFC server - These are UNSUPPORTED, except those which have been published at AMX Mod X.
pizzahut is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-06-2010 , 15:16   Re: Simple Team Balancer for Team Fortress Classic (TFC)
Reply With Quote #5

You don't need to initialize manually the array, it's done automatically with "new". You can cache also get_maxplayers().
__________________
Arkshine is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 04-06-2010 , 16:18   Re: Simple Team Balancer for Team Fortress Classic (TFC)
Reply With Quote #6

I've went one step further and made it a global variable, because maxplayers can't be changed.
__________________
My AMXX plugins (content date 2007-03-29, link check 2017-04-26)

Plugins for the Royston Vasey TFC server - These are UNSUPPORTED, except those which have been published at AMX Mod X.
pizzahut is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-06-2010 , 16:21   Re: Simple Team Balancer for Team Fortress Classic (TFC)
Reply With Quote #7

I was meant that since it's something it won't change in-game. ;)
__________________
Arkshine is offline
eazt
Junior Member
Join Date: Apr 2010
Old 05-02-2010 , 15:27   Re: Simple Team Balancer for TFC
Reply With Quote #8

Hi
I installed this on my server.
Its shows up when i type amx_plugins
I entered stb_on 1 and stb_teams 2 in console - for 2fort
i dont know what to enter for stb_version so i haven't entered anything.

It does not seem to work at all.

Any help appreciated

thanks
eazt is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 05-03-2010 , 05:51   Re: Simple Team Balancer for TFC
Reply With Quote #9

For 2fort you don't need to configure anything, the values you mentioned are default. stb_version just contains the version number, it shouldn't be changed.

I'm assuming this is for the UK 2fort server, it seems to be working. Red had two human players, blue team zero humans (which for the reasons I stated in the first post can happen), and I could *not* choose the red team, so it's working as intended.

Immunity: If you have admin immunity (check for flag "a" in file "tfc\addons\amxmodx\configs\users.ini"), you can switch to any team.

No forced switching: If teams are uneven e.g. by players dropping from one team, players will NOT be forced to switch.

Auto team: If someone chooses auto team (which is available even if tfc_autoteam is disabled), it can happen that there are more humans in one team if there are currently bots present.

Bot team balance: This should be enabled, see first post.
__________________
My AMXX plugins (content date 2007-03-29, link check 2017-04-26)

Plugins for the Royston Vasey TFC server - These are UNSUPPORTED, except those which have been published at AMX Mod X.

Last edited by pizzahut; 05-05-2010 at 15:40.
pizzahut is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-31-2010 , 07:09   Re: Simple Team Balancer for TFC
Reply With Quote #10

The plugin needs testing. If anyone can report that it does or doesn't work, please post, before approval.

If you would like any information regarding possible adjustments you could make or things you could do to make this better, please feel free to post here or PM me.
__________________
Arkshine is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:37.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode