If these two numbers diverge, Nexgen issues a playerTeamChanged() call to plugins. In the vast majority of instances this works just fine. But for reasons that would be too long-winded to go into, I needed something that had a direct link back to the line that caused the team change to happen in the first place - in other words, I didn't want additional game ticks to take place before I had a chance to intercept and deal with them.
So poking around, and tracing through the class hierarchy, I eventually found the AddToTeam() function inside of TeamGamePlus (so, obviously, this will only be applicable to TeamGamePlus derived game types).
Near the end of the AddToTeam() function, a call to BroadcastLocalizedMessage() is issued, and this can be intercepted by a mutatorBroadcastLocalizedMessage() function in a mutator to watch for the relevant LocalMessage class, e.g.,
Code: Select all
function bool mutatorBroadcastLocalizedMessage(actor sender, pawn receiver, out class<LocalMessage> message, out optional int switch, out optional playerReplicationInfo relatedPRI_1, out optional playerReplicationInfo relatedPRI_2, out optional object optionalObject)
{
local teamInfo TI;
if (message == class'botpack.deathMatchMessage' && sender.isA('CTFGame') && switch == 3)
{
TI = teamInfo(optionalObject);
// TI.teamIndex contains the new team number
// relatedPRI_1 is the playerReplicationInfo for the player who changed teams
if (TI != none)
LOG(relatedPRI_1.playerName $ " SWITCHED TO TEAM " $ TI.teamIndex);
}
return true;
}