private bool OnSignHit(int X, int Y, string text, int who)
        {
            if (!text.ToLower().StartsWith(Config.DefineSignCommands.ToLower()))
            {
                return(false);
            }
            TSPlayer tPly = TShock.Players[who];
            scPlayer sPly = scPlayers[who];
            scSign   sign = new scSign(text, new Point(X, Y));

            bool CanBreak = scUtils.CanBreak(tPly, sign);

            if (sPly.DestroyMode && CanBreak)
            {
                return(false);
            }

            if (Config.ShowDestroyMessage && CanBreak && sPly.AlertDestroyCooldown == 0)
            {
                tPly.SendInfoMessage("To destroy this sign, Type \"/destsign\".");
                sPly.AlertDestroyCooldown = 10;
            }

            sign.ExecuteCommands(sPly);

            return(true);
        }
        private void CMDdestsign(CommandArgs args)
        {
            scPlayer sPly = scPlayers[args.Player.Index];

            sPly.DestroyMode = true;
            args.Player.SendSuccessMessage("You can now destroy a sign.");
        }
Ejemplo n.º 3
0
        public static void CMDspawnmob(scPlayer sPly, List <string> args)
        {
            if (args.Count < 1)
            {
                return;
            }
            string mob = args[0];

            int amount = 1;

            if (args.Count > 1)
            {
                int.TryParse(args[1], out amount);
            }
            if (amount < 1)
            {
                amount = 1;
            }

            amount = Math.Min(amount, Main.maxNPCs);

            var npc = TShock.Utils.GetNPCByIdOrName(mob);

            if (npc.Count == 1 && npc[0].type >= 1 && npc[0].type < Main.maxNPCTypes && npc[0].type != 113)
            {
                TSPlayer.Server.SpawnNPC(npc[0].type, npc[0].name, amount, sPly.TSPlayer.TileX, sPly.TSPlayer.TileY, 50, 20);
            }
        }
Ejemplo n.º 4
0
        public static void CMDcommand(scPlayer sPly, List <string> args)
        {
            if (args.Count < 1)
            {
                return;
            }
            string command = args[0];

            Commands.HandleCommand(sPly.TSPlayer, command);
        }
Ejemplo n.º 5
0
 public SignCommands(Main game)
     : base(game)
 {
     getConfig = new scConfig();
     scPlayers = new scPlayer[256];
     GlobalCooldowns = new Dictionary<string, DateTime>();
     OfflineCooldowns = new Dictionary<string, Dictionary<string, DateTime>>();
     UsingInfiniteSigns = File.Exists(Path.Combine("ServerPlugins", "InfiniteSigns.dll"));
     UsingVault = File.Exists(Path.Combine("ServerPlugins", "Vault.dll"));
     this.lastCooldown = DateTime.UtcNow;
     this.lastPurge = DateTime.UtcNow;
     Order = -1;
 }
Ejemplo n.º 6
0
        public static void CMDdamage(scPlayer sPly, List <string> args)
        {
            int amount = 10;

            if (args.Count > 0)
            {
                int.TryParse(args[0], out amount);
            }
            if (amount < 1)
            {
                amount = 10;
            }
            sPly.TSPlayer.DamagePlayer(amount);
        }
Ejemplo n.º 7
0
        public static void CMDheal(scPlayer sPly, List <string> args)
        {
            Item heart = TShock.Utils.GetItemById(58);
            Item star  = TShock.Utils.GetItemById(184);

            for (int ic = 0; ic < 20; ic++)
            {
                sPly.TSPlayer.GiveItem(heart.type, heart.name, heart.width, heart.height, heart.maxStack);
            }
            for (int ic = 0; ic < 10; ic++)
            {
                sPly.TSPlayer.GiveItem(star.type, star.name, star.width, star.height, star.maxStack);
            }
        }
        bool chargeSign(scPlayer sPly)
        {
            try
            {
                var economyPlayer = Wolfje.Plugins.SEconomy.SEconomyPlugin.GetEconomyPlayerSafe(sPly.Index);
                var commandCost   = new Wolfje.Plugins.SEconomy.Money(this.Cost);

                if (economyPlayer.BankAccount != null)
                {
                    if (!economyPlayer.BankAccount.IsAccountEnabled)
                    {
                        sPly.TSPlayer.SendErrorMessage("You cannot use this command because your account is disabled.");
                    }
                    else if (economyPlayer.BankAccount.Balance >= this.Cost)
                    {
                        Wolfje.Plugins.SEconomy.Journal.BankTransferEventArgs trans = economyPlayer.BankAccount.TransferTo(
                            Wolfje.Plugins.SEconomy.SEconomyPlugin.WorldAccount,
                            commandCost,
                            Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.AnnounceToSender |
                            Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.IsPayment,
                            "",
                            string.Format("Sign Command charge to {0}", sPly.TSPlayer.Name)
                            );
                        if (trans.TransferSucceeded)
                        {
                            return(true);
                        }
                        else
                        {
                            sPly.TSPlayer.SendErrorMessage("Your payment failed.");
                        }
                    }
                    else
                    {
                        sPly.TSPlayer.SendErrorMessage("This Sign Command costs {0}. You need {1} more to be able to use it.",
                                                       commandCost.ToLongString(),
                                                       ((Wolfje.Plugins.SEconomy.Money)(economyPlayer.BankAccount.Balance - commandCost)).ToLongString()
                                                       );
                    }
                }
                else
                {
                    sPly.TSPlayer.SendErrorMessage("This command costs money and you don't have a bank account. Please log in first.");
                }
            }
            catch { }
            return(false);
        }
