Skip to content

Commit

Permalink
Swap players right when they spawn instead of when they die to preven…
Browse files Browse the repository at this point in the history
…t teamkill errors
  • Loading branch information
allejo committed Aug 4, 2014
1 parent af450a8 commit 326561c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions autoTeamBalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const std::string PLUGIN_NAME = "Automatic Team Balance";
const int MAJOR = 1;
const int MINOR = 6;
const int REV = 0;
const int BUILD = 63;
const int BUILD = 64;

class teamSwitch : public bz_Plugin, public bz_CustomSlashCommandHandler
{
Expand Down Expand Up @@ -76,8 +76,8 @@ void teamSwitch::Init (const char* /*commandLine*/)
// Register our events with Register()
Register(bz_eAllowCTFCaptureEvent);
Register(bz_eCaptureEvent);
Register(bz_ePlayerDieEvent);
Register(bz_ePlayerJoinEvent);
Register(bz_ePlayerSpawnEvent);
Register(bz_eTickEvent);

// Register our custom slash commands
Expand Down Expand Up @@ -380,11 +380,22 @@ void teamSwitch::Event (bz_EventData* eventData)
}
break;

case bz_ePlayerDieEvent: // This event is called each time a tank is killed.
case bz_ePlayerJoinEvent: // This event is called each time a player joins the game
{
bz_PlayerJoinPartEventData_V1* joinData = (bz_PlayerJoinPartEventData_V1*)eventData;

int playerID = joinData->playerID;

swapQueue[playerID] = false;
targetTeamQueue[playerID] = eNoTeam;
}
break;

case bz_ePlayerSpawnEvent: // This event is called each time a tank is killed.
{
bz_PlayerDieEventData_V1* dieData = (bz_PlayerDieEventData_V1*)eventData;
bz_PlayerSpawnEventData_V1* spawnData = (bz_PlayerSpawnEventData_V1*)eventData;

int playerID = dieData->playerID;
int playerID = spawnData->playerID;

if (swapQueue[playerID])
{
Expand All @@ -400,17 +411,6 @@ void teamSwitch::Event (bz_EventData* eventData)
}
break;

case bz_ePlayerJoinEvent: // This event is called each time a player joins the game
{
bz_PlayerJoinPartEventData_V1* joinData = (bz_PlayerJoinPartEventData_V1*)eventData;

int playerID = joinData->playerID;

swapQueue[playerID] = false;
targetTeamQueue[playerID] = eNoTeam;
}
break;

case bz_eTickEvent:
{
bz_eTeamType strongTeam, weakTeam;
Expand Down

0 comments on commit 326561c

Please sign in to comment.