Esempio n. 1
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            Player           caller   = (sender is Player send) ? send : null;
            Server           server   = PluginManager.Manager.Server;
            const DamageType killType = DamageType.NONE;

            AdminToolbox.AddMissingPlayerVariables();
            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    int playerNum = 0;
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (server.GetPlayers().Count > 1)
                        {
                            if (caller != null && pl.PlayerId == caller.PlayerId || (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].godMode) || pl.GetGodmode() /*|| (caller.GetUserGroup().Permissions < pl.GetUserGroup().Permissions)*/)
                            {
                                continue;
                            }
                        }
                        pl.Kill(killType);
                        playerNum++;
                    }
                    if (caller != null && !string.IsNullOrEmpty(caller.Name) && caller.Name.ToLower() != "server")
                    {
                        plugin.Info(caller.Name + " ran the \"SLAY\" command on: " + playerNum + " players");
                    }
                    return(new string[] { playerNum + " players has been slain!" });
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });
                }
                if (myPlayer.TeamRole.Role != Role.SPECTATOR)
                {
                    if (caller != null && !string.IsNullOrEmpty(caller.Name) && caller.Name.ToLower() != "server")
                    {
                        plugin.Info(caller.Name + " ran the \"SLAY\" command on: " + myPlayer.Name);
                    }
                    myPlayer.Kill(killType);
                    return(new string[] { myPlayer.Name + " has been slain!" });
                }
                else
                {
                    return new string[] { myPlayer.Name + " is already dead!" }
                };
            }
            else
            {
                return(new string[] { GetUsage() });
            }
        }
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 1)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    int    playerNum  = -1;
                    Player myTpPlayer = API.GetPlayerFromString.GetPlayer(args[1]);
                    if (myTpPlayer == null)
                    {
                        return(new string[] { "Couldn't find player: " + args[1] });;
                    }
                    Vector pos = myTpPlayer.GetPosition();
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (pl.PlayerId != myTpPlayer.PlayerId)
                        {
                            pl.Teleport(pos, true);
                            playerNum++;
                        }
                    }
                    return(new string[] { "Teleported " + playerNum + " players to " + myTpPlayer.Name });
                }
                Player myPlayer = API.GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't find player: " + args[0] });;
                }
                Player myPlayer2 = API.GetPlayerFromString.GetPlayer(args[1]);
                if (myPlayer2 == null)
                {
                    return(new string[] { "Couldn't find player: " + args[1] });;
                }
                if (args[1] != null)
                {
                    myPlayer.Teleport(myPlayer2.GetPosition(), true);
                    return(new string[] { "Teleported: " + myPlayer.Name + " to " + myPlayer2.Name });
                }
                else
                {
                    return new string[] { GetUsage() }
                };
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
Esempio n. 3
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                if (args.Length > 1)
                {
                    if (args[1].ToLower() == "open")
                    {
                        foreach (var item in server.Map.GetDoors())
                        {
                            item.Open = true;
                        }
                        return(new string[] { "Door Opened" });
                    }
                    else if (args[1].ToLower() == "close")
                    {
                        foreach (var item in server.Map.GetDoors())
                        {
                            item.Open = false;
                        }
                        return(new string[] { "Door Closed" });
                    }
                    else if (args[1].ToLower() == "lock")
                    {
                        return(new string[] { "Door Locked" });
                    }
                    else if (args[1].ToLower() == "unlock")
                    {
                        return(new string[] { "Door UnLocked" });
                    }
                    else
                    {
                        return new string[] { GetUsage() }
                    };
                }
                else
                {
                    return new string[] { GetUsage() }
                };
            }
            return(new string[] { GetUsage() });
        }
    }
Esempio n. 4
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 1)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    int    playerNum  = -1;
                    Player myTpPlayer = GetPlayerFromString.GetPlayer(args[1], out myTpPlayer);
                    if (myTpPlayer == null)
                    {
                        return(new string[] { "Couldn't find player: " + args[1] });;
                    }
                    foreach (Player pl in server.GetPlayers())
                    {
                        pl.Teleport(myTpPlayer.GetPosition());
                        playerNum++;
                    }
                    //plugin.Info("Teleported " + playerNum + " players to " + myTpPlayer.Name);
                    return(new string[] { "Teleported " + playerNum + " players to " + myTpPlayer.Name });
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't find player: " + args[0] });;
                }
                Player myPlayer2 = GetPlayerFromString.GetPlayer(args[1], out myPlayer2);
                if (myPlayer2 == null)
                {
                    return(new string[] { "Couldn't find player: " + args[1] });;
                }
                if (args[1] != null)
                {
                    myPlayer.Teleport(myPlayer2.GetPosition());
                    //plugin.Info("Teleported: " + myPlayer.Name + " to " + myPlayer2.Name /*+ " at " + System.DateTime.Now.ToString()*/);
                    return(new string[] { "Teleported: " + myPlayer.Name + " to " + myPlayer2.Name });
                }
                else
                {
                    return new string[] { GetUsage() }
                };
                //plugin.Info(GetUsage());
            }
            else
            {
                return(new string[] { GetUsage() });
                //plugin.Info(GetUsage());
            }
        }
Esempio n. 5
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
            }
            return(new string[] { GetUsage() });
        }
Esempio n. 6
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                AdminToolbox.AddMissingPlayerVariables(new System.Collections.Generic.List <Player> {
                    myPlayer
                });
            }
            return(new string[] { GetUsage() });
        }
Esempio n. 7
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (AdminToolbox.warpVectors.Count < 1)
            {
                return(new string[] { "No warp points created yet!" });
            }
            string        str  = "\n" + "Warp Points:";
            List <string> list = AdminToolbox.warpVectors.Keys.ToList();

            list.Sort();
            foreach (string i in list)
            {
                str += "\n - " + i;
            }
            return(new string[] { str });
        }
Esempio n. 8
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Player caller = (sender is Player send) ? send : null;
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    int playerNum = 0;
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (caller != null && (pl.PlayerId == caller.PlayerId) || (AdminToolbox.playerdict[pl.SteamId].godMode || pl.GetGodmode()) /*|| (caller.GetUserGroup().Permissions < pl.GetUserGroup().Permissions)*/)
                        {
                            continue;
                        }
                        pl.Kill();
                        playerNum++;
                    }
                    return(new string[] { playerNum + " players has been slain!" });
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });
                }
                if (myPlayer.TeamRole.Role != Role.SPECTATOR)
                {
                    myPlayer.Kill();
                    return(new string[] { myPlayer + " has been slain!" });
                }
                else
                {
                    return new string[] { myPlayer + " is already dead!" }
                };
            }
            else
            {
                return(new string[] { GetUsage() });
            }
        }
Esempio n. 9
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0 && server.GetPlayers().Count > 0)
            {
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                string x = "Player info: \n " +
                           "\n Player: " + myPlayer.Name +
                           "\n - SteamID: " + myPlayer.SteamId +
                           "\n - Health: " + myPlayer.GetHealth() +
                           "\n - Role: " + myPlayer.TeamRole.Role +
                           "\n - Server Rank: " + myPlayer.GetRankName() +
                           "\n - AdminToolbox Toggables: " +
                           "\n     - SpectatorOnly: " + AdminToolbox.playerdict[myPlayer.SteamId][0] +
                           "\n     - Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId][1] +
                           "\n     - NoDmg: " + AdminToolbox.playerdict[myPlayer.SteamId][2] +
                           "\n     - BreakDoors: " + AdminToolbox.playerdict[myPlayer.SteamId][3] +
                           "\n     - KeepSettings: " + AdminToolbox.playerdict[myPlayer.SteamId][4] +
                           "\n     - PlayerLockDown: " + AdminToolbox.playerdict[myPlayer.SteamId][5] +
                           "\n     - InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId][6] +
                           "\n - Stats:" +
                           "\n     - Kills: " + AdminToolbox.playerStats[myPlayer.SteamId][0] +
                           "\n     - TeamKills: " + AdminToolbox.playerStats[myPlayer.SteamId][1] +
                           "\n     - Deaths: " + AdminToolbox.playerStats[myPlayer.SteamId][2] +
                           "\n     - Rounds Played: " + AdminToolbox.playerStats[myPlayer.SteamId][3] +
                           "\n - Position:" +
                           " - X:" + (int)myPlayer.GetPosition().x +
                           " - Y:" + (int)myPlayer.GetPosition().y +
                           " - Z:" + (int)myPlayer.GetPosition().z;
                //plugin.Info(x);
                return(new string[] { x });
            }
            return(new string[] { GetUsage() });
        }
Esempio n. 10
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (bool.TryParse(args[0], out bool k))
                {
                    AdminToolbox.lockRound = k;
                    plugin.Info("Round lock: " + k);
                    return(new string[] { "Round lock: " + k });
                }
                else if (Int32.TryParse(args[0], out int l))
                {
                    if (l < 1)
                    {
                        AdminToolbox.lockRound = false;
                        plugin.Info("Round lock: " + AdminToolbox.lockRound);
                        return(new string[] { "Round lock: " + AdminToolbox.lockRound });
                    }
                    else
                    {
                        AdminToolbox.lockRound = true;
                        plugin.Info("Round lock: " + AdminToolbox.lockRound);
                        return(new string[] { "Round lock: " + AdminToolbox.lockRound });
                    }
                }
                else
                {
                    return new string[] { GetUsage() }
                };
            }
            else
            {
                AdminToolbox.lockRound = !AdminToolbox.lockRound;
                plugin.Info("Round lock: " + AdminToolbox.lockRound);
                return(new string[] { "Round lock: " + AdminToolbox.lockRound });
            }
        }