Ejemplo n.º 9
0
        public static void CMDwarp(scPlayer sPly, List <string> args)
        {
            if (args.Count < 1)
            {
                return;
            }

            string WarpName = args[0];

            var Warp = TShock.Warps.Find(WarpName);

            if (Warp != null && Warp.Name != "" && Warp.Position.X > 0 && Warp.Position.Y > 0)
            {
                sPly.TSPlayer.Teleport(Warp.Position.X * 16F, Warp.Position.Y * 16F);
            }
        }
Ejemplo n.º 10
0
        public void ExecuteCommand(scPlayer sPly)
        {
            switch (command)
            {
            case "time":
                CMDtime(sPly, args);
                break;

            case "heal":
                CMDheal(sPly, args);
                break;

            case "show":
                CMDshow(sPly, args);
                break;

            case "damage":
                CMDdamage(sPly, args);
                break;

            case "boss":
                CMDboss(sPly, args);
                break;

            case "spawnmob":
                CMDspawnmob(sPly, args);
                break;

            case "warp":
                CMDwarp(sPly, args);
                break;

            case "item":
                CMDitem(sPly, args);
                break;

            case "buff":
                CMDbuff(sPly, args);
                break;

            case "command":
                CMDcommand(sPly, args);
                break;
            }
        }
Ejemplo n.º 11
0
        public static void CMDitem(scPlayer sPly, List <string> args)
        {
            if (args.Count < 1)
            {
                return;
            }
            string itemname = args[0];

            int amount = 1;

            if (args.Count > 1)
            {
                int.TryParse(args[1], out amount);
            }
            if (amount < 1)
            {
                amount = 1;
            }

            int prefix = 0;

            if (args.Count > 2)
            {
                int.TryParse(args[2], out prefix);
            }
            if (prefix < 0)
            {
                prefix = 0;
            }

            List <Item> items = TShock.Utils.GetItemByIdOrName(itemname);

            if (items.Count == 1 && items[0].type >= 1 && items[0].type < Main.maxItemTypes)
            {
                Item item = items[0];
                if (sPly.TSPlayer.InventorySlotAvailable || item.name.Contains("Coin"))
                {
                    if (amount == 0 || amount > item.maxStack)
                    {
                        amount = item.maxStack;
                    }
                    sPly.TSPlayer.GiveItemCheck(item.type, item.name, item.width, item.height, amount, prefix);
                }
            }
        }
Ejemplo n.º 12
0
        public static void CMDtime(scPlayer sPly, List <string> args)
        {
            if (args.Count < 1)
            {
                return;
            }
            string time = args[0].ToLower();

            switch (time)
            {
            case "day":
                TSPlayer.Server.SetTime(true, 150.0);
                break;

            case "night":
                TSPlayer.Server.SetTime(false, 0.0);
                break;

            case "dusk":
                TSPlayer.Server.SetTime(false, 0.0);
                break;

            case "noon":
                TSPlayer.Server.SetTime(true, 27000.0);
                break;

            case "midnight":
                TSPlayer.Server.SetTime(false, 16200.0);
                break;

            case "fullmoon":
                TSPlayer.Server.SetFullMoon(true);
                break;

            case "bloodmoon":
                TSPlayer.Server.SetBloodMoon(true);
                break;
            }
        }
