Beispiel #1
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            Server server = PluginManager.Manager.Server;

            bool isPlayer()
            {
                if (sender is Player pl)
                {
                    if (!string.IsNullOrEmpty(pl.SteamId))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            string ColoredBools(bool input)
            {
                if (isPlayer() && input)
                {
                    return("<color=green>" + input + "</color>");
                }
                else if (isPlayer() && !input)
                {
                    return("<color=red>" + input + "</color>");
                }
                else if (input)
                {
                    return(input.ToString() + " ");
                }
                else
                {
                    return(input.ToString());
                }
            }

            if (server.GetPlayers().Count > 0)
            {
                Player myPlayer = (args.Length > 0) ? GetPlayerFromString.GetPlayer(args[0]) : null;
                if (args.Length == 0)
                {
                    if (sender is Player sendingPlayer)
                    {
                        myPlayer = sendingPlayer;
                    }
                }
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                AdminToolbox.AddMissingPlayerVariables(new List <Player> {
                    myPlayer
                });
                AdminToolbox.AdminToolboxLogger.PlayerStatsFileManager(new List <Player> {
                    myPlayer
                }, LogHandlers.PlayerFile.Write);
                AdminToolbox.AdminToolboxPlayerSettings playerDict = (AdminToolbox.playerdict.ContainsKey(myPlayer.SteamId)) ? AdminToolbox.playerdict[myPlayer.SteamId] : new AdminToolbox.AdminToolboxPlayerSettings();
                int    remainingJailTime = ((int)playerDict.JailedToTime.Subtract(DateTime.Now).TotalSeconds >= 0) ? (int)playerDict.JailedToTime.Subtract(DateTime.Now).TotalSeconds : 0;
                string remoteAdmin       = "Player info: \n " +
                                           "\n Player: (" + myPlayer.PlayerId + ") " + myPlayer.Name +
                                           "\n - SteamID: " + myPlayer.SteamId + "   - IP: " + myPlayer.IpAddress.Replace("::ffff:", string.Empty) +
                                           "\n - Role: " + myPlayer.TeamRole.Role + "      - Health: " + myPlayer.GetHealth() +
                                           "\n - Server Rank: " + "<color=" + myPlayer.GetUserGroup().Color + ">" + myPlayer.GetRankName() + "</color>" +
                                           "\n - AdminToolbox Toggables: " +
                                           "\n     - Godmode: " + ColoredBools(playerDict.godMode) + "         - NoDmg: " + ColoredBools(playerDict.dmgOff) +
                                           "\n     - SpectatorOnly: " + ColoredBools(playerDict.spectatorOnly) + " - KeepSettings: " + ColoredBools(playerDict.keepSettings) +
                                           "\n     - BreakDoors: " + ColoredBools(playerDict.destroyDoor) + "      - PlayerLockDown: " + ColoredBools(playerDict.lockDown) +
                                           "\n     - InstantKill: " + ColoredBools(playerDict.instantKill) +
                                           "\n     - IsJailed: " + ColoredBools(playerDict.isJailed) + "        - Released In: " + remainingJailTime +
                                           "\n - Stats:" +
                                           "\n     - Kills: " + playerDict.Kills + "  - TeamKills: " + playerDict.TeamKills + "  - Deaths: " + playerDict.Deaths +
                                           "\n     - Rounds Played: " + playerDict.RoundsPlayed + "        - Playtime: " + (int)playerDict.minutesPlayed + " minutes" +
                                           "\n - Position:" +
                                           " - X:" + (int)myPlayer.GetPosition().x +
                                           "   Y:" + (int)myPlayer.GetPosition().y +
                                           "   Z:" + (int)myPlayer.GetPosition().z;
                string[] playerStrings = new string[]
                {
                    "\n Player: (" + myPlayer.PlayerId + ") " + myPlayer.Name,
                    " - SteamID: " + myPlayer.SteamId,
                    " - IP: " + myPlayer.IpAddress,
                    " - Server Rank: " + "<color=" + myPlayer.GetUserGroup().Color + ">" + myPlayer.GetRankName() + "</color>",
                    " - Role: " + myPlayer.TeamRole.Role,
                    " - Health: " + myPlayer.GetHealth(),
                    " - AdminToolbox Toggables: ",
                    "   - Godmode: " + ColoredBools(playerDict.godMode),
                    "   - NoDmg: " + ColoredBools(playerDict.dmgOff),
                    "   - SpectatorOnly: " + ColoredBools(playerDict.spectatorOnly),
                    "   - KeepSettings: " + ColoredBools(playerDict.keepSettings),
                    "   - BreakDoors: " + ColoredBools(playerDict.destroyDoor),
                    "   - PlayerLockDown: " + ColoredBools(playerDict.lockDown),
                    "   - InstantKill: " + ColoredBools(playerDict.instantKill),
                    "   - IsJailed: " + ColoredBools(playerDict.isJailed),
                    "   - Released In: " + remainingJailTime,
                    " - Stats:" +
                    "     - Kills: " + playerDict.Kills,
                    "     - TeamKills: " + playerDict.TeamKills,
                    "     - Deaths: " + playerDict.Deaths,
                    "     - Rounds Played: " + playerDict.RoundsPlayed,
                    "     - Playtime: " + playerDict.minutesPlayed + " minutes",
                    " - Position:",
                    "	  - X:"+ (int)myPlayer.GetPosition().x + " Y:" + (int)myPlayer.GetPosition().y + " Z:" + (int)myPlayer.GetPosition().z
                };
                //foreach (string str in playerStrings)
                //{
                //	_maxlen = Math.Max(_maxlen, str.Length);
                //}
                _maxlen = 29;
                string BuildTwoLiner(string str1, string str2 = "")
                {
                    return(StringToMax(str1, _maxlen) + "|" + StringToMax(str2, _maxlen).PadLeft(LeftPadding));
                }

                string serverConsole = "\n\nPlayer: (" + myPlayer.PlayerId + ") " + myPlayer.Name + Environment.NewLine +
                                       BuildTwoLiner(" - SteamID: " + myPlayer.SteamId, " - IP: " + myPlayer.IpAddress) + Environment.NewLine +
                                       BuildTwoLiner(" - Server Rank: " + "<color=" + myPlayer.GetUserGroup().Color + ">" + myPlayer.GetRankName() + "</color>") +
                                       BuildTwoLiner(" - Role: " + myPlayer.TeamRole.Role, " - Health: " + myPlayer.GetHealth()) + Environment.NewLine +
                                       BuildTwoLiner(" - AdminToolbox Toggables: ") + Environment.NewLine +
                                       BuildTwoLiner("   - Godmode: " + ColoredBools(playerDict.godMode), "  - NoDmg: " + ColoredBools(playerDict.dmgOff)) + Environment.NewLine +
                                       BuildTwoLiner("   - SpectatorOnly: " + ColoredBools(playerDict.spectatorOnly), "  - KeepSettings: " + ColoredBools(playerDict.keepSettings)) + Environment.NewLine +
                                       BuildTwoLiner("   - BreakDoors: " + ColoredBools(playerDict.destroyDoor), "  - PlayerLockDown: " + ColoredBools(playerDict.lockDown)) + Environment.NewLine +
                                       BuildTwoLiner("   - InstantKill: " + ColoredBools(playerDict.instantKill)) + Environment.NewLine +
                                       BuildTwoLiner("   - IsJailed: " + ColoredBools(playerDict.isJailed), " - Released In: " + remainingJailTime) + Environment.NewLine +
                                       BuildTwoLiner(" - Stats:") + Environment.NewLine +
                                       BuildTwoLiner("     - Kills: " + playerDict.Kills, " - TeamKills: " + playerDict.TeamKills) + Environment.NewLine +
                                       BuildTwoLiner("     - Deaths: " + playerDict.Deaths) + Environment.NewLine +
                                       BuildTwoLiner("     - Playtime: " + playerDict.minutesPlayed + " minutes", " - Rounds Played: " + playerDict.RoundsPlayed) + Environment.NewLine +
                                       BuildTwoLiner(" - Position:") + Environment.NewLine +
                                       BuildTwoLiner(" - X:" + (int)myPlayer.GetPosition().x + " Y:" + (int)myPlayer.GetPosition().y + " Z:" + (int)myPlayer.GetPosition().z) + Environment.NewLine;
                if (!isPlayer())
                {
                    return new string[] { serverConsole }
                }
                ;
                else
                {
                    return new string[] { remoteAdmin }
                };
            }
            return(new string[] { GetUsage() });
        }
    }