Esempio n. 11
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "list")
                {
                    if (AdminToolbox.warpVectors.Count < 1)
                    {
                        return(new string[] { "No warp points created yet!" });
                    }
                    string        str  = "\n" + "Warp Points:";
                    List <string> list = AdminToolbox.warpVectors.Keys.ToList();
                    list.Sort();
                    foreach (string i in list)
                    {
                        str += "\n - " + i;
                    }
                    return(new string[] { str });
                }
                else if (args[0].ToLower() == "remove" || args[0].ToLower() == "-")
                {
                    if (AdminToolbox.warpVectors.ContainsKey(args[1].ToLower()))
                    {
                        AdminToolbox.warpVectors.Remove(args[1].ToLower());
                        return(new string[] { "Warp point: " + args[1].ToLower() + " removed." });
                    }
                    else
                    {
                        return new string[] { "Warp point " + args[1].ToLower() + " does not exist!" }
                    };
                }
                else if (args[0].ToLower() == "add" || args[0].ToLower() == "+")
                {
                    if (args.Length > 2)
                    {
                        if (!AdminToolbox.warpVectors.ContainsKey(args[2]))
                        {
                            Player myPlayer = GetPlayerFromString.GetPlayer(args[1]);
                            if (myPlayer == null)
                            {
                                return(new string[] { "Couldn't get player: " + args[1] });;
                            }
                            Vector myvector = myPlayer.GetPosition();
                            AdminToolbox.warpVectors.Add(args[2].ToLower(), myvector);
                            return(new string[] { "Warp point: " + args[2].ToLower() + " added." });
                        }
                        else
                        {
                            return new string[] { "A warp point named: " + args[2].ToLower() + " already exists!" }
                        };
                    }
                    else
                    {
                        return new string[] { GetUsage() }
                    };
                }
                else
                {
                    if (args.Length > 1)
                    {
                        if (args[0] == "*")
                        {
                            if (server.GetPlayers().Count == 0)
                            {
                                return new string[] { "No players to teleport!" }
                            }
                            ;
                            else if (!AdminToolbox.warpVectors.ContainsKey(args[1].ToLower()))
                            {
                                return new string[] { "No warp point called: " + args[1] }
                            }
                            ;
                            byte playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                pl.Teleport(AdminToolbox.warpVectors[args[1].ToLower()]);

                                playerNum++;
                            }
                            return(new string[] { "Teleported " + playerNum + " players to warp point: " + args[1] });
                        }
                        Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);

                        if (myPlayer == null)
                        {
                            return(new string[] { "Couldn't get player: " + args[0] });;
                        }
                        if (!AdminToolbox.warpVectors.ContainsKey(args[1].ToLower()))
                        {
                            return new string[] { "No warp point called: " + args[1] }
                        }
                        ;
                        myPlayer.Teleport(AdminToolbox.warpVectors[args[1].ToLower()]);
                        return(new string[] { "Teleported: " + myPlayer.Name + " to warp point: " + args[1] });
                    }
                    else
                    {
                        return new string[] { GetUsage() }
                    };
                }
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
}
Esempio n. 12
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            if (!ConfigManager.Manager.Config.GetBoolValue("sm_enable_ghostmode", false))
            {
                return new string[] { "\"sm_enable_ghostmode\" needs to be set TRUE to use this!" }
            }
            ;
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length == 0 && sender is Player p)
            {
                p.SetGhostMode(!p.GetGhostMode());

                return(new string[]
                {
                    "\nSet " + p.Name + " 's GhostMode to:" +
                    "\n - Enabled: " + p.GetGhostMode() +
                    "\n - Visible to specators: " + true +
                    "\n - Visible while talking: " + true
                });
            }
            if (args.Length > 0)
            {
                if (args[0].ToLower() == "help")
                {
                    return new string[] { GetUsage() }
                }
                ;
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        if (bool.TryParse(args[1], out bool state))
                        {
                            bool   visibleTospec  = (args.Length > 2 && bool.TryParse(args[2], out bool xvis)) ? xvis : true;
                            bool   visibleTalking = (args.Length > 3 && bool.TryParse(args[3], out bool xtalk)) ? xtalk : true;
                            string outPut         = string.Empty;
                            int    playerNum      = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                pl.SetGhostMode(state, visibleTospec, visibleTalking);
                                playerNum++;
                            }
                            if (state)
                            {
                                outPut += "\nSet " + playerNum + " player's GhostMode to:"
                                          + "\n - Enabled: " + state
                                          + "\n - Visible to specators: " + visibleTospec
                                          + "\n - Visible while talking: " + visibleTalking;
                            }
                            else
                            {
                                outPut += "\nSet " + playerNum + " player's GhostMode to " + state;
                            }
                            return(new string[] { outPut });
                        }
                        else
                        {
                            return new string[] { "Not a valid bool!" }
                        };
                    }
                    else
                    {
                        foreach (Player ply in server.GetPlayers())
                        {
                            ply.SetGhostMode(!ply.GetGhostMode());
                        }
                        return(new string[] { "Toggled all players GhostMode!" });
                    }
                }
                else if (args[0].ToLower() == "list" || args[0].ToLower() == "get")
                {
                    string str = "\nPlayers with GhostMode enabled: \n";

                    List <string> myPlayerList = new List <string>();

                    foreach (Player pl in server.GetPlayers())
                    {
                        if (pl.GetGhostMode())
                        {
                            myPlayerList.Add(pl.Name);
                        }
                    }

                    if (myPlayerList.Count > 0)
                    {
                        myPlayerList.Sort();
                        foreach (var item in myPlayerList)
                        {
                            str += "\n - " + item;
                        }
                    }
                    else
                    {
                        str = "\nNo players with \"GhostMode\" enabled!";
                    }
                    return(new string[] { str });
                }
                Player myPlayer = API.GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't find player: " + args[0] });
                }
                if (args.Length > 1)
                {
                    if (bool.TryParse(args[1], out bool state))
                    {
                        bool   visibleTospec  = (args.Length > 2 && bool.TryParse(args[2], out bool xvis)) ? xvis : true;
                        bool   visibleTalking = (args.Length > 3 && bool.TryParse(args[3], out bool xtalk)) ? xtalk : true;
                        string outPut         = string.Empty;

                        myPlayer.SetGhostMode(state, visibleTospec, visibleTalking);

                        if (state)
                        {
                            outPut += "\nSet " + myPlayer.Name + " GhostMode to:"
                                      + "\n - Enabled: " + state
                                      + "\n - Visible to specators: " + visibleTospec
                                      + "\n - Visible while talking: " + visibleTalking;
                        }
                        else
                        {
                            outPut += "\nSet " + myPlayer.Name + " GhostMode to " + state;
                        }
                        return(new string[] { outPut });
                    }
                    else
                    {
                        return new string[] { "Not a valid bool!" }
                    };
                }
                else
                {
                    myPlayer.SetGhostMode(!myPlayer.GetGhostMode());
                    return(new string[] { myPlayer.Name + " GhostMode toggled to: " + myPlayer.GetGhostMode() });
                }
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
}
Esempio n. 13
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            Server server = PluginManager.Manager.Server;
            int    max    = Enum.GetValues(typeof(ItemType)).Cast <int>().Max(),
                   min    = Enum.GetValues(typeof(ItemType)).Cast <int>().Min() + 1;

            if (args.Length > 0)
            {
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                if (myPlayer.TeamRole.Role == Role.UNASSIGNED)
                {
                    return new string[] { "Player not properly initialized!" }
                }
                ;
                if (myPlayer.TeamRole.Role == Role.SPECTATOR)
                {
                    return new string[] { "This can not be used on spectators!" }
                }
                ;
                AdminToolbox.AddMissingPlayerVariables(myPlayer);

                byte     itemNumber = 0;
                Vector   pos = myPlayer.GetPosition(), rot = myPlayer.GetRotation();
                string[] deleteAliases = { "delete", "del", "d" };
                if (args.Length > 1 && deleteAliases.Contains(args[1].ToLower()))
                {
                    foreach (Smod2.API.Item item in myPlayer.GetInventory().Where(i => i.ItemType != ItemType.NULL))
                    {
                        item.Remove(); itemNumber++;
                    }
                    foreach (int a in Enum.GetValues(typeof(AmmoType)))
                    {
                        myPlayer.SetAmmo((AmmoType)a, 0);
                    }
                    return(new string[] { "Deleted " + itemNumber + " items from player " + myPlayer.Name + "'s inventory" });
                }
                else if (args.Length > 1 && byte.TryParse(args[1], out byte itemInt) && itemInt <= max && itemInt >= min)
                {
                    if (args.Length > 2 && deleteAliases.Contains(args[2].ToLower()))
                    {
                        foreach (Smod2.API.Item item in myPlayer.GetInventory())
                        {
                            if ((byte)item.ItemType == itemInt)
                            {
                                item.Remove(); itemNumber++;
                            }
                        }
                        return(new string[] { "Deleted all \"" + Enum.GetName(typeof(ItemType), itemInt) + "\" items from player " + myPlayer.Name + "'s inventory" });
                    }
                    else
                    {
                        foreach (Smod2.API.Item item in myPlayer.GetInventory())
                        {
                            if ((byte)item.ItemType == itemInt)
                            {
                                item.Drop(); itemNumber++;
                            }
                        }
                        return(new string[] { "Dropped all \"" + Enum.GetName(typeof(ItemType), itemInt) + "\" items from player " + myPlayer.Name + "'s inventory" });
                    }
                }
                else
                {
                    foreach (Smod2.API.Item item in myPlayer.GetInventory().Where(i => i.ItemType != ItemType.NULL))
                    {
                        item.Drop(); itemNumber++;
                    }
                    Map.SpawnItem(ItemType.DROPPED_5, pos, rot);
                    Map.SpawnItem(ItemType.DROPPED_7, pos, rot);
                    Map.SpawnItem(ItemType.DROPPED_9, pos, rot);
                    foreach (int a in Enum.GetValues(typeof(AmmoType)))
                    {
                        myPlayer.SetAmmo((AmmoType)a, 0);
                    }
                    return(new string[] { "Dropped " + itemNumber + " items from player " + myPlayer.Name + "'s inventory" });
                }
            }
            else if (sender is Player p && p != null)
            {
                int    itemNumber = 0;
                Vector pos = p.GetPosition(), rot = p.GetRotation();
                foreach (Smod2.API.Item item in p.GetInventory().Where(i => i.ItemType != ItemType.NULL))
                {
                    item.Drop(); itemNumber++;
                }
                Map.SpawnItem(ItemType.DROPPED_5, pos, rot);
                Map.SpawnItem(ItemType.DROPPED_7, pos, rot);
                Map.SpawnItem(ItemType.DROPPED_9, pos, rot);
                foreach (int a in Enum.GetValues(typeof(AmmoType)))
                {
                    p.SetAmmo((AmmoType)a, 0);
                }
                return(new string[] { "Dropped " + itemNumber + " items from player " + p.Name + "'s inventory" });
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
}
Esempio n. 14
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                AdminToolbox.AddMissingPlayerVariables(new List <Player> {
                    myPlayer
                });
                if (sender is Player p)
                {
                    AdminToolbox.AddMissingPlayerVariables(new List <Player> {
                        p
                    });
                }
                byte     itemNumber    = 0;
                string[] deleteAliases = { "delete", "del", "d" };
                if (args.Length > 1 && deleteAliases.Contains(args[1].ToLower()))
                {
                    foreach (Smod2.API.Item item in myPlayer.GetInventory())
                    {
                        if (item.ItemType != ItemType.NULL)
                        {
                            item.Remove(); itemNumber++;
                        }
                    }
                    myPlayer.SetAmmo(AmmoType.DROPPED_5, 0);
                    myPlayer.SetAmmo(AmmoType.DROPPED_7, 0);
                    myPlayer.SetAmmo(AmmoType.DROPPED_9, 0);
                    return(new string[] { "Deleted " + itemNumber + " items from player " + myPlayer.Name + "'s inventory" });
                }
                else if (args.Length > 1 && byte.TryParse(args[1], out byte itemInt))
                {
                    if (args.Length > 2 && deleteAliases.Contains(args[2].ToLower()))
                    {
                        foreach (Smod2.API.Item item in myPlayer.GetInventory())
                        {
                            if ((byte)item.ItemType == itemInt)
                            {
                                item.Remove(); itemNumber++;
                            }
                        }
                        return(new string[] { "Deleted all \"" + Enum.GetName(typeof(ItemType), itemInt) + "\" items from player " + myPlayer.Name + "'s inventory" });
                    }
                    else
                    {
                        foreach (Smod2.API.Item item in myPlayer.GetInventory())
                        {
                            if ((byte)item.ItemType == itemInt)
                            {
                                item.Drop(); itemNumber++;
                            }
                        }
                        return(new string[] { "Dropped all \"" + Enum.GetName(typeof(ItemType), itemInt) + "\" items from player " + myPlayer.Name + "'s inventory" });
                    }
                }
                else
                {
                    foreach (Smod2.API.Item item in myPlayer.GetInventory())
                    {
                        if (item.ItemType != ItemType.NULL)
                        {
                            item.Drop(); itemNumber++;
                        }
                    }
                    PluginManager.Manager.Server.Map.SpawnItem(ItemType.DROPPED_5, myPlayer.GetPosition(), myPlayer.GetRotation());
                    PluginManager.Manager.Server.Map.SpawnItem(ItemType.DROPPED_7, myPlayer.GetPosition(), myPlayer.GetRotation());
                    PluginManager.Manager.Server.Map.SpawnItem(ItemType.DROPPED_9, myPlayer.GetPosition(), myPlayer.GetRotation());
                    myPlayer.SetAmmo(AmmoType.DROPPED_5, 0);
                    myPlayer.SetAmmo(AmmoType.DROPPED_5, 0);
                    myPlayer.SetAmmo(AmmoType.DROPPED_5, 0);
                    return(new string[] { "Dropped " + itemNumber + " items from player " + myPlayer.Name + "'s inventory" });
                }
            }
            return(new string[] { GetUsage() });
        }