Ejemplo n.º 13
0
        public static void CMDbuff(scPlayer sPly, List <string> args)
        {
            if (args.Count < 1)
            {
                return;
            }
            string buffname = args[0];

            int duration = 60;

            if (args.Count > 1)
            {
                int.TryParse(args[1], out duration);
            }

            int buffid = -1;

            if (!int.TryParse(buffname, out buffid))
            {
                List <int> buffs = TShock.Utils.GetBuffByName(buffname);
                if (buffs.Count == 1)
                {
                    buffid = buffs[0];
                }
                else
                {
                    return;
                }
            }
            if (buffid > 0 && buffid < Main.maxBuffTypes)
            {
                if (duration < 1 || duration > short.MaxValue)
                {
                    duration = 60;
                }
                sPly.TSPlayer.SetBuff(buffid, duration * 60);
            }
        }
Ejemplo n.º 14
0
        public static void CMDshow(scPlayer sPly, List <string> args)
        {
            if (args.Count < 1)
            {
                return;
            }
            string file = args[0].ToLower();

            switch (file)
            {
            case "motd":
                TShock.Utils.ShowFileToUser(sPly.TSPlayer, "motd.txt");
                break;

            case "rules":
                TShock.Utils.ShowFileToUser(sPly.TSPlayer, "rules.txt");
                break;

            case "playing":
                Commands.HandleCommand(sPly.TSPlayer, "/playing");
                break;

            default:
            {
                if (File.Exists(args[0]))
                {
                    TShock.Utils.ShowFileToUser(sPly.TSPlayer, args[0]);
                }
                else
                {
                    sPly.TSPlayer.SendErrorMessage("Could not find file.");
                }
            }
            break;
            }
        }
 public static void CMDtime(scPlayer sPly, List<string> args)
 {
     if (args.Count < 1) return;
     string time = args[0].ToLower();
     switch (time)
     {
         case "day":
             TSPlayer.Server.SetTime(true, 150.0);
             break;
         case "night":
             TSPlayer.Server.SetTime(false, 0.0);
             break;
         case "dusk":
             TSPlayer.Server.SetTime(false, 0.0);
             break;
         case "noon":
             TSPlayer.Server.SetTime(true, 27000.0);
             break;
         case "midnight":
             TSPlayer.Server.SetTime(false, 16200.0);
             break;
         case "fullmoon":
             TSPlayer.Server.SetFullMoon(true);
             break;
         case "bloodmoon":
             TSPlayer.Server.SetBloodMoon(true);
             break;
     }
 }
 public static void CMDshow(scPlayer sPly, List<string> args)
 {
     if (args.Count < 1) return;
     string file = args[0].ToLower();
     switch (file)
     {
         case "motd":
             TShock.Utils.ShowFileToUser(sPly.TSPlayer, "motd.txt");
             break;
         case "rules":
             TShock.Utils.ShowFileToUser(sPly.TSPlayer, "rules.txt");
             break;
         case "playing":
             Commands.HandleCommand(sPly.TSPlayer, "/playing");
             break;
         default:
             {
                 if (File.Exists(args[0]))
                     TShock.Utils.ShowFileToUser(sPly.TSPlayer, args[0]);
                 else
                     sPly.TSPlayer.SendMessage("Could not find file!", Color.OrangeRed);
             }
             break;
     }
 }
        public static void CMDspawnmob(scPlayer sPly, List<string> args)
        {
            if (args.Count < 1) return;
            string mob = args[0];

            int amount = 1;
            if (args.Count > 1)
                int.TryParse(args[1], out amount);
            if (amount < 1)
                amount = 1;

            amount = Math.Min(amount, Main.maxNPCs);

            var npc = TShock.Utils.GetNPCByIdOrName(mob);
            if (npc.Count == 1 && npc[0].type >= 1 && npc[0].type < Main.maxNPCTypes && npc[0].type != 113)
                TSPlayer.Server.SpawnNPC(npc[0].type, npc[0].name, amount, sPly.TSPlayer.TileX, sPly.TSPlayer.TileY, 50, 20);
        }
        public static void CMDitem(scPlayer sPly, List<string> args)
        {
            if (args.Count < 1) return;
            string itemname = args[0];

            int amount = 1;
            if (args.Count > 1)
                int.TryParse(args[1], out amount);
            if (amount < 1)
                amount = 1;

            int prefix = 0;
            if (args.Count > 2)
                int.TryParse(args[2], out prefix);
            if (prefix < 0)
                prefix = 0;

            List<Item> items = TShock.Utils.GetItemByIdOrName(itemname);
            if (items.Count == 1 && items[0].type >= 1 && items[0].type < Main.maxItemTypes)
            {
                Item item = items[0];
                if (sPly.TSPlayer.InventorySlotAvailable || item.name.Contains("Coin"))
                {
                    if (amount == 0 || amount > item.maxStack)
                        amount = item.maxStack;
                    sPly.TSPlayer.GiveItemCheck(item.type, item.name, item.width, item.height, amount, prefix);
                }
            }
        }
        public static void CMDkit(scPlayer sPly, List<string> args)
        {
            if (args.Count < 1) return;
            string kitname = args[0];

            try { HandleKits(sPly, kitname); }
            catch { }
        }
 public static void CMDdamage(scPlayer sPly, List<string> args)
 {
     int amount = 10;
     if (args.Count > 0)
         int.TryParse(args[0], out amount);
     if (amount < 1)
         amount = 10;
     sPly.TSPlayer.DamagePlayer(amount);
 }
 public static void CMDheal(scPlayer sPly, List<string> args)
 {
     Item heart = TShock.Utils.GetItemById(58);
     Item star = TShock.Utils.GetItemById(184);
     for (int ic = 0; ic < 20; ic++)
         sPly.TSPlayer.GiveItem(heart.type, heart.name, heart.width, heart.height, heart.maxStack);
     for (int ic = 0; ic < 10; ic++)
         sPly.TSPlayer.GiveItem(star.type, star.name, star.width, star.height, star.maxStack);
 }
        public static void CMDbuff(scPlayer sPly, List<string> args)
        {
            if (args.Count < 1) return;
            string buffname = args[0];

            int duration = 60;
            if (args.Count > 1)
                int.TryParse(args[1], out duration);

            int buffid = -1;
            if (!int.TryParse(buffname, out buffid))
            {
                List<int> buffs = TShock.Utils.GetBuffByName(buffname);
                if (buffs.Count == 1)
                    buffid = buffs[0];
                else
                    return;
            }
            if (buffid > 0 && buffid < Main.maxBuffs)
            {
                if (duration < 1 || duration > short.MaxValue)
                    duration = 60;
                sPly.TSPlayer.SetBuff(buffid, duration * 60);
            }
        }
 public static void CMDcommand(scPlayer sPly, List<string> args)
 {
     if (args.Count < 1) return;
     string command = args[0];
     Commands.HandleCommand(sPly.TSPlayer, command);
 }
