Ejemplo n.º 1
0
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            string cmd = text.Split(' ')[0];

            if (cmd == "/duel" && TShockAPI.TShock.Utils.FindPlayer(text.Split(' ')[1]).Count == 1)
            {
                TSPlayer challenged = TShockAPI.TShock.Utils.FindPlayer(text.Split(' ')[1])[0];
                TSPlayer challenger = TShock.Players[ply];
                if (challenger.IsLoggedIn && challenged.IsLoggedIn)
                {
                    int challengerbal =
                        ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(challenger.Index).DisplayAccount;
                    if (challengerbal >= GetCEPlayer(ply).Bet)
                    {
                        GetCEPlayer(ply).challenged = challenged.Index;
                        challenger.SendMessage(
                            "You challenged " + challenged.Name + " to a duel for " + GetCEPlayer(ply).Bet.ToString() +
                            " " + ServerPointSystem.ServerPointSystem.currname + "s", Color.Teal);
                        challenger.SendMessage(
                            challenger.Name + " has  challenged you" + challenged.Name + " to a duel for " +
                            GetCEPlayer(ply).Bet.ToString() + " " + ServerPointSystem.ServerPointSystem.currname + "s",
                            Color.Teal);
                        foreach (CEPlayer ceplayerctr in WhoChallengedThisGuy(challenged.Index))
                        {
                            if (ceplayerctr.ID != ply)
                            {
                                GetCEPlayer(ceplayerctr.ID).challenged = -1;
                            }
                        }
                    }
                    else
                    {
                        e.Handled = true;
                        challenger.SendMessage(
                            "You don't have enough " + ServerPointSystem.ServerPointSystem.currname +
                            "s to do that! Lower your bet", Color.Red);
                    }
                }
                return;
            }
            else if (cmd == "/accept")
            {
                if (WhoChallengedThisGuy(ply).Count > 0)
                {
                    TSPlayer  challenger  = TShock.Players[WhoChallengedThisGuy(ply)[0].ID];
                    TSPlayer  challenged  = TShock.Players[ply];
                    EPRPlayer Echallenger = ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(challenger.Index);
                    EPRPlayer Echallenged = ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(challenged.Index);
                    if (challenger.IsLoggedIn && challenged.IsLoggedIn)
                    {
                        int challengerbal = Echallenger.DisplayAccount;
                        int challengedbal = Echallenged.DisplayAccount;
                        int wager         = GetCEPlayer(challenger.Index).Bet;
                        if (challengerbal >= wager && challengedbal >= wager)
                        {
                            GetCEPlayer(challenged.Index).DuelReward = wager;
                            GetCEPlayer(challenger.Index).DuelReward = wager;
                            EPREvents.PointUse(Echallenger, wager, PointUsage.Bet);
                            EPREvents.PointUse(Echallenged, wager, PointUsage.Bet);
                        }
                        else
                        {
                            challenger.SendMessage(
                                "Error processing dueling bets. Either you or your opponent does not have enough " +
                                ServerPointSystem.ServerPointSystem.currname + "s", Color.Red);
                            challenged.SendMessage(
                                "Error processing dueling bets. Either you or your opponent does not have enough " +
                                ServerPointSystem.ServerPointSystem.currname + "s", Color.Red);
                            e.Handled = true;
                        }
                    }
                }
                return;
            }
            return;
        }