Esempio n. 15
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        if (Int32.TryParse(args[1], out int j))
                        {
                            int playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                Vector originalPos = pl.GetPosition();
                                if (pl.TeamRole.Role == Role.UNASSIGNED || pl.TeamRole.Role == Role.SPECTATOR)
                                {
                                    pl.ChangeRole((Role)j, true, true);
                                }
                                else
                                {
                                    pl.ChangeRole((Role)j, true, false);
                                    pl.Teleport(originalPos);
                                }
                                pl.SetHealth(pl.TeamRole.MaxHP);
                                playerNum++;
                            }
                            if (playerNum > 1)
                            {
                                return new string[] { playerNum + " roles set to " + (Role)j }
                            }
                            ;
                            else
                            {
                                return new string[] { playerNum + " role set to " + (Role)j }
                            };
                        }
                        else
                        {
                            return(new string[] { "Not a valid ID number!" });
                        }
                    }
                    else
                    {
                        return(new string[] { GetUsage() });
                    }
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                if (args.Length > 1)
                {
                    int j;
                    if (Int32.TryParse(args[1], out j))
                    {
                        TeamRole oldRole     = myPlayer.TeamRole;
                        Vector   originalPos = myPlayer.GetPosition();
                        if (myPlayer.TeamRole.Role == Role.UNASSIGNED || myPlayer.TeamRole.Role == Role.SPECTATOR)
                        {
                            myPlayer.ChangeRole((Role)j, true, true);
                        }
                        else
                        {
                            myPlayer.ChangeRole((Role)j, true, false);
                            myPlayer.Teleport(originalPos);
                        }
                        myPlayer.SetHealth(myPlayer.TeamRole.MaxHP);
                        return(new string[] { "Changed " + myPlayer.Name + " from " + oldRole.Name + " to " + (Role)j });
                    }
                    else
                    {
                        return new string[] { "Not a valid ID number!" }
                    };
                }
                else
                {
                    return(new string[] { GetUsage() });
                }
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
Esempio n. 16
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        if (bool.TryParse(args[1], out bool j))
                        {
                            string outPut    = null;
                            int    playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                AdminToolbox.playerdict[pl.SteamId][3] = j;
                                playerNum++;
                            }
                            outPut += "\nSet " + playerNum + " player's BreakDoors to " + j;
                            return(new string[] { "\nSet " + playerNum + " player's BreakDoors to " + j });
                        }
                        else
                        {
                            //plugin.Info("Not a valid bool!");
                            return(new string[] { "Not a valid bool!" });
                        }
                    }
                    else
                    {
                        foreach (Player pl in server.GetPlayers())
                        {
                            AdminToolbox.playerdict[pl.SteamId][3] = !AdminToolbox.playerdict[pl.SteamId][3];
                        }
                        //plugin.Info("Toggled all players godmodes");
                        return(new string[] { "Toggled all players BreakDoors" });
                    }
                }
                else if (args[0].ToLower() == "list" || args[0].ToLower() == "get")
                {
                    string        str          = "\nPlayers with BreakDoors enabled: \n";
                    List <string> myPlayerList = new List <string>();
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (AdminToolbox.playerdict[pl.SteamId][3])
                        {
                            myPlayerList.Add(pl.Name);
                            //str += " - " +pl.Name + "\n";
                        }
                    }
                    if (myPlayerList.Count > 0)
                    {
                        myPlayerList.Sort();
                        foreach (var item in myPlayerList)
                        {
                            str += "\n - " + item;
                        }
                    }
                    else
                    {
                        str = "\nNo players with \"BreakDoors\" enabled!";
                    }
                    return(new string[] { str });
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't find player: " + args[0] });
                }
                if (args.Length > 1)
                {
                    if (args[1].ToLower() == "on" || args[1].ToLower() == "true")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId][3] = true;
                    }
                    else if (args[1].ToLower() == "off" || args[1].ToLower() == "false")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId][3] = false;
                    }
                    return(new string[] { myPlayer.Name + " BreakDoors: " + AdminToolbox.playerdict[myPlayer.SteamId][3] });
                }
                else
                {
                    AdminToolbox.playerdict[myPlayer.SteamId][3] = !AdminToolbox.playerdict[myPlayer.SteamId][3];
                    return(new string[] { myPlayer.Name + " BreakDoors: " + AdminToolbox.playerdict[myPlayer.SteamId][3] });
                }
            }
            return(new string[] { GetUsage() });
        }