Ejemplo n.º 24
0
        public static void CMDboss(scPlayer sPly, List <string> args)
        {
            if (args.Count < 1)
            {
                return;
            }
            string boss = args[0].ToLower();

            int amount = 1;

            if (args.Count > 1)
            {
                int.TryParse(args[1], out amount);
            }

            amount = Math.Min(amount, Main.maxNPCs);
            if (amount < 1)
            {
                amount = 1;
            }

            NPC npc = null;

            switch (boss)
            {
            case "eater":
                npc = TShock.Utils.GetNPCById(13);
                break;

            case "eye":
            {
                npc = TShock.Utils.GetNPCById(4);
                TSPlayer.Server.SetTime(false, 0.0);
            }
            break;

            case "king":
                npc = TShock.Utils.GetNPCById(50);
                break;

            case "skeletron":
            {
                npc = TShock.Utils.GetNPCById(35);
                TSPlayer.Server.SetTime(false, 0.0);
            }
            break;

            case "wof":
            {
                for (int i = 0; i < amount; i++)
                {
                    if (Main.wof >= 0 || (sPly.TSPlayer.Y / 16f < (float)(Main.maxTilesY - 205)))
                    {
                        sPly.TSPlayer.SendErrorMessage("Can't spawn Wall of Flesh.");
                    }
                    NPC.SpawnWOF(new Vector2(sPly.TSPlayer.X, sPly.TSPlayer.Y));
                }
            }
            break;

            case "twins":
            {
                NPC retinazer = TShock.Utils.GetNPCById(125);
                NPC spaz      = TShock.Utils.GetNPCById(126);
                TSPlayer.Server.SetTime(false, 0.0);
                for (int i = 0; i < amount; i++)
                {
                    TSPlayer.Server.SpawnNPC(retinazer.type, retinazer.name, 1, sPly.TSPlayer.TileX, sPly.TSPlayer.TileY);
                    TSPlayer.Server.SpawnNPC(spaz.type, spaz.name, 1, sPly.TSPlayer.TileX, sPly.TSPlayer.TileY);
                }
            }
            break;

            case "destroyer":
            {
                npc = TShock.Utils.GetNPCById(134);
                TSPlayer.Server.SetTime(false, 0.0);
            }
            break;

            case "skeletronprime":
            {
                npc = TShock.Utils.GetNPCById(127);
                TSPlayer.Server.SetTime(false, 0.0);
            }
            break;
            }

            if (npc != null)
            {
                for (int i = 0; i < amount; i++)
                {
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, 1, sPly.TSPlayer.TileX, sPly.TSPlayer.TileY);
                }
            }
        }
