PRoConEvents.MULTIbalancer.OnPlayerMovedByAdmin C# (CSharp) Method

OnPlayerMovedByAdmin() public method

public OnPlayerMovedByAdmin ( string soldierName, int destinationTeamId, int destinationSquadId, bool forceKilled ) : void
soldierName string
destinationTeamId int
destinationSquadId int
forceKilled bool
return void
        public override void OnPlayerMovedByAdmin(string soldierName, int destinationTeamId, int destinationSquadId, bool forceKilled)
        {
            if (!fIsEnabled) return;

            DebugWrite("^9^bGot OnPlayerMovedByAdmin^n: " + soldierName + " " + destinationTeamId + " " + destinationSquadId + " " + forceKilled, 7);

            try {
            if (fPluginState == PluginState.Active && fGameState == GameState.Playing) {
            if (fDisableUnswitcherByRemote) {
                DebugWrite("^nADMIN MOVED ^b" + soldierName + "^n to team " + destinationTeamId + ": ^8another plugin DISABLED the Unswitcher!", 4);
            }
            if (fPendingTeamChange.ContainsKey(soldierName)) {
                // this is an admin move in reversed order, clear from pending table
                fPendingTeamChange.Remove(soldierName);
                DebugWrite("(REVERSED) Moved by admin: ^b" + soldierName + "^n to team " + destinationTeamId, 6);
                // If the move was not done by MB, update and count the move
                PlayerModel player = GetPlayer(soldierName);
                if (player == null // haven't seen this player before
                || GetMovesThisRound(player) == 0 // never been moved before (MB FinishMove would have incremented this)
                || player.Team != destinationTeamId // no update for teams has been done yet (MB FinishMove would have done this)
                || player.LastMoveFrom != 0) { // interrupted MB move, special case
                    // Do updates as needed
                    bool interruptedMBMove = (player != null && player.LastMoveFrom != 0);
                    if (!interruptedMBMove) {
                        DebugWrite("^4^bADMIN^n moved player (REVERSED) ^b" + soldierName + "^n, " + GetPluginName() + " will respect this move", 4);
                    } else {
                        ConsoleDebug("Interrupted move (REVERSED) ^b" + soldierName + "^n, updating to correct");
                    }
                    UpdatePlayerTeam(soldierName, destinationTeamId);
                    if (!interruptedMBMove) ConditionalIncrementMoves(soldierName);
                    UpdateTeams();
                }
            } else if (!fUnassigned.Contains(soldierName)) {
                // this is an admin move in correct order, add to pending table and let OnPlayerTeamChange handle it
                fPendingTeamChange[soldierName] = destinationTeamId;
            }
            }
            } catch (Exception e) {
            ConsoleException(e);
            }
        }
MULTIbalancer