Ejemplo n.º 2
0
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            string cmd = text;

            if (TShock.Players[ply].IsLoggedIn && text.StartsWith("/"))
            {
                Command chckcmd = TShockAPI.Commands.ChatCommands.Find(fcmd => fcmd.Names.Contains(cmd.Split(' ')[0].Remove(0, 1)));
                if (chckcmd != null)
                {
                    if (TShock.Players[ply].Group.HasPermission(chckcmd.Permission))
                    {
                        EPRPlayer player = ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(ply);
                        bool      block  = false;
                        bool      charge = false;
                        int       cost   = 0;
                        foreach (CommandParser cmdprsr in CommandParserList)
                        {
                            if (cmdprsr.BlockType == BlockType.BlockStartsWith && !TShock.Players[ply].Group.HasPermission(cmdprsr.BlockOverridePermission) && cmdprsr.BlockOverridePermission != "" && cmd.ToLower().StartsWith(cmdprsr.Command.ToLower()))
                            {
                                block = true;
                            }
                            else if (cmdprsr.BlockType == BlockType.BlockEqualsTo && !TShock.Players[ply].Group.HasPermission(cmdprsr.BlockOverridePermission) && cmdprsr.BlockOverridePermission != "" && cmd.ToLower().Equals(cmdprsr.Command.ToLower()))
                            {
                                block = true;
                            }

                            if (cmdprsr.ChargeType == ChargeType.StartsWith && cmd.ToLower().StartsWith(cmdprsr.Command.ToLower()))
                            {
                                charge = true;
                                if (cmdprsr.Cost > 0)
                                {
                                    cost = cmdprsr.Cost;
                                }
                                if (TShock.Players[ply].Group.HasPermission(cmdprsr.CostOverridePermission.ToLower()) && cmdprsr.CostOverridePermission != "")
                                {
                                    cost = 0;
                                }
                            }
                            else if (cmdprsr.ChargeType == ChargeType.EqualsTo && cmd.ToLower().Equals(cmdprsr.Command.ToLower()))
                            {
                                charge = true;
                                if (cmdprsr.Cost > 0)
                                {
                                    cost = cmdprsr.Cost;
                                }
                                if (TShock.Players[ply].Group.HasPermission(cmdprsr.CostOverridePermission.ToLower()) && cmdprsr.CostOverridePermission != "")
                                {
                                    cost = 0;
                                }
                            }
                        }
                        if (block)
                        {
                            e.Handled = true;
                            return;
                        }
                        else if (!block && charge && cost > 0)
                        {
                            if (player.DisplayAccount >= cost)
                            {
                                EPREvents.PointUse(player, cost, PointUsage.Command);
                                player.TSPlayer.SendMessage(string.Format("Command cost you {0} {1}s. You have {2} {1}(s) left", cost, ServerPointSystem.ServerPointSystem.currname, (player.DisplayAccount)), Color.Red);
                                return;
                            }
                            else
                            {
                                player.TSPlayer.SendMessage(string.Format("You do not have enough {0}s to use that command", ServerPointSystem.ServerPointSystem.currname), Color.Red);
                                e.Handled = true;
                                return;
                            }
                        }
                    }
                }
            }
            return;
        }