Ejemplo n.º 25
0
        public void OnGreetPlayer(int who, HandledEventArgs e)
        {
            try
            {
                scPlayers[who] = new scPlayer(who);

                if (OfflineCooldowns.ContainsKey(TShock.Players[who].Name))
                {
                    scPlayers[who].Cooldowns = OfflineCooldowns[TShock.Players[who].Name];
                    OfflineCooldowns.Remove(TShock.Players[who].Name);
                }
            }
            catch { }
        }
 public void ExecuteCommand(scPlayer sPly)
 {
     switch(command)
     {
         case "time":
             CMDtime(sPly, args);
             break;
         case "heal":
             CMDheal(sPly, args);
             break;
         case "show":
             CMDshow(sPly, args);
             break;
         case "damage":
             CMDdamage(sPly, args);
             break;
         case "boss":
             CMDboss(sPly, args);
             break;
         case "spawnmob":
             CMDspawnmob(sPly, args);
             break;
         case "warp":
             CMDwarp(sPly, args);
             break;
         case "item":
             CMDitem(sPly, args);
             break;
         case "buff":
             CMDbuff(sPly, args);
             break;
         case "kit":
             CMDkit(sPly, args);
             break;
         case "command":
             CMDcommand(sPly, args);
             break;
     }
 }
        public static void CMDwarp(scPlayer sPly, List<string> args)
        {
            if (args.Count < 1) return;

            string WarpName = args[0];

            var Warp  = TShock.Warps.FindWarp(WarpName);

            if (Warp != null && Warp.WarpName != "" && Warp.WarpPos.X > 0 && Warp.WarpPos.Y > 0 && Warp.WorldWarpID != "")
                sPly.TSPlayer.Teleport((int)Warp.WarpPos.X, (int)Warp.WarpPos.Y);
        }
        public void ExecuteCommands(scPlayer sPly)
        {
            #region Check Cooldown
            if (!sPly.TSPlayer.Group.HasPermission("essentials.signs.nocooldown") && this.Cooldown > 0)
            {
                if (this.CooldownGroup.StartsWith("global-"))
                {
                    lock (SignCommands.GlobalCooldowns)
                    {
                        if (!SignCommands.GlobalCooldowns.ContainsKey(this.CooldownGroup))
                        {
                            SignCommands.GlobalCooldowns.Add(this.CooldownGroup, DateTime.UtcNow.AddSeconds(this.Cooldown));
                        }
                        else
                        {
                            if (SignCommands.GlobalCooldowns[this.CooldownGroup] > DateTime.UtcNow)
                            {
                                if (sPly.AlertCooldownCooldown == 0)
                                {
                                    sPly.TSPlayer.SendErrorMessage("Everyone must wait another {0} seconds before using this sign.", (int)(SignCommands.GlobalCooldowns[this.CooldownGroup] - DateTime.UtcNow).TotalSeconds);
                                    sPly.AlertCooldownCooldown = 3;
                                }
                                return;
                            }
                            else
                            {
                                SignCommands.GlobalCooldowns[this.CooldownGroup] = DateTime.UtcNow.AddSeconds(this.Cooldown);
                            }
                        }
                    }
                }
                else
                {
                    lock (sPly.Cooldowns)
                    {
                        string CooldownID = string.Concat(this.Position.ToString());
                        if (this.CooldownGroup != string.Empty)
                        {
                            CooldownID = this.CooldownGroup;
                        }

                        if (!sPly.Cooldowns.ContainsKey(CooldownID))
                        {
                            sPly.Cooldowns.Add(CooldownID, DateTime.UtcNow.AddSeconds(this.Cooldown));
                        }
                        else
                        {
                            if (sPly.Cooldowns[CooldownID] > DateTime.UtcNow)
                            {
                                if (sPly.AlertCooldownCooldown == 0)
                                {
                                    sPly.TSPlayer.SendErrorMessage("You must wait another {0} seconds before using this sign.", (int)(sPly.Cooldowns[CooldownID] - DateTime.UtcNow).TotalSeconds);
                                    sPly.AlertCooldownCooldown = 3;
                                }
                                return;
                            }
                            else
                            {
                                sPly.Cooldowns[CooldownID] = DateTime.UtcNow.AddSeconds(this.Cooldown);
                            }
                        }
                    }
                }
            }
            #endregion

            #region Check Cost
            if (SignCommands.UsingSEConomy && this.Cost > 0 && !chargeSign(sPly))
            {
                return;
            }
            #endregion

            int DoesntHavePermission = 0;
            foreach (scCommand cmd in this.Commands)
            {
                if (!sPly.TSPlayer.Group.HasPermission(string.Format("essentials.signs.use.{0}", cmd.command)))
                {
                    DoesntHavePermission++;
                    continue;
                }

                cmd.ExecuteCommand(sPly);
            }

            if (DoesntHavePermission > 0 && sPly.AlertPermissionCooldown == 0)
            {
                sPly.TSPlayer.SendErrorMessage("You do not have permission to use {0} command(s) on that sign.", DoesntHavePermission);
                sPly.AlertPermissionCooldown = 5;
            }
        }
        public static void HandleKits(scPlayer sPly, string KitName)
        {
            try
            {
                Kits.Kit k = Kits.Kits.FindKit(KitName.ToLower());

                if (k != null && sPly.TSPlayer.Group.HasPermission(k.getPerm()))
                {
                    k.giveItems(sPly.TSPlayer);

                }
            }
            catch { }
        }
