public int GetPlayerIndex(CSteamID steamID) { for (int i = 0; i < pugStatus.players.GetLength(0); i++) { Program.logToWindow("Checking row " + i + " for SteamID " + steamID.ToString() + ". Array values: ID: \n" + pugStatus.players[i, 0] + " Name: " + pugStatus.players[i, 1]); if (pugStatus.players[i, 0] == steamID.ToString()) { return i; } } return -1; }
public bool removePlayer(CSteamID steamID) { int playerIndex = GetPlayerIndex(steamID); if (playerIndex >= 0) { //player is in the pug string name = pugStatus.players[playerIndex, 1]; pugStatus.players[playerIndex, 0] = null; pugStatus.players[playerIndex, 1] = null; Program.logToFile("Removed " + name + " (" + steamID + ") from the pug"); this.sendBotCommand("REMOVEPLAYER!" + name + "!" + steamID.ToString()); pugStatus.numPlayers -= 1; return true; } return false; }
public int addPlayer(CSteamID steamID, string name) { int playerIndex = GetPlayerIndex(steamID); if (playerIndex >= 0) { //already in the pug return 2; //status code 2 indicates this } for (int i = 0; i < pugStatus.players.GetLength(0); i++) { if (pugStatus.players[i, 0] == null) { pugStatus.players[i, 0] = steamID.ToString(); pugStatus.players[i, 1] = name; Program.logToFile("Added " + name + " (" + steamID + ") to the pug"); this.sendBotCommand("ADDPLAYER!" + name + "!" + steamID.ToString()); pugStatus.numPlayers += 1; return 1; } } return 0; }