Ejemplo n.º 3
0
        private static void Rank(CommandArgs args)
        {
            if (args.Parameters.Count > 0)
            {
                if (args.Player.IsLoggedIn)
                {
                    string cmd = "help";
                    cmd = args.Parameters[0].ToLower();
                    switch (cmd)
                    {
                    case "change":
                    {
                        if (!args.Player.Group.HasPermission("dontrankme"))
                        {
                            if (args.Parameters.Count > 1)
                            {
                                int RankLineID = GetRankLineIDByLineName(args.Parameters[1]);
                                if (RankLineID >= 0)
                                {
                                    if (!RankConfig.RankLineRestrictons[RankLineID])
                                    {
                                        Group           Group = TShockAPI.TShock.Utils.GetGroup(RankConfig.Ranks[RankLineID][0]);
                                        List <SqlValue> list  = new List <SqlValue>();
                                        List <SqlValue> where = new List <SqlValue>();
                                        where.Add(new SqlValue("Username", "'" + args.Player.UserAccountName + "'"));
                                        list.Add(new SqlValue("Usergroup", "'" + Group.Name + "'"));
                                        SQLEditor.UpdateValues("Users", list, where);
                                        args.Player.SendMessage("You changed rank from " + args.Player.Group.Name + " to " + Group.Name, Color.Green);
                                        args.Player.Group = Group;
                                    }
                                    else
                                    {
                                        args.Player.SendMessage("That Rank Line is Restricted!", Color.Red);
                                    }
                                }
                                else
                                {
                                    args.Player.SendMessage("There is no such rank line!", Color.Red);
                                }
                            }
                            else
                            {
                                args.Player.SendMessage("/rank change [Rank Line]", Color.Yellow);
                                args.Player.SendMessage("Warning this will transfer you to the lowest rank in that Rank Line", Color.Yellow);
                            }
                        }
                        else
                        {
                            args.Player.SendMessage("You cannot change your Rank Line", Color.Red);
                        }

                        break;
                    }

                    case "check":
                    {
                        int RankLineID = GetRankLineIDByRank(args.Player.Group.Name);
                        int RankID     = -1;
                        if (RankLineID >= 0)
                        {
                            RankID = GetRankID(args.Player.Group.Name, RankLineID);
                        }
                        if (RankID >= 0)
                        {
                            args.Player.SendMessage(RankConfig.RankCheckMessage[RankLineID][RankID], Color.AntiqueWhite);
                        }
                        else
                        {
                            args.Player.SendMessage("Your group: " + args.Player.Group.Name + " isn't part of the ranking system", Color.Red);
                        }
                        break;
                    }

                    case "up":
                    {
                        EPRPlayer       player = ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(args.Player.Index);
                        List <SqlValue> where2 = new List <SqlValue>();
                        where2.Add(new SqlValue("Username", "'" + args.Player.UserAccountName.ToString() + "'"));
                        int currbal    = player.DisplayAccount;
                        int RankLineID = GetRankLineIDByRank(args.Player.Group.Name);
                        int RankID     = -1;
                        if (RankLineID >= 0)
                        {
                            RankID = GetRankID(args.Player.Group.Name, RankLineID);
                        }
                        if (RankID >= 0 && RankID < (RankConfig.Ranks[RankLineID].Length - 1))
                        {
                            int RankUpCost = RankConfig.RankUpCost[RankLineID][RankID];
                            if (currbal >= RankUpCost)
                            {
                                EPREvents.PointUse(player, RankUpCost, PointUsage.Rank);
                                List <SqlValue> list2 = new List <SqlValue>();
                                list2.Add(new SqlValue("Usergroup", "'" + RankConfig.Ranks[RankLineID][RankID + 1] + "'"));
                                SQLEditor.UpdateValues("Users", list2, where2);
                                args.Player.SendMessage(RankConfig.RankUpMessage[RankLineID][RankID], Color.AntiqueWhite);
                                args.Player.Group = TShockAPI.TShock.Utils.GetGroup(RankConfig.Ranks[RankLineID][RankID + 1]);
                            }
                            else
                            {
                                args.Player.SendMessage(RankConfig.RankCheckMessage[RankLineID][RankID], Color.AntiqueWhite);
                            }
                        }
                        else if (RankID >= 0 && RankID == (RankConfig.Ranks[RankLineID].Length - 1))
                        {
                            args.Player.SendMessage(RankConfig.RankCheckMessage[RankLineID][RankID], Color.AntiqueWhite);
                        }
                        else
                        {
                            args.Player.SendMessage("Your group: " + args.Player.Group.Name + " isn't part of the ranking system", Color.Red);
                        }
                        break;
                    }

                    default:
                        args.Player.SendMessage("Invalid Syntax! try:/rank up or /rank check or /rank change", Color.Yellow);
                        break;
                    }
                }
                else
                {
                    args.Player.SendMessage("You must be logged in to do that!", Color.Red);
                }
            }
            else
            {
                args.Player.SendMessage("Invalid Syntax! try:/rank up or /rank check or /rank change", Color.Yellow);
            }
        }