Ejemplo n.º 30
0
        bool chargeSign(scPlayer sPly)
        {
            try
            {
                var economyPlayer = Wolfje.Plugins.SEconomy.SEconomyPlugin.GetEconomyPlayerSafe(sPly.Index);
                var commandCost = new Wolfje.Plugins.SEconomy.Money(this.Cost);

                if (economyPlayer.BankAccount != null)
                {
                    if (!economyPlayer.BankAccount.IsAccountEnabled)
                    {
                        sPly.TSPlayer.SendErrorMessage("You cannot use this command because your account is disabled.");
                    }
                    else if (economyPlayer.BankAccount.Balance >= this.Cost)
                    {
                        Wolfje.Plugins.SEconomy.Journal.BankTransferEventArgs trans = economyPlayer.BankAccount.TransferTo(
                            Wolfje.Plugins.SEconomy.SEconomyPlugin.WorldAccount,
                            commandCost,
                            Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.AnnounceToSender |
                            Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.IsPayment,
                            "",
                            string.Format("Sign Command charge to {0}", sPly.TSPlayer.Name)
                        );
                        if (trans.TransferSucceeded)
                        {
                            return true;
                        }
                        else
                        {
                            sPly.TSPlayer.SendErrorMessage("Your payment failed.");
                        }
                    }
                    else
                    {
                        sPly.TSPlayer.SendErrorMessage("This Sign Command costs {0}. You need {1} more to be able to use it.",
                            commandCost.ToLongString(),
                            ((Wolfje.Plugins.SEconomy.Money)(economyPlayer.BankAccount.Balance - commandCost)).ToLongString()
                        );
                    }
                }
                else
                {
                    sPly.TSPlayer.SendErrorMessage("This command costs money and you don't have a bank account. Please log in first.");
                }
            }
            catch { }
            return false;
        }
        public static void CMDboss(scPlayer sPly, List<string> args)
        {
            if (args.Count < 1) return;
            string boss = args[0].ToLower();

            int amount = 1;
            if (args.Count > 1)
                int.TryParse(args[1], out amount);

            amount = Math.Min(amount, Main.maxNPCs);
            if (amount < 1)
                amount = 1;

            NPC npc = null;
            switch (boss)
            {
                case "eater":
                    npc = TShock.Utils.GetNPCById(13);
                    break;
                case "eye":
                    {
                        npc = TShock.Utils.GetNPCById(4);
                        TSPlayer.Server.SetTime(false, 0.0);
                    }
                    break;
                case "king":
                    npc = TShock.Utils.GetNPCById(50);
                    break;
                case "skeletron":
                    {
                        npc = TShock.Utils.GetNPCById(35);
                        TSPlayer.Server.SetTime(false, 0.0);
                    }
                    break;
                case "wof":
                    {
                        for (int i = 0; i < amount; i++)
                        {
                            if (Main.wof >= 0 || (sPly.TSPlayer.Y / 16f < (float)(Main.maxTilesY - 205)))
                            {
                                sPly.TSPlayer.SendMessage("Can't spawn Wall of Flesh!", Color.Red);
                            }
                            NPC.SpawnWOF(new Vector2(sPly.TSPlayer.X, sPly.TSPlayer.Y));
                        }
                    }
                    break;
                case "twins":
                    {
                        NPC retinazer = TShock.Utils.GetNPCById(125);
                        NPC spaz = TShock.Utils.GetNPCById(126);
                        TSPlayer.Server.SetTime(false, 0.0);
                        for (int i = 0; i < amount; i++)
                        {
                            TSPlayer.Server.SpawnNPC(retinazer.type, retinazer.name, 1, sPly.TSPlayer.TileX, sPly.TSPlayer.TileY);
                            TSPlayer.Server.SpawnNPC(spaz.type, spaz.name, 1, sPly.TSPlayer.TileX, sPly.TSPlayer.TileY);
                        }
                    }
                    break;
                case "destroyer":
                    {
                        npc = TShock.Utils.GetNPCById(134);
                        TSPlayer.Server.SetTime(false, 0.0);
                    }
                    break;
                case "skeletronprime":
                    {
                        npc = TShock.Utils.GetNPCById(127);
                        TSPlayer.Server.SetTime(false, 0.0);
                    }
                    break;
            }

            if (npc != null)
                for (int i = 0; i < amount; i++)
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, 1, sPly.TSPlayer.TileX, sPly.TSPlayer.TileY);
        }
