Beispiel #1
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() }
            };
        }
    }