AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Simple Team Balancer for TFC (https://forums.alliedmods.net/showthread.php?t=123523)

pizzahut 04-06-2010 08:46

Simple Team Balancer for TFC
 
18 Attachment(s)
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.)

Arkshine 04-06-2010 09:01

Re: Simple Team Balancer
 
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.

NiQu 04-06-2010 13:33

Re: Simple Team Balancer
 
EDIT: sry didnt notice it was for TFC sorry.

pizzahut 04-06-2010 15:10

Re: Simple Team Balancer for Team Fortress Classic (TFC)
 
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.

Arkshine 04-06-2010 15:16

Re: Simple Team Balancer for Team Fortress Classic (TFC)
 
You don't need to initialize manually the array, it's done automatically with "new". You can cache also get_maxplayers().

pizzahut 04-06-2010 16:18

Re: Simple Team Balancer for Team Fortress Classic (TFC)
 
I've went one step further and made it a global variable, because maxplayers can't be changed.

Arkshine 04-06-2010 16:21

Re: Simple Team Balancer for Team Fortress Classic (TFC)
 
I was meant that since it's something it won't change in-game. ;)

eazt 05-02-2010 15:27

Re: Simple Team Balancer for TFC
 
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

pizzahut 05-03-2010 05:51

Re: Simple Team Balancer for TFC
 
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.

Arkshine 10-31-2010 07:09

Re: Simple Team Balancer for TFC
 
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.


All times are GMT -4. The time now is 10:41.

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