Ejemplo n.º 32
0
 bool chargeSign(scPlayer sPly)
 {
     try
     {
         int NewBalance = Vault.Vault.GetBalance(sPly.TSPlayer.Name) - this.Cost;
         if (NewBalance < 0)
         {
             if (sPly.AlertCooldownCooldown == 0)
             {
                 sPly.TSPlayer.SendMessage(string.Format("You must have at least {0} to execute this sign!", Vault.Vault.MoneyToString(this.Cost)), Color.OrangeRed);
                 sPly.AlertCooldownCooldown = 3;
             }
             return false;
         }
         if (!Vault.Vault.SetBalance(sPly.TSPlayer.Name, NewBalance, false))
         {
             if (sPly.AlertCooldownCooldown == 0)
             {
                 sPly.TSPlayer.SendMessage("Changing your balance failed!", Color.OrangeRed);
                 sPly.AlertCooldownCooldown = 3;
             }
             return false;
         }
         sPly.TSPlayer.SendMessage("Charged {0}, Your balance is now {1}!".SFormat(Vault.Vault.MoneyToString(this.Cost), Vault.Vault.MoneyToString(NewBalance)), Color.OrangeRed);
         return true;
     }
     catch { return true; }
 }
Ejemplo n.º 33
0
 bool chargeSign(scPlayer sPly)
 {
     try
     {
         var account = Wolfje.Plugins.SEconomy.SEconomyPlugin.GetEconomyPlayerSafe(sPly.Index).BankAccount;
         var CostString = new Wolfje.Plugins.SEconomy.Money((long)this.Cost).ToString();
         if (account.Balance < this.Cost)
         {
             if (sPly.AlertCooldownCooldown == 0)
             {
                 Send.Error(sPly.TSPlayer, "You must have at least {0} to execute this sign.", CostString);
                 sPly.AlertCooldownCooldown = 3;
             }
             return false;
         }
         account.Balance -= this.Cost;
         Send.Error(sPly.TSPlayer, "Charged {0}, Your balance is now {1}.", CostString, account.Balance.ToString());
         return true;
     }
     catch { return true; }
 }
        public static void HandleKits(TSPlayer tplayer, scPlayer doplay, string KitName)
        {
            try
            {
                Kits.Kit k = Kits.Kits.FindKit(KitName.ToLower());

                if (k == null)
                {
                    if (doplay.toldalert <= 0)
                    {
                        doplay.toldalert = 3;
                        tplayer.SendMessage("Error: The specified kit does not exist.", Color.Red);
                    }
                    return;
                }

                if (tplayer.Group.HasPermission(k.getPerm()))
                {
                    k.giveItems(tplayer);
                    if (getConfig.GlobalKitCooldown)
                        GlobalKitCooldown = getConfig.KitCooldown;
                    else
                        doplay.CooldownKit = getConfig.KitCooldown;
                }
                else
                {
                    if (doplay.toldalert <= 0)
                    {
                        doplay.toldalert = 3;
                        tplayer.SendMessage(string.Format("You do not have permission to use the {0} kit.", KitName), Color.Red);
                    }
                }
            }
            catch { }
        }