Ejemplo n.º 4
0
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            string cmd = text.Split(' ')[0];

            if (TShock.Players[ply].IsLoggedIn)
            {
                EPRPlayer player = ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(ply);
                if (cmd == "/warp")
                {
                    if (text.Split(' ').Length > 1)
                    {
                        if (TShock.Warps.FindWarp(text.Split(' ')[1]).WarpPos != Vector2.Zero)
                        {
                            if (!TShock.Players[ply].Group.HasPermission("freewarp"))
                            {
                                int             warpcosttemp = warpcost;
                                int             currbal      = player.DisplayAccount;
                                string          warpname     = text.Split(' ')[1];
                                List <SqlValue> where2       = new List <SqlValue>();
                                where2.Add(new SqlValue("Command", "'" + "warp " + warpname + "'"));
                                if (SQLEditor.ReadColumn("CommandCosts", "Cost", where2).Count == 1)
                                {
                                    warpcosttemp = Int32.Parse(SQLEditor.ReadColumn("CommandCosts", "Cost", where2)[0].ToString());
                                }
                                if (currbal < warpcosttemp)
                                {
                                    TShock.Players[ply].SendMessage("You do not have enough " + ServerPointSystem.ServerPointSystem.currname + "s!", Color.Red);
                                    TShock.Players[ply].SendMessage("You need " + warpcosttemp + " " + ServerPointSystem.ServerPointSystem.currname + "s to use that command", Color.Red);
                                    e.Handled = true;
                                    return;
                                }
                                else
                                {
                                    EPREvents.PointUse(player, warpcosttemp, PointUsage.Command);
                                    player.TSPlayer.SendMessage(string.Format("Warped to {0} for {1} {2}(s)", warpname, warpcosttemp, ServerPointSystem.ServerPointSystem.currname), Color.Yellow);
                                    return;
                                }
                            }
                            //else
                            //    return;
                        }
                        //else
                        //    return;
                    }
                    //else
                    return;
                }
                else if (cmd == "/heal")
                {
                    if (!TShock.Players[ply].Group.HasPermission("freeheal"))
                    {
                        int currbal = player.DisplayAccount;
                        if (currbal < healcost)
                        {
                            TShock.Players[ply].SendMessage("You do not have enough " + ServerPointSystem.ServerPointSystem.currname + "s!", Color.Red);
                            TShock.Players[ply].SendMessage("You need " + healcost + " " + ServerPointSystem.ServerPointSystem.currname + "s to use that command", Color.Red);
                            e.Handled = true;
                            return;
                        }
                        else
                        {
                            EPREvents.PointUse(player, healcost, PointUsage.Command);
                            return;
                        }
                    }
                }
                else if (cmd == "/tp")
                {
                    if (!TShock.Players[ply].Group.HasPermission("freetp"))
                    {
                        int currbal = player.DisplayAccount;
                        if (currbal < tpcost)
                        {
                            TShock.Players[ply].SendMessage("You do not have enough " + ServerPointSystem.ServerPointSystem.currname + "s!", Color.Red);
                            TShock.Players[ply].SendMessage("You need " + tpcost + " " + ServerPointSystem.ServerPointSystem.currname + "s to use that command", Color.Red);
                            e.Handled = true;
                            return;
                        }
                        else
                        {
                            EPREvents.PointUse(player, tpcost, PointUsage.Command);
                            return;
                        }
                    }
                }
                else if (cmd == "/buff")
                {
                    if (!TShock.Players[ply].Group.HasPermission("freebuff"))
                    {
                        int currbal = player.DisplayAccount;
                        if (currbal < buffcost)
                        {
                            TShock.Players[ply].SendMessage("You do not have enough " + ServerPointSystem.ServerPointSystem.currname + "s!", Color.Red);
                            TShock.Players[ply].SendMessage("You need " + buffcost + " " + ServerPointSystem.ServerPointSystem.currname + "s to use that command", Color.Red);
                            e.Handled = true;
                            return;
                        }
                        else
                        {
                            EPREvents.PointUse(player, buffcost, PointUsage.Command);
                        }
                    }
                }
            }
            return;
        }