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

Team Balance Immunity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Afronanny
Veteran Member
Join Date: Aug 2009
Old 06-14-2010 , 23:33   Team Balance Immunity
Reply With Quote #1

Team Balance Immunity

This extension allows you to use Valve's autobalance system, which is, in my opinion the best one, and give certain people immunity to it. A basic sample immunity plugin is included that gives people with the 'a' flag immunity to autobalance.

The regular version will download an updated version of the gamedata if it changes. I have added versions of the extension so that you can opt-out of automatic gamedata updates if you wish.


Instructions
  1. Extract the contents of the archive to your game folder (tf or cstrike)
  2. Give yourself (and any others) admin flag 'a', or whatever you change it to in the example plugin using the 'sm_teambalance_flags' cvar
  3. Load the example plugin
Download:

TF2:
Regular: 1.0
No Automatic Gamedata Updater (Not recommended): 1.0

CSS (Linux version does not work at the moment):
Regular: 1.0
No Automatic Gamedata Updater (Not recommended): 1.0
The Linux CS:S version has a very nasty crash that I have been unable to track down. All debug and crash data I have collected has been utterly useless. I don't forsee a fix in the near future.

Source code available
Here
The source code is the same for all versions, TF2 and CS:S. They are compiled using defines, so you need only un-comment or comment out whichever options you want in extension.cpp if you are compiling this yourself.

SourcePawn Forwards:
PHP Code:
/**  
 * @brief Called when the balancer wants to know if a player can be autobalanced  *  
 * @param client    Index of the client
 * @param actual    Result as determined by the server. Overwrite and return Plugin_Handled to force a value.  
 * @return         True to allow player to be seen, false to disallow player being seen  
 */ 

forward Action:OnBalanceCheck(client, &bool:actual); 
How to use in a plugin:
PHP Code:
#include <teambalance>
#include <sourcemod>

public Action:OnBalanceCheck(client, &bool:actual)
{
    if (
GetUserFlagBits(client) & ADMFLAG_GENERIC)
    {
        
actual false;
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;


Last edited by Afronanny; 09-07-2012 at 09:13.
Afronanny is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 06-15-2010 , 01:54   Re: [EXTENSION] TF2 Team Balance Immunity
Reply With Quote #2

Nice, I wish I knew how TF2's autobalancer chooses players to be balanced?
__________________

DontWannaName is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 06-15-2010 , 02:39   Re: [EXTENSION] TF2 Team Balance Immunity
Reply With Quote #3

It's based on how recently you joined the server and how much time has passed since the last time you were switched.

Source code needs to be cleaned up. Check line 46. Not being able to respawn kind of sucks- should be fixable. A forward for sourcepawn would be useful. Then you could use a plugin to check immunity.
__________________
pheadxdll is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 06-15-2010 , 08:57   Re: [EXTENSION] TF2 Team Balance Immunity
Reply With Quote #4

I'm fairly sure it just chooses the next player to die after it decides that teams need balancing.
Wazz is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 06-15-2010 , 08:59   Re: [EXTENSION] TF2 Team Balance Immunity
Reply With Quote #5

Quote:
Originally Posted by DontWannaName View Post
Nice, I wish I knew how TF2's autobalancer chooses players to be balanced?
Code:
CBaseMultiplayerPlayer::CalculateTeamBalanceScore(void)
CBaseEntity::IsAlive(void)
CTeamplayRoundBasedRules::AreTeamsUnbalanced(int, int)

Last edited by Afronanny; 06-15-2010 at 10:15.
Afronanny is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 06-15-2010 , 11:18   Re: [EXTENSION] TF2 Team Balance Immunity
Reply With Quote #6

Quote:
Originally Posted by Afronanny View Post
Code:
CBaseMultiplayerPlayer::CalculateTeamBalanceScore(void)
CBaseEntity::IsAlive(void)
CTeamplayRoundBasedRules::AreTeamsUnbalanced(int, int)
Only the first two are needed, the third isn't necessary for this to work, and might be the cause of the respawn bug.
bl4nk is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 06-15-2010 , 12:11   Re: [EXTENSION] TF2 Team Balance Immunity
Reply With Quote #7

Quote:
Originally Posted by bl4nk View Post
Only the first two are needed, the third isn't necessary for this to work, and might be the cause of the respawn bug.
bl4nk, you're right, AreTeamsUnbalanced wasn't needed at all .If the player is alive, they won't be balanced, right? I don't think CalculateTeamBalanceScore would be required, if the player is reported as alive.

By the way, I now have a forward for sourcepawn coded in, and the respawn bug is fixed. All I need to do is figure out why I always get "file not found" errors when trying to compile on Windows and fix them >.<
Afronanny is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 06-15-2010 , 12:36   Re: [EXTENSION] TF2 Team Balance Immunity
Reply With Quote #8

Updated source and binaries:

  • Fixed respawn bug.
  • Added Windows binary (not tested)
  • Added sourcepawn forward.
Afronanny is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-15-2010 , 13:33   Re: [EXTENSION] TF2 Team Balance Immunity
Reply With Quote #9

Nice work on this Afronanny, glad to see there is finally a public one .
__________________
asherkin is offline
blik
Senior Member
Join Date: May 2006
Old 06-15-2010 , 15:39   Re: [EXTENSION] TF2 Team Balance Immunity
Reply With Quote #10

Windows servers crash as they start

Quote:
L 06/15/2010 - 2078: [AUTOIMMUNITY] Sigscan for Balance failed - Disabling detour to prevent crashes
Look forward to fixed/tested windows binary.
blik 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:34.


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