Esempio n. 17
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            if (Server.GetPlayers().Count > 0)
            {
                Player myPlayer = (args.Length > 0) ? API.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[] { "Could not find player: " + args[0] }
                    }
                }
                ;
                else
                {
                    return new string[] { GetUsage() }
                };

                //Handling player stats
                AdminToolbox.AddMissingPlayerVariables(new List <Player> {
                    myPlayer
                });
                AdminToolbox.atfileManager.PlayerStatsFileManager(new List <Player> {
                    myPlayer
                }, Managers.ATFileManager.PlayerFile.Write);
                API.PlayerSettings playerDict = (AdminToolbox.ATPlayerDict.ContainsKey(myPlayer.SteamId)) ? AdminToolbox.ATPlayerDict[myPlayer.SteamId] : new API.PlayerSettings(myPlayer.SteamId);

                //Inventory
                string playerInv = string.Empty;
                foreach (Smod2.API.Item i in myPlayer.GetInventory().Where(i => 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;

                string _playerRole = (IsPlayer(sender)) ? ColoredRole(myPlayer) : myPlayer.TeamRole.Role + "";

                //Building string
                string playerInfoString = Environment.NewLine + Environment.NewLine +
                                          "Player: (" + myPlayer.PlayerId + ") " + myPlayer.Name + Environment.NewLine +
                                          BuildTwoLiner(" - SteamID: " + myPlayer.SteamId, " - IP: " + myPlayer.IpAddress.Replace("::ffff:", string.Empty)) + Environment.NewLine +
                                          BuildTwoLiner(" - Server Rank: " + "<color=" + myPlayer.GetUserGroup().Color + ">" + myPlayer.GetRankName() + "</color>") + Environment.NewLine +
                                          BuildTwoLiner(" - Role: " + _playerRole, " - 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 }
                };
            }
Esempio n. 18
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        if (bool.TryParse(args[1], out bool j))
                        {
                            string outPut       = null;
                            bool   changedState = false;
                            if (args.Length > 2)
                            {
                                if (args[2].ToLower() == "nodmg")
                                {
                                    noDmg = j; changedState = true;
                                }
                            }
                            int playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                AdminToolbox.playerdict[pl.SteamId][1] = j;
                                if (changedState)
                                {
                                    AdminToolbox.playerdict[pl.SteamId][2] = j;
                                }
                                playerNum++;
                            }
                            outPut += "\nSet " + playerNum + " player's Godmode to " + j;
                            //plugin.Info("Set " + playerNum + " player's Godmode to " + j);
                            if (changedState) /*plugin.Info("\nNoDmg for theese " + playerNum + " players set to: " + j);*/ return {
                                (new string[] { "\nSet " + playerNum + " player's Godmode to " + j, "\nNoDmg for theese " + playerNum + " players set to: " + j });
                            }
                            return(new string[] { "\nSet " + playerNum + " player's Godmode to " + j });
                        }
                        else
                        {
                            //plugin.Info("Not a valid bool!");
                            return(new string[] { "Not a valid bool!" });
                        }
                    }
                    else
                    {
                        foreach (Player pl in server.GetPlayers())
                        {
                            AdminToolbox.playerdict[pl.SteamId][1] = !AdminToolbox.playerdict[pl.SteamId][1];
                        }
                        //plugin.Info("Toggled all players godmodes");
                        return(new string[] { "Toggled all players godmodes" });
                    }
                }
                else if (args[0].ToLower() == "list" || args[0].ToLower() == "get")
                {
                    string        str          = "\nPlayers with Godmode enabled: \n";
                    List <string> myPlayerList = new List <string>();
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (AdminToolbox.playerdict[pl.SteamId][1])
                        {
                            myPlayerList.Add(pl.Name);
                            //str += " - " +pl.Name + "\n";
                        }
                    }
                    if (myPlayerList.Count > 0)
                    {
                        myPlayerList.Sort();
                        foreach (var item in myPlayerList)
                        {
                            str += "\n - " + item;
                        }
                    }
                    else
                    {
                        str = "\nNo players with \"Godmode\" enabled!";
                    }
                    //plugin.Info(str);
                    return(new string[] { str });
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null) /*plugin.Info("Couldn't find player: " + args[0]);*/ return {
                    (new string[] { "Couldn't find player: " + args[0] });
                }
                if (args.Length > 1)
                {
                    bool changedValue = false;
                    if (args.Length > 2)
                    {
                        if (args[2].ToLower() == "nodmg")
                        {
                            changedValue = true;
                        }
                    }
                    if (args[1].ToLower() == "on" || args[1].ToLower() == "true")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId][1] = true;
                    }
                    else if (args[1].ToLower() == "off" || args[1].ToLower() == "false")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId][1] = false;
                    }
                    //plugin.Info(myPlayer.Name + " godmode: " + AdminToolbox.playerdict[myPlayer.SteamId][1]);
                    if (changedValue)
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId][2] = AdminToolbox.playerdict[myPlayer.SteamId][1];
                        //plugin.Info(myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId][2]);
                        return(new string[] { myPlayer.Name + " godmode: " + AdminToolbox.playerdict[myPlayer.SteamId][1], myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId][2] });
                    }
                    else
                    {
                        return new string[] { myPlayer.Name + " godmode: " + AdminToolbox.playerdict[myPlayer.SteamId][1] }
                    };
                }
                else
                {
                    AdminToolbox.playerdict[myPlayer.SteamId][1] = !AdminToolbox.playerdict[myPlayer.SteamId][1];
                    //plugin.Info(myPlayer.Name + " Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId][1]);
                    return(new string[] { myPlayer.Name + " Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId][1] });
                }
            }
            else
            {
                return(new string[] { GetUsage() });
                //plugin.Info(GetUsage());
            }
        }
Esempio n. 19
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        int j;
                        if (Int32.TryParse(args[1], out j))
                        {
                            int playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                pl.ChangeRole(Role.TUTORIAL);
                                playerNum++;
                            }
                            if (playerNum > 1)
                            {
                                return new string[] { playerNum + " roles set to " + (Role)14 }
                            }
                            ;
                            //plugin.Info(playerNum + " roles set to " + (Role)14);
                            else
                            {
                                return new string[] { playerNum + " role set to " + (Role)14 }
                            };
                            //plugin.Info(playerNum + " role set to " + (Role)14);
                        }
                        else
                        {
                            //plugin.Info("Not a valid number!");
                            return(new string[] { "Not a valid number!" });
                        }
                    }
                    else
                    {
                        foreach (Player pl in server.GetPlayers())
                        {
                            pl.ChangeRole(Role.TUTORIAL);
                        }
                        //plugin.Info("Changed all players to " + Role.TUTORIAL);
                        return(new string[] { "Changed all players to " + Role.TUTORIAL });
                    }
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                Vector originalPos = myPlayer.GetPosition();
                //plugin.Info("Set " + myPlayer.Name + " to TUTORIAL");
                myPlayer.ChangeRole(Role.TUTORIAL);
                myPlayer.Teleport(originalPos);
                return(new string[] { "Set " + myPlayer.Name + " to TUTORIAL" });
            }
            else
            {
                return new string[] { GetUsage() }
            };
            //plugin.Info(GetUsage());
        }
    }
