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

Autobalance -Admin


Post New Thread Reply   
 
Thread Tools Display Modes
Antithasys
Moderator
Join Date: Apr 2008
Old 09-06-2008 , 15:06   Re: Autobalance -Admin
Reply With Quote #11

I added some error checking although I still never run GetClientName(). I think you got that error from my modified ammopacks and medipacks, which I corrected in their threads.

I went ahead and had it return if the client is not connected, which doesn't make sense because why would the event run on a client not connected, but ok its in there. I am guessing that sometimes the server runs this event and that is why the client index is 0, and I guess it is possible that during the split second that the event is run the client may disconnect. Either way, I added:

Code:
if (IsClientConnected(client)) {
Let me know if you are having any additional problems.

Last edited by Antithasys; 09-06-2008 at 16:00.
Antithasys is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-06-2008 , 16:50   Re: Autobalance -Admin
Reply With Quote #12

I don't see how this plugin will even work. The way the whole system works is that it picks a player to switch, switches them, and then fires the event. The event doesn't actually control whether or not the player was switched, it just controls whether or not the message is relayed to the players.

Taken from CTeamplayRoundBasedRules::BalanceTeams(bool bRequireSwitcheesToBeDead):
Code:
    for ( int i=0; i<vecPlayers.Count() && iNumSwitchesRequired > 0 && i < iNumEligibleSwitchees; i++ )
    {
        pPlayer = vecPlayers.Element(i);

        Assert( pPlayer );

        if ( !pPlayer )
            continue;

        if ( bRequireSwitcheesToBeDead == false || !pPlayer->IsAlive() )
        {
            pPlayer->ChangeTeam( iLightestTeam );
            pPlayer->SetLastForcedChangeTeamTimeToNow();

            IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_teambalanced_player" );
            if ( event )
            {
                event->SetInt( "player", pPlayer->entindex() );
                event->SetInt( "team", iLightestTeam );
                gameeventmanager->FireEvent( event );
            }

            // tell people that we've switched this player
            UTIL_ClientPrintAll( HUD_PRINTTALK, "#game_player_was_team_balanced", pPlayer->GetPlayerName() );

            iNumSwitchesRequired--;
        }
    }
bl4nk is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 09-06-2008 , 17:08   Re: Autobalance -Admin
Reply With Quote #13

Well like I said it has been hard to test. After 3 days none of my admins were switched so I figured it worked.

Since I was getting the event in _Pre mode I figured switching the team back would make the event essentially "try again".

But from looking at what you posted, it appears that this will actually do nothing and I have just been lucky with the autobalances.

Would be nice if the event actually controlled the switching.

Oh well. Delete this thread or move to unapproved.
Antithasys is offline
ThatGuy
Senior Member
Join Date: Nov 2007
Old 09-06-2008 , 17:41   Re: Autobalance -Admin
Reply With Quote #14

I test by adding bots, then kicking them. Forcing the teams to balance, and kill yourself a few times to see if it works.
ThatGuy is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-06-2008 , 17:44   Re: Autobalance -Admin
Reply With Quote #15

I did basically the same thing, but I modified the plugin to print a text saying that user x is going to be switched, and the block the event. It would end up with the user still being switched over. I then decided to dig into the SDK and found what I showed up above.
bl4nk is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 09-07-2008 , 16:25   Re: Autobalance -Admin
Reply With Quote #16

All I know is it gives a whole lot of errors. Why cant you just take the code out of Pinkfaries donator plugin and make it with the a flag.
__________________

DontWannaName is offline
ThatGuy
Senior Member
Join Date: Nov 2007
Old 09-07-2008 , 17:09   Re: Autobalance -Admin
Reply With Quote #17

I tried doing that but i couldn't get it to work. Now i'm looking at editing Crimson's team balancer to make it block admins. Though, I of course won't release it, because it's not my plugin to showoff.
ThatGuy is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 09-07-2008 , 19:10   Re: Autobalance -Admin
Reply With Quote #18

Quote:
Originally Posted by DontWannaName View Post
All I know is it gives a whole lot of errors. Why cant you just take the code out of Pinkfaries donator plugin and make it with the a flag.
Pinkfaire hooks the same event and it will have the same results.

Basically we(as in someone) just needs to make a autobalancer that does it very simply. I have already started to work on one, but it will take a week or so to test and get it on the forums.
Antithasys is offline
Reply



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 20:34.


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