Beispiel #2
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            if (server.GetPlayers().Count > 0)
            {
                Player myPlayer = (args.Length > 0) ? GetPlayerFromString.GetPlayer(args[0]) : null;
                if (myPlayer == null && sender is Player sendingPlayer)
                {
                    myPlayer = sendingPlayer;
                }
                else if (myPlayer == null)
                {
                    if (args.Length > 0)
                    {
                        return new string[] { "Couldn't get player: " + args[0] }
                    }
                }
                ;
                else
                {
                    return new string[] { GetUsage() }
                };

                //Handling player stats
                AdminToolbox.AddMissingPlayerVariables(new List <Player> {
                    myPlayer
                });
                AdminToolbox.AdminToolboxLogger.PlayerStatsFileManager(new List <Player> {
                    myPlayer
                }, LogHandlers.PlayerFile.Write);
                AdminToolbox.AdminToolboxPlayerSettings playerDict = (AdminToolbox.playerdict.ContainsKey(myPlayer.SteamId)) ? AdminToolbox.playerdict[myPlayer.SteamId] : new AdminToolbox.AdminToolboxPlayerSettings();

                //Inventory
                string playerInv = string.Empty;
                myPlayer.GetInventory().ForEach(i => { if (i.ItemType != ItemType.NULL)
                                                       {
                                                           playerInv += i.ItemType + ", ";
                                                       }
                                                });
                if (playerInv == string.Empty)
                {
                    playerInv = "Empty Inventory";
                }

                //Calculating remaining jail time
                int remainingJailTime = ((int)playerDict.JailedToTime.Subtract(DateTime.Now).TotalSeconds >= 0) ? (int)playerDict.JailedToTime.Subtract(DateTime.Now).TotalSeconds : 0;

                //Building string
                string playerInfoString = Environment.NewLine + Environment.NewLine +
                                          "Player: (" + myPlayer.PlayerId + ") " + myPlayer.Name + Environment.NewLine +
                                          BuildTwoLiner(" - SteamID: " + myPlayer.SteamId, " - IP: " + myPlayer.IpAddress) + Environment.NewLine +
                                          BuildTwoLiner(" - Server Rank: " + "<color=" + myPlayer.GetUserGroup().Color + ">" + myPlayer.GetRankName() + "</color>") + Environment.NewLine +
                                          BuildTwoLiner(" - Role: " + myPlayer.TeamRole.Role, " - Health: " + myPlayer.GetHealth()) + Environment.NewLine +
                                          BuildTwoLiner(" - AdminToolbox Toggables: ") + Environment.NewLine +
                                          BuildTwoLiner("   - Godmode: " + (playerDict.godMode), " - NoDmg: " + (playerDict.dmgOff)) + Environment.NewLine +
                                          BuildTwoLiner("   - OverwatchMode: " + (myPlayer.OverwatchMode), " - KeepSettings: " + (playerDict.keepSettings)) + Environment.NewLine +
                                          BuildTwoLiner("   - BreakDoors: " + (playerDict.destroyDoor), " - PlayerLockDown: " + (playerDict.lockDown)) + Environment.NewLine +
                                          BuildTwoLiner("   - InstantKill: " + (playerDict.instantKill), " - GhostMode: " + myPlayer.GetGhostMode()) + Environment.NewLine +
                                          BuildTwoLiner("   - IsJailed: " + (playerDict.isJailed), " - Released In: " + remainingJailTime) + Environment.NewLine +
                                          BuildTwoLiner(" - Stats:") + Environment.NewLine +
                                          BuildTwoLiner("   - Kills: " + playerDict.Kills, " - TeamKills: " + playerDict.TeamKills) + Environment.NewLine +
                                          BuildTwoLiner("   - Deaths: " + playerDict.Deaths, " - Times Banned: " + playerDict.banCount) + Environment.NewLine +
                                          BuildTwoLiner("   - Playtime: " + (int)playerDict.minutesPlayed + " minutes", " - Rounds Played: " + playerDict.RoundsPlayed) + Environment.NewLine +
                                          BuildTwoLiner(" - Position:") + Environment.NewLine +
                                          BuildTwoLiner("  - X:" + (int)myPlayer.GetPosition().x + " Y:" + (int)myPlayer.GetPosition().y + " Z:" + (int)myPlayer.GetPosition().z) + Environment.NewLine +
                                          BuildTwoLiner(" - Inventory: " + playerInv) + Environment.NewLine;
                if (isPlayer(sender))
                {
                    return new string[] { playerInfoString.Replace("True", "<color=green>" + "True " + " </color>").Replace("False", "<color=red>" + "False" + "</color>") }
                }
                ;
                else
                {
                    return new string[] { playerInfoString }
                };
            }