Esempio n. 20
0
        /// <summary>
        /// Read/Writes stats to/from <see cref="File"/> for each steamID in the <see cref="List{T}"/>
        /// </summary>
        public void PlayerStatsFileManager(List <string> steamIdList, PlayerFile FileOperation = PlayerFile.Read)
        {
            if (Directory.Exists(FileManager.GetAppFolder()))
            {
                char splitChar = ';';
                if (!Directory.Exists(AdminToolboxFolder))
                {
                    Directory.CreateDirectory(AdminToolboxFolder);
                }
                if (!Directory.Exists(AdminToolboxPlayerStats))
                {
                    Directory.CreateDirectory(AdminToolboxPlayerStats);
                }

                if (steamIdList != null && steamIdList.Count > 0)
                {
                    foreach (string sid in steamIdList)
                    {
                        ReadWriteHandler(sid, FileOperation);
                    }
                }
                else
                {
                    foreach (string steamID in AdminToolbox.ATPlayerDict.Keys)
                    {
                        ReadWriteHandler(steamID, FileOperation);
                    }
                }

                void ReadWriteHandler(string steamID, PlayerFile Operation)
                {
                    if (string.IsNullOrEmpty(steamID))
                    {
                        return;
                    }
                    if (!AdminToolbox.ATPlayerDict.ContainsKey(steamID))
                    {
                        AdminToolbox.AddMissingPlayerVariables(PluginManager.Manager.Server.GetPlayers(steamID));
                        return;
                    }
                    ;
                    switch (Operation)
                    {
                    case PlayerFile.Read:
                        ReadFromFile(steamID);
                        break;

                    case PlayerFile.Write:
                        WriteToFile(steamID);
                        break;

                    default:
                        ReadFromFile(steamID);
                        break;
                    }
                }

                void WriteToFile(string steamID)
                {
                    if (!AdminToolbox.ATPlayerDict.ContainsKey(steamID))
                    {
                        if (PluginManager.Manager.Server.GetPlayers(steamID).Count < 1)
                        {
                            return;
                        }
                        AdminToolbox.AddMissingPlayerVariables(PluginManager.Manager.Server.GetPlayers(steamID).FirstOrDefault());
                    }
                    if (!AdminToolbox.ATPlayerDict.ContainsKey(steamID))
                    {
                        return;
                    }
                    string playerFilePath = (AdminToolbox.ATPlayerDict.ContainsKey(steamID)) ? AdminToolboxPlayerStats + Path.DirectorySeparatorChar + steamID + ".txt" : AdminToolboxPlayerStats + Path.DirectorySeparatorChar + "server" + ".txt";

                    if (!File.Exists(playerFilePath))
                    {
                        File.Create(playerFilePath).Dispose();
                    }

                    API.PlayerSettings setting = (AdminToolbox.ATPlayerDict.ContainsKey(steamID)) ? AdminToolbox.ATPlayerDict[steamID] : new API.PlayerSettings(steamID);
                    int    Kills         = (AdminToolbox.ATPlayerDict.ContainsKey(steamID) && AdminToolbox.ATPlayerDict[steamID].Kills > 0) ? AdminToolbox.ATPlayerDict[steamID].Kills : 0;
                    int    TeamKills     = (AdminToolbox.ATPlayerDict.ContainsKey(steamID) && AdminToolbox.ATPlayerDict[steamID].TeamKills > 0) ? AdminToolbox.ATPlayerDict[steamID].TeamKills : 0;
                    int    Deaths        = (AdminToolbox.ATPlayerDict.ContainsKey(steamID) && AdminToolbox.ATPlayerDict[steamID].Deaths > 0) ? AdminToolbox.ATPlayerDict[steamID].Deaths : 0;
                    double minutesPlayed = (AdminToolbox.ATPlayerDict.ContainsKey(steamID) && AdminToolbox.ATPlayerDict[steamID].MinutesPlayed > 0) ? DateTime.Now.Subtract(AdminToolbox.ATPlayerDict[steamID].JoinTime).TotalMinutes + AdminToolbox.ATPlayerDict[steamID].MinutesPlayed : 0;
                    int    BanCount      = (AdminToolbox.ATPlayerDict.ContainsKey(steamID) && AdminToolbox.ATPlayerDict[steamID].banCount > 0) ? AdminToolbox.ATPlayerDict[steamID].banCount : 0;

                    if (AdminToolbox.ATPlayerDict.ContainsKey(steamID))
                    {
                        AdminToolbox.ATPlayerDict[steamID].JoinTime = DateTime.Now;
                    }
                    string str = string.Empty + Kills + splitChar + TeamKills + splitChar + Deaths + splitChar + minutesPlayed + splitChar + BanCount;

                    using (StreamWriter streamWriter = new StreamWriter(playerFilePath, false))
                    {
                        streamWriter.Write(str);
                        streamWriter.Close();
                    }
                    ReadFromFile(steamID);
                }

                void ReadFromFile(string steamID)
                {
                    string playerFilePath = (AdminToolbox.ATPlayerDict.ContainsKey(steamID)) ? AdminToolboxPlayerStats + Path.DirectorySeparatorChar + steamID + ".txt" : AdminToolboxPlayerStats + Path.DirectorySeparatorChar + "server" + ".txt";

                    if (!File.Exists(playerFilePath))
                    {
                        PlayerStatsFileManager(new List <string> {
                            steamID
                        }, PlayerFile.Write);
                    }
                    string[] fileStrings = (File.ReadAllLines(playerFilePath).Length > 0) ? File.ReadAllLines(playerFilePath) : new string[] { "0;0;0;0;0" };
                    string[] playerStats = fileStrings.FirstOrDefault().Split(splitChar);
                    if (AdminToolbox.ATPlayerDict.ContainsKey(steamID))
                    {
                        API.PlayerSettings setting = AdminToolbox.ATPlayerDict[steamID];
                        setting.Kills         = (playerStats.Length > 0 && int.TryParse(playerStats[0], out int x0) && x0 > setting.Kills) ? x0 : setting.Kills;
                        setting.TeamKills     = (playerStats.Length > 1 && int.TryParse(playerStats[1], out int x1) && x1 > setting.TeamKills) ? x1 : setting.TeamKills;
                        setting.Deaths        = (playerStats.Length > 2 && int.TryParse(playerStats[2], out int x2) && x2 > setting.Deaths) ? x2 : setting.Deaths;
                        setting.MinutesPlayed = (playerStats.Length > 3 && double.TryParse(playerStats[3], out double x3) && x3 > setting.MinutesPlayed) ? x3 : setting.MinutesPlayed;
                        setting.banCount      = (playerStats.Length > 4 && int.TryParse(playerStats[4], out int x4) && x4 > setting.banCount) ? x4 : setting.banCount;
                        AdminToolbox.ATPlayerDict[steamID] = setting;
                    }
                }
            }
        }
Esempio n. 21
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't find player: " + args[0] });;
                }
                if (args.Length > 1)
                {
                    if (args.Length > 2)
                    {
                        if (args[1].ToLower() == "add")
                        {
                            Dictionary <string, int> myPos = new Dictionary <string, int>()
                            {
                                { "x", 0 },
                                { "y", 0 },
                                { "z", 0 }
                            };
                            int      xInput = 0, yInput = 0, zInput = 0;
                            char[]   delimiterChars = { '.', ',', '=', '_', ':', '^', '/', '>', '<', '\'' };
                            string[] charsAllowed   = { "x", "y", "z" };
                            for (int i = 2; i < args.Length; i++)
                            {
                                string[] cordinates = args[i].ToLower().Split(delimiterChars);
                                if (cordinates.Length < 2)
                                {
                                    return(new string[] { GetUsage() });
                                }
                                if (!charsAllowed.Any(cordinates[0].Contains))
                                {
                                    return new string[] { cordinates[0] + " is not a valid axis, use X, Y or Z" }
                                }
                                ;
                                if (Int32.TryParse(cordinates[1], out int xyz))
                                {
                                    if (!myPos.ContainsKey(cordinates[0]))
                                    {
                                        myPos.Add(cordinates[0], xyz);
                                    }
                                    else
                                    {
                                        myPos[cordinates[0]] = xyz;
                                    }
                                }
                                else
                                {
                                    return new string[] { cordinates[1] + " is not a valid number" }
                                };
                            }
                            xInput = myPos["x"];
                            yInput = myPos["y"];
                            zInput = myPos["z"];
                            Vector myvector = new Vector(myPlayer.GetPosition().x + xInput, myPlayer.GetPosition().y + yInput, myPlayer.GetPosition().z + zInput);
                            myPlayer.Teleport(myvector, Unstuck);
                            return(new string[] { "Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z });
                        }
                        else if (args[1].ToLower() == "set")
                        {
                            Dictionary <string, int> myPos = new Dictionary <string, int>()
                            {
                                { "x", 0 },
                                { "y", 0 },
                                { "z", 0 }
                            };
                            int      xInput = 0, yInput = 0, zInput = 0;
                            char[]   delimiterChars = { '.', ',', '=', '_', ':', ';', ' ' };
                            string[] charsAllowed   = { "x", "y", "z" };
                            for (int i = 2; i < args.Length; i++)
                            {
                                string[] cordinates = args[i].ToLower().Split(delimiterChars);
                                if (cordinates.Length < 2)
                                {
                                    return(new string[] { GetUsage() });
                                }
                                if (!charsAllowed.Any(cordinates[0].Contains))
                                {
                                    return(new string[] { cordinates[0] + " is not a valid axis, use X, Y or Z" });
                                }
                                if (Int32.TryParse(cordinates[1], out int xyz))
                                {
                                    if (!myPos.ContainsKey(cordinates[0].ToLower()))
                                    {
                                        myPos.Add(cordinates[0].ToLower(), xyz);
                                    }
                                    else
                                    {
                                        myPos[cordinates[0]] = xyz;
                                    }
                                }
                                else
                                {
                                    return(new string[] { cordinates[1] + " is not a valid number" });
                                }
                            }
                            xInput = myPos["x"];
                            yInput = myPos["y"];
                            zInput = myPos["z"];
                            Vector myvector = new Vector(xInput, yInput, zInput);

                            myPlayer.Teleport(myvector, Unstuck);
                            return(new string[] { "Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z });
                        }
                        else
                        {
                            return new string[] { GetUsage() }
                        };
                    }
                    else if (args[1].ToLower() == "get")
                    {
                        return(new string[] { myPlayer.Name + " Pos x:" + myPlayer.GetPosition().x + " y:" + myPlayer.GetPosition().y + " z:" + myPlayer.GetPosition().z });
                    }
                    else
                    {
                        return new string[] { GetUsage() }
                    };
                }
                else
                {
                    return new string[] { GetUsage() }
                };
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
}
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        if (bool.TryParse(args[1], out bool j))
                        {
                            int playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                AdminToolbox.ATPlayerDict[pl.SteamId].overwatchMode = j;
                                pl.OverwatchMode = j;
                                playerNum++;
                            }
                            if (playerNum > 1)
                            {
                                return new string[] { playerNum + " player's Overwatch status set to: " + j }
                            }
                            ;
                            else
                            {
                                return new string[] { playerNum + " player Overwatch status set to: " + j }
                            };
                        }
                        else
                        {
                            return new string[] { "Not a valid bool!" }
                        };
                    }
                    else
                    {
                        int playerNum = 0;
                        foreach (Player pl in server.GetPlayers())
                        {
                            AdminToolbox.ATPlayerDict[pl.SteamId].overwatchMode = !AdminToolbox.ATPlayerDict[pl.SteamId].overwatchMode; pl.OverwatchMode = !pl.OverwatchMode; playerNum++;
                        }
                        return(new string[] { "Toggled " + playerNum + " player's \"OverwatchMode\"" });
                    }
                }
                else if (args[0].ToLower() == "list" || args[0].ToLower() == "get")
                {
                    string        str          = "\nPlayers with \"Overwatch\" enabled: \n";
                    List <string> myPlayerList = new List <string>();
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (pl.OverwatchMode)
                        {
                            myPlayerList.Add(pl.Name);
                        }
                    }
                    if (myPlayerList.Count > 0)
                    {
                        myPlayerList.Sort();
                        foreach (var item in myPlayerList)
                        {
                            str += "\n - " + item;
                        }
                    }
                    else
                    {
                        str = "\nNo players with \"Overwatch\" enabled!";
                    }
                    return(new string[] { str });
                }
                Player myPlayer = API.GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't find player: " + args[0] });
                }
                if (args.Length > 1)
                {
                    if (args[1].ToLower() == "on" || args[1].ToLower() == "true")
                    {
                        AdminToolbox.ATPlayerDict[myPlayer.SteamId].overwatchMode = true; myPlayer.OverwatchMode = true;
                    }
                    else if (args[1].ToLower() == "off" || args[1].ToLower() == "false")
                    {
                        AdminToolbox.ATPlayerDict[myPlayer.SteamId].overwatchMode = false; myPlayer.OverwatchMode = false;
                    }
                    return(new string[] { myPlayer.Name + " Overwatch: " + myPlayer.OverwatchMode });
                }
                else
                {
                    AdminToolbox.ATPlayerDict[myPlayer.SteamId].overwatchMode = !AdminToolbox.ATPlayerDict[myPlayer.SteamId].overwatchMode;
                    myPlayer.OverwatchMode = !myPlayer.OverwatchMode;
                    return(new string[] { myPlayer.Name + " Overwatch: " + AdminToolbox.ATPlayerDict[myPlayer.SteamId].overwatchMode });
                }
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
Esempio n. 23
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        int j;
                        if (Int32.TryParse(args[1], out j))
                        {
                            int playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                pl.SetHealth(j);
                                playerNum++;
                            }
                            if (playerNum > 1)
                            {
                                return new string[] { "Set " + playerNum + " players HP to " + j + "HP" }
                            }
                            ;
                            //plugin.Info("Set " + playerNum + " players HP to " + j + "HP");
                            else
                            {
                                return new string[] { "Set " + playerNum + " players HP to " + j + "HP" }
                            };
                            //plugin.Info("Set " + playerNum + " player HP to " + j + "HP");
                        }
                        else
                        {
                            return(new string[] { "Not a valid number!" });
                            //plugin.Info("Not a valid number!");
                        }
                    }
                    else
                    {
                        foreach (Player pl in server.GetPlayers())
                        {
                            pl.SetHealth(pl.TeamRole.MaxHP);
                        }
                        return(new string[] { "Set all players to their default max HP" });
                        //plugin.Info("Set all players to their default max HP");
                    }
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                if (args.Length > 1)
                {
                    int j;
                    if (Int32.TryParse(args[1], out j))
                    {
                        //plugin.Info("Set " + myPlayer.Name + "'s HP to " + j + "HP");
                        myPlayer.SetHealth(j);
                        return(new string[] { "Set " + myPlayer.Name + "'s HP to " + j + "HP" });
                    }
                    else
                    {
                        return new string[] { "Not a valid number!" }
                    };
                    //plugin.Info("Not a valid number!");
                }
                else
                {
                    //plugin.Info(GetUsage());
                    //plugin.Info("Set " + myPlayer.Name + " to default HP");
                    myPlayer.SetHealth(myPlayer.TeamRole.MaxHP);
                    return(new string[] { "Set " + myPlayer.Name + " to default (" + myPlayer.TeamRole.MaxHP + ") HP" });
                }
            }
            else
            {
                return new string[] { GetUsage() }
            };
            //plugin.Info(GetUsage());
        }
    }