Ejemplo n.º 35
0
        public void ExecuteCommands(scPlayer sPly)
        {
            #region Check Cooldown
            if (!sPly.TSPlayer.Group.HasPermission("essentials.signs.nocooldown") && this.Cooldown > 0)
            {
                if (this.CooldownGroup.StartsWith("global-"))
                {
                    lock (SignCommands.GlobalCooldowns)
                    {
                        if (!SignCommands.GlobalCooldowns.ContainsKey(this.CooldownGroup))
                            SignCommands.GlobalCooldowns.Add(this.CooldownGroup, DateTime.UtcNow.AddSeconds(this.Cooldown));
                        else
                        {
                            if (SignCommands.GlobalCooldowns[this.CooldownGroup] > DateTime.UtcNow)
                            {
                                if (sPly.AlertCooldownCooldown == 0)
                                {
                                    sPly.TSPlayer.SendMessage(string.Format("Everyone must wait another {0} seconds before using this sign!", (int)(SignCommands.GlobalCooldowns[this.CooldownGroup] - DateTime.UtcNow).TotalSeconds), Color.OrangeRed);
                                    sPly.AlertCooldownCooldown = 3;
                                }
                                return;
                            }
                            else
                                SignCommands.GlobalCooldowns[this.CooldownGroup] = DateTime.UtcNow.AddSeconds(this.Cooldown);
                        }
                    }
                }
                else
                {
                    lock (sPly.Cooldowns)
                    {
                        string CooldownID = string.Concat(this.Position.ToString());
                        if (this.CooldownGroup != string.Empty)
                            CooldownID = this.CooldownGroup;

                        if (!sPly.Cooldowns.ContainsKey(CooldownID))
                            sPly.Cooldowns.Add(CooldownID, DateTime.UtcNow.AddSeconds(this.Cooldown));
                        else
                        {
                            if (sPly.Cooldowns[CooldownID] > DateTime.UtcNow)
                            {
                                if (sPly.AlertCooldownCooldown == 0)
                                {
                                    sPly.TSPlayer.SendMessage(string.Format("You must wait another {0} seconds before using this sign!", (int)(sPly.Cooldowns[CooldownID] - DateTime.UtcNow).TotalSeconds), Color.OrangeRed);
                                    sPly.AlertCooldownCooldown = 3;
                                }
                                return;
                            }
                            else
                                sPly.Cooldowns[CooldownID] = DateTime.UtcNow.AddSeconds(this.Cooldown);
                        }
                    }
                }
            }
            #endregion

            #region Check Cost
            if (SignCommands.UsingVault && this.Cost > 0 && !chargeSign(sPly))
                return;
            #endregion

            int DoesntHavePermission = 0;
            foreach (scCommand cmd in this.Commands)
            {
                if (!sPly.TSPlayer.Group.HasPermission(string.Format("essentials.signs.use.{0}", cmd.command)))
                {
                    DoesntHavePermission++;
                    continue;
                }

                cmd.ExecuteCommand(sPly);
            }

            if (DoesntHavePermission > 0 && sPly.AlertPermissionCooldown == 0)
            {
                sPly.TSPlayer.SendMessage(string.Format("You do not have permission to use {0} command(s) on that sign!", DoesntHavePermission), Color.OrangeRed);
                sPly.AlertPermissionCooldown = 5;
            }
        }
Ejemplo n.º 36
0
        public static void CMDwarp(scPlayer sPly, List<string> args)
        {
            if (args.Count < 1) return;

            string WarpName = args[0];

            var Warp = TShock.Warps.Find(WarpName);

            if (Warp != null && Warp.Name != "" && Warp.Position.X > 0 && Warp.Position.Y > 0)
                sPly.TSPlayer.Teleport(Warp.Position.X * 16F, Warp.Position.Y * 16F);
        }