Esempio n. 24
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "list")
                {
                    if (AdminToolbox.warpVectors.Count < 1)
                    {
                        return(new string[] { "No warp points created yet!" });
                    }
                    string str  = "\nWarp Points:";
                    var    list = AdminToolbox.warpVectors.Keys.ToList();
                    list.Sort();
                    foreach (var i in list)
                    {
                        str += "\n - " + i;
                    }
                    //str += "\n Room Teleports:";
                    //foreach (var i in RoomManager.)
                    //{
                    //    str += "\n - " + i.label;
                    //}
                    //plugin.Info(str);
                    return(new string[] { str });
                }
                else if (args[0].ToLower() == "remove" || args[0].ToLower() == "-")
                {
                    if (AdminToolbox.warpVectors.ContainsKey(args[1].ToLower()))
                    {
                        AdminToolbox.warpVectors.Remove(args[1].ToLower());
                        return(new string[] { "Warp point: " + args[1].ToLower() + " removed." });
                        //plugin.Info("Warp point: " + args[2].ToLower() + " removed.");
                    }
                    else
                    {
                        return new string[] { "Warp point " + args[1].ToLower() + " does not exist!" }
                    };
                    //plugin.Info("Warp point " + args[2].ToLower() + " does not exist!");
                }
                else if (args[0].ToLower() == "add" || args[0].ToLower() == "+")
                {
                    if (args.Length > 2)
                    {
                        if (!AdminToolbox.warpVectors.ContainsKey(args[2]))
                        {
                            Player myPlayer = GetPlayerFromString.GetPlayer(args[1], out myPlayer);
                            if (myPlayer == null)
                            {
                                return(new string[] { "Couldn't get player: " + args[1] });;
                            }
                            Vector myvector = myPlayer.GetPosition();
                            AdminToolbox.warpVectors.Add(args[2].ToLower(), myvector);
                            //plugin.Info("Warp point: " + args[2].ToLower() + " added.");
                            return(new string[] { "Warp point: " + args[2].ToLower() + " added." });
                        }
                        else
                        {
                            return new string[] { "A warp point named: " + args[2].ToLower() + " already exists!" }
                        };
                        //plugin.Info("A warp point named: " + args[2].ToLower() + " already exists!");
                    }
                    else
                    {
                        return new string[] { GetUsage() }
                    };
                }
                else
                {
                    if (args.Length > 1)
                    {
                        Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);

                        if (myPlayer == null)
                        {
                            return(new string[] { "Couldn't get player: " + args[0] });;
                        }
                        if (!AdminToolbox.warpVectors.ContainsKey(args[1].ToLower()))
                        {
                            return new string[] { "No warp point called: " + args[1] }
                        }
                        ;
                        myPlayer.Teleport(AdminToolbox.warpVectors[args[1].ToLower()]);
                        return(new string[] { "Teleported: " + myPlayer.Name + " to warp point: " + args[1] });
                    }
                    else
                    {
                        return new string[] { GetUsage() }
                    };
                }
            }
            else
            {
                return new string[] { GetUsage() }
            };
            //plugin.Info(GetUsage());
        }
    }
}
Esempio n. 25
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        if (bool.TryParse(args[1], out bool j))
                        {
                            int playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                AdminToolbox.playerdict[pl.SteamId].dmgOff = j;
                                playerNum++;
                            }
                            return(new string[] { "Set " + playerNum + " player's \"No Dmg\" to " + j });
                        }
                        else
                        {
                            return new string[] { "Not a valid bool!" }
                        };
                    }
                    else
                    {
                        foreach (Player pl in server.GetPlayers())
                        {
                            AdminToolbox.playerdict[pl.SteamId].dmgOff = !AdminToolbox.playerdict[pl.SteamId].dmgOff;
                        }
                        return(new string[] { "Toggled all player's \"No Dmg\"" });
                    }
                }
                else if (args[0].ToLower() == "list" || args[0].ToLower() == "get")
                {
                    string        str          = "\nPlayers with \"No Dmg\" enabled: \n";
                    List <string> myPlayerList = new List <string>();
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (AdminToolbox.playerdict[pl.SteamId].dmgOff)
                        {
                            myPlayerList.Add(pl.Name);
                        }
                    }
                    if (myPlayerList.Count > 0)
                    {
                        myPlayerList.Sort();
                        foreach (var item in myPlayerList)
                        {
                            str += "\n - " + item;
                        }
                    }
                    else
                    {
                        str = "\nNo players with \"No Dmg\" enabled!";
                    }
                    return(new string[] { str });
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                if (args.Length > 1)
                {
                    bool changedValue = false;
                    if (args.Length > 2)
                    {
                        if (args[2].ToLower() == "godmode")
                        {
                            changedValue = true;
                        }
                    }
                    if (args[1].ToLower() == "on" || args[1].ToLower() == "true")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = true;
                    }
                    else if (args[1].ToLower() == "off" || args[1].ToLower() == "false")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = false;
                    }
                    if (changedValue)
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId].godMode = AdminToolbox.playerdict[myPlayer.SteamId].dmgOff;
                        return(new string[] { myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff, myPlayer.Name + " Godmode: " + AdminToolbox.playerdict[myPlayer.SteamId].godMode });
                    }
                    return(new string[] { myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff });
                }
                else
                {
                    AdminToolbox.playerdict[myPlayer.SteamId].dmgOff = !AdminToolbox.playerdict[myPlayer.SteamId].dmgOff;
                    return(new string[] { myPlayer.Name + " No Dmg: " + AdminToolbox.playerdict[myPlayer.SteamId].dmgOff });
                }
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
Esempio n. 26
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't find player: " + args[0] });;
                }
                if (args.Length > 1)
                {
                    if (args.Length > 2)
                    {
                        if (args[1].ToLower() == "add")
                        {
                            Dictionary <string, int> myPos = new Dictionary <string, int>()
                            {
                                { "x", 0 },
                                { "y", 0 },
                                { "z", 0 }
                            };
                            int      xInput = 0, yInput = 0, zInput = 0;
                            char[]   delimiterChars = { '.', ',', '=', '_', ':', ';', ' ' };
                            string[] charsAllowed   = { "x", "y", "z" };
                            for (int i = 2; i < args.Length; i++)
                            {
                                string[] cordinates = args[i].ToLower().Split(delimiterChars);
                                if (cordinates.Length < 2)
                                {
                                    return(new string[] { GetUsage() });
                                }
                                if (!charsAllowed.Any(cordinates[0].Contains))
                                {
                                    //plugin.Info(cordinates[0] + " is not a valid axis, use X, Y or Z");
                                    return(new string[] { cordinates[0] + " is not a valid axis, use X, Y or Z" });
                                }
                                if (Int32.TryParse(cordinates[1], out int xyz))
                                {
                                    if (!myPos.ContainsKey(cordinates[0]))
                                    {
                                        //myPos.Remove(cordinates[0]);
                                        //plugin.Info("Added " + cordinates[0] + " value: " + xyz + " to cord dict");
                                        myPos.Add(cordinates[0], xyz);
                                    }
                                    else
                                    {
                                        //plugin.Info("Set " + cordinates[0] + " value: " + xyz);
                                        myPos[cordinates[0]] = xyz;
                                    }
                                }
                                else
                                {
                                    //plugin.Info(cordinates[1] + " is not a valid number");
                                    return(new string[] { cordinates[1] + " is not a valid number" });
                                }
                            }
                            xInput = myPos["x"];
                            yInput = myPos["y"];
                            zInput = myPos["z"];
                            //plugin.Info("MyPos: \n xInput: " + xInput + "\n yInput: " + yInput + "\n zInput: " + zInput);
                            Vector myvector = new Vector(myPlayer.GetPosition().x + xInput, myPlayer.GetPosition().y + yInput, myPlayer.GetPosition().z + zInput);

                            myPlayer.Teleport(myvector);
                            return(new string[] { "Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z });
                            //plugin.Info("Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z);
                        }
                        else if (args[1].ToLower() == "set")
                        {
                            Dictionary <string, int> myPos = new Dictionary <string, int>()
                            {
                                { "x", 0 },
                                { "y", 0 },
                                { "z", 0 }
                            };
                            int      xInput = 0, yInput = 0, zInput = 0;
                            char[]   delimiterChars = { '.', ',', '=', '_', ':', ';', ' ' };
                            string[] charsAllowed   = { "x", "y", "z" };
                            for (int i = 2; i < args.Length; i++)
                            {
                                string[] cordinates = args[i].ToLower().Split(delimiterChars);
                                if (cordinates.Length < 2)
                                {
                                    return(new string[] { GetUsage() });
                                }
                                if (!charsAllowed.Any(cordinates[0].Contains))
                                {
                                    //plugin.Info(cordinates[0] + " is not a valid axis, use X, Y or Z");
                                    return(new string[] { cordinates[0] + " is not a valid axis, use X, Y or Z" });
                                }
                                if (Int32.TryParse(cordinates[1], out int xyz))
                                {
                                    if (!myPos.ContainsKey(cordinates[0].ToLower()))
                                    {
                                        //myPos.Remove(cordinates[0]);
                                        //plugin.Info("Added " + cordinates[0] + " value: " + xyz + " to cord dict");
                                        myPos.Add(cordinates[0].ToLower(), xyz);
                                    }
                                    else
                                    {
                                        //plugin.Info("Set " + cordinates[0] + " value: " + xyz);
                                        myPos[cordinates[0]] = xyz;
                                    }
                                }
                                else
                                {
                                    //plugin.Info(cordinates[1] + " is not a valid number");
                                    return(new string[] { cordinates[1] + " is not a valid number" });
                                }
                            }
                            xInput = myPos["x"];
                            yInput = myPos["y"];
                            zInput = myPos["z"];
                            //plugin.Info("MyPos: \n xInput: " + xInput + "\n yInput: " + yInput + "\n zInput: " + zInput);
                            Vector myvector = new Vector(xInput, yInput, zInput);

                            myPlayer.Teleport(myvector);
                            //plugin.Info("Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z);
                            return(new string[] { "Teleported " + myPlayer.Name + " to x:" + myvector.x + " y:" + myvector.y + " z:" + myvector.z });
                        }
                        else
                        {
                            return new string[] { GetUsage() }
                        };
                        //plugin.Info("Not valid type, use [add/set/get]");
                    }
                    else if (args[1].ToLower() == "get")
                    {
                        //plugin.Info(myPlayer.Name + " Pos[x:" + myPlayer.GetPosition().x + " y:" + myPlayer.GetPosition().y + " z:" + myPlayer.GetPosition().z);
                        return(new string[] { myPlayer.Name + " Pos x:" + myPlayer.GetPosition().x + " y:" + myPlayer.GetPosition().y + " z:" + myPlayer.GetPosition().z });
                    }
                    else
                    {
                        return new string[] { GetUsage() }
                    };
                    //plugin.Info(GetUsage());
                }
                else
                {
                    return new string[] { GetUsage() }
                };
                //plugin.Info(GetUsage());
            }
            //else if (args[0].ToLower() == "help")
            //{
            //    //plugin.Info("\n General info: You dont need to use all X Y Z, you can use only one if you wish\n This command might trigger the anti-cheat if you have it enabled \n Teleporing less than 7 units might not work \n \n Position command examples: \n  pos (player) set x:80 y:-1000 z:95  -Sets the player pos to x y z \n pos (player) add y:10   -Adds to the player's chosen axis pos \n pos (player) get  -Gets the player's current pos \n Write ROOMPOS to see room positions");
            //    return new string[] { "\nGeneral info: You dont need to use all X Y Z, you can use only one if you wish\n This command might trigger the anti-cheat if you have it enabled \n Teleporing less than 7 units might not work \n \n Position command examples: \n  pos (player) set x:80 y:-1000 z:95  -Sets the player pos to x y z \n pos (player) add y:10   -Adds to the player's chosen axis pos \n pos (player) get  -Gets the player's current pos \n Write ROOMPOS to see room positions" };
            //}
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
Esempio n. 27
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        if (bool.TryParse(args[1], out bool j))
                        {
                            string outPut    = null;
                            int    playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                AdminToolbox.playerdict[pl.SteamId].instantKill = j;
                                playerNum++;
                            }
                            outPut += "\nSet " + playerNum + " player's InstantKill to " + j;
                            return(new string[] { outPut });
                        }
                        else
                        {
                            return(new string[] { "Not a valid bool!" });
                        }
                    }
                    else
                    {
                        foreach (Player pl in server.GetPlayers())
                        {
                            AdminToolbox.playerdict[pl.SteamId].instantKill = !AdminToolbox.playerdict[pl.SteamId].instantKill;
                        }
                        return(new string[] { "Toggled all players InstantKill" });
                    }
                }
                else if (args[0].ToLower() == "list" || args[0].ToLower() == "get")
                {
                    string        str          = "\nPlayers with InstantKill enabled: \n";
                    List <string> myPlayerList = new List <string>();
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (AdminToolbox.playerdict[pl.SteamId].instantKill)
                        {
                            myPlayerList.Add(pl.Name);
                            //str += " - " +pl.Name + "\n";
                        }
                    }
                    if (myPlayerList.Count > 0)
                    {
                        myPlayerList.Sort();
                        foreach (var item in myPlayerList)
                        {
                            str += "\n - " + item;
                        }
                    }
                    else
                    {
                        str = "\nNo players with \"InstantKill\" enabled!";
                    }
                    return(new string[] { str });
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't find player: " + args[0] });
                }
                if (args.Length > 1)
                {
                    if (bool.TryParse(args[1], out bool g))
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId].instantKill = g;
                    }
                    else if (args[1].ToLower() == "on")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId].instantKill = true;
                    }
                    else if (args[1].ToLower() == "off")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId].instantKill = false;
                    }
                    else
                    {
                        return new string[] { GetUsage() }
                    };
                    return(new string[] { myPlayer.Name + " InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId].instantKill });
                }
                else
                {
                    AdminToolbox.playerdict[myPlayer.SteamId].instantKill = !AdminToolbox.playerdict[myPlayer.SteamId].instantKill;
                    return(new string[] { myPlayer.Name + " InstantKill: " + AdminToolbox.playerdict[myPlayer.SteamId].instantKill });
                }
            }
            return(new string[] { GetUsage() });
        }
Esempio n. 28
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            if (sender is Player p)
            {
                AdminToolbox.AddMissingPlayerVariables(new List <Player> {
                    p
                });
            }
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        if (bool.TryParse(args[1], out bool j))
                        {
                            string outPut       = null;
                            bool   changedState = false;
                            if (args.Length > 2)
                            {
                                if (args[2].ToLower() == "nodmg")
                                {
                                    noDmg = j; changedState = true;
                                }
                            }
                            int playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                if (AdminToolbox.ATPlayerDict.ContainsKey(pl.SteamId))
                                {
                                    AdminToolbox.ATPlayerDict[pl.SteamId].godMode = j;
                                    if (changedState)
                                    {
                                        AdminToolbox.ATPlayerDict[pl.SteamId].dmgOff = j;
                                    }
                                    playerNum++;
                                }
                            }
                            outPut += "\nSet " + playerNum + " player's AT-Godmode to " + j;
                            if (changedState)
                            {
                                return new string[] { "\n" + "Set " + playerNum + " player's AT-Godmode to " + j, "\n" + "NoDmg for theese " + playerNum + " players set to: " + j }
                            }
                            ;
                            return(new string[] { "\n" + "Set " + playerNum + " player's AT-Godmode to " + j });
                        }
                        else
                        {
                            return(new string[] { "Not a valid bool!" });
                        }
                    }
                    else
                    {
                        foreach (Player pl in server.GetPlayers())
                        {
                            AdminToolbox.ATPlayerDict[pl.SteamId].godMode = !AdminToolbox.ATPlayerDict[pl.SteamId].godMode;
                        }
                        return(new string[] { "Toggled all players AT-Godmodes" });
                    }
                }
                else if (args[0].ToLower() == "list" || args[0].ToLower() == "get")
                {
                    string        str          = "\n" + "Players with AT-Godmode enabled: " + "\n";
                    List <string> myPlayerList = new List <string>();
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (AdminToolbox.ATPlayerDict.ContainsKey(pl.SteamId) && AdminToolbox.ATPlayerDict[pl.SteamId].godMode)
                        {
                            myPlayerList.Add(pl.Name);
                            //str += " - " +pl.Name + "\n";
                        }
                    }
                    if (myPlayerList.Count > 0)
                    {
                        myPlayerList.Sort();
                        foreach (var item in myPlayerList)
                        {
                            str += "\n - " + item;
                        }
                    }
                    else
                    {
                        str = "\n" + "No players with \"AT-Godmode\" enabled!";
                    }
                    return(new string[] { str });
                }
                Player myPlayer = API.GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return new string[] { "Couldn't find player: " + args[0] }
                }
                ;
                if (!AdminToolbox.ATPlayerDict.ContainsKey(myPlayer.SteamId))
                {
                    return new string[] { "Player not in dictionary" }
                }
                ;
                if (args.Length > 1)
                {
                    bool changedValue = false;

                    if (args.Length > 2)
                    {
                        if (args[2].ToLower() == "nodmg")
                        {
                            changedValue = true;
                        }
                    }
                    if (args[1].ToLower() == "on" || args[1].ToLower() == "true")
                    {
                        AdminToolbox.ATPlayerDict[myPlayer.SteamId].godMode = true;
                    }
                    else if (args[1].ToLower() == "off" || args[1].ToLower() == "false")
                    {
                        AdminToolbox.ATPlayerDict[myPlayer.SteamId].godMode = false;
                    }
                    if (changedValue)
                    {
                        AdminToolbox.ATPlayerDict[myPlayer.SteamId].dmgOff = AdminToolbox.ATPlayerDict[myPlayer.SteamId].godMode;
                        return(new string[] { myPlayer.Name + " AT-Godmode: " + AdminToolbox.ATPlayerDict[myPlayer.SteamId].godMode, myPlayer.Name + " No Dmg: " + AdminToolbox.ATPlayerDict[myPlayer.SteamId].dmgOff });
                    }
                    else
                    {
                        return new string[] { myPlayer.Name + " AT-Godmode: " + AdminToolbox.ATPlayerDict[myPlayer.SteamId].godMode }
                    };
                }
                else
                {
                    AdminToolbox.ATPlayerDict[myPlayer.SteamId].godMode = !AdminToolbox.ATPlayerDict[myPlayer.SteamId].godMode;
                    return(new string[] { myPlayer.Name + " AT-Godmode: " + AdminToolbox.ATPlayerDict[myPlayer.SteamId].godMode });
                }
            }
            else
            {
                return(new string[] { GetUsage() });
            }
        }
    }
}
Esempio n. 29
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            AdminToolbox.AddMissingPlayerVariables();
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                if (args[0].ToLower() == "all" || args[0].ToLower() == "*")
                {
                    if (args.Length > 1)
                    {
                        bool j;
                        if (bool.TryParse(args[1], out j))
                        {
                            int playerNum = 0;
                            foreach (Player pl in server.GetPlayers())
                            {
                                AdminToolbox.playerdict[pl.SteamId][0] = j;
                                playerNum++;
                            }
                            if (playerNum > 1)
                            {
                                return new string[] { playerNum + " players set to AlwaysSpectator: " + j }
                            }
                            ;
                            //plugin.Info(playerNum + " roles set to " + (Role)14);
                            else
                            {
                                return new string[] { playerNum + " player set to AlwaysSpectator: " + j }
                            };
                            //plugin.Info(playerNum + " role set to " + (Role)14);
                        }
                        else
                        {
                            return(new string[] { "Not a valid bool!" });
                        }
                    }
                    else
                    {
                        int playerNum = 0;
                        foreach (Player pl in server.GetPlayers())
                        {
                            AdminToolbox.playerdict[pl.SteamId][0] = !AdminToolbox.playerdict[pl.SteamId][0]; playerNum++;
                        }
                        //plugin.Info("Toggled all player's \"No Dmg\"");
                        return(new string[] { "Toggled " + playerNum + " player's \"AlwaysSpectator\"" });
                    }
                }
                else if (args[0].ToLower() == "list" || args[0].ToLower() == "get")
                {
                    string        str          = "\nPlayers with \"AlwaysSpectator\" enabled: \n";
                    List <string> myPlayerList = new List <string>();
                    foreach (Player pl in server.GetPlayers())
                    {
                        if (AdminToolbox.playerdict[pl.SteamId][0])
                        {
                            myPlayerList.Add(pl.Name);
                            //str += " - " +pl.Name + "\n";
                        }
                    }
                    if (myPlayerList.Count > 0)
                    {
                        myPlayerList.Sort();
                        foreach (var item in myPlayerList)
                        {
                            str += "\n - " + item;
                        }
                    }
                    else
                    {
                        str = "\nNo players with \"AlwaysSpectator\" enabled!";
                    }
                    //plugin.Info(str);
                    return(new string[] { str });
                }
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't find player: " + args[0] });
                }
                if (args.Length > 1)
                {
                    if (args[1].ToLower() == "on" || args[1].ToLower() == "true")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId][0] = true;
                    }
                    else if (args[1].ToLower() == "off" || args[1].ToLower() == "false")
                    {
                        AdminToolbox.playerdict[myPlayer.SteamId][0] = false;
                    }
                    //plugin.Info(myPlayer.Name + " Keep settings: " + AdminToolbox.playerdict[myPlayer.SteamId][0]);
                    return(new string[] { myPlayer.Name + " AlwaysSpectator: " + AdminToolbox.playerdict[myPlayer.SteamId][0] });
                }
                else
                {
                    AdminToolbox.playerdict[myPlayer.SteamId][0] = !AdminToolbox.playerdict[myPlayer.SteamId][0];
                    //plugin.Info(myPlayer.Name + " Keep settings: " + AdminToolbox.playerdict[myPlayer.SteamId][0]);
                    return(new string[] { myPlayer.Name + " AlwaysSpectator: " + AdminToolbox.playerdict[myPlayer.SteamId][0] });
                }
            }
            else
            {
                return(new string[] { GetUsage() });
                //plugin.Info(GetUsage());
            }
        }
Esempio n. 30
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            Server server = PluginManager.Manager.Server;

            if (args.Length > 0)
            {
                Player myPlayer = GetPlayerFromString.GetPlayer(args[0]);
                if (myPlayer == null)
                {
                    return(new string[] { "Couldn't get player: " + args[0] });;
                }
                AdminToolbox.AddMissingPlayerVariables(new List <Player> {
                    myPlayer
                });
                if (args.Length == 2)
                {
                    if (Int32.TryParse(args[1], out int x))
                    {
                        if (x > 0)
                        {
                            AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime = DateTime.Now.AddSeconds(x);
                            AdminToolbox.SendToJail(myPlayer);
                            return(new string[] { "\"" + myPlayer.Name + "\" sent to jail for: " + x + " seconds." });
                        }
                        else
                        {
                            AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime = DateTime.Now.AddYears(1);
                            AdminToolbox.SendToJail(myPlayer);
                            return(new string[] { "\"" + myPlayer.Name + "\" sent to jail for 1 year" });
                        }
                    }
                    else
                    {
                        return new string[] { args[1] + " is not a valid number!" }
                    };
                }
                else if (args.Length == 1)
                {
                    if (AdminToolbox.playerdict[myPlayer.SteamId].isInJail || AdminToolbox.playerdict[myPlayer.SteamId].isJailed)
                    {
                        AdminToolbox.ReturnFromJail(myPlayer);

                        return(new string[] { "\"" + myPlayer.Name + "\" returned from jail" });
                    }
                    else
                    {
                        AdminToolbox.SendToJail(myPlayer);
                        AdminToolbox.playerdict[myPlayer.SteamId].JailedToTime = DateTime.Now.AddYears(1);
                        return(new string[] { "\"" + myPlayer.Name + "\" sent to jail for 1 year" });
                    }
                }
                else
                {
                    return new string[] { GetUsage() }
                };
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }