Exemplo n.º 1
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#sit")
            {
//                if (CommandArray.Length < 3)
//                    goto WrongArguments;
//
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#sit", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#move", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                TheTCPWrapper.Send(CommandCreator.SIT_DOWN(true));
            }
            if (CommandArray[0] == "#stand")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#stand", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#tl", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                TheTCPWrapper.Send(CommandCreator.SIT_DOWN(false));
            }
            return;
            //WrongArguments:
            //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #move command:   "));
            //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#move x y                                 "));
            //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #move 192 168                    "));
            //    return;
        }
Exemplo n.º 2
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#canceltrade")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#canceltrade", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("canceltrade", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                TheTCPWrapper.Send(CommandCreator.EXIT_TRADE());
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "The trade was cancelled!"));
                return;
            }
        }
Exemplo n.º 3
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#isonline")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#isonline", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#isonline", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray.Length < 2)
                {
                    goto WrongArguments;
                }
                string playerName     = CommandArray[1];
                bool   playerIsOnline = false;
                string serverName     = "live";
                if (CommandArray.Length == 3)
                {
                    serverName = CommandArray[2];
                }
                if ((playerIsOnline = TheMySqlManager.isPlayerOnline(e.username, playerName, serverName)))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, playerName + " is online on the " + serverName + " server."));
                }
                else
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, playerName + " is not online on the " + serverName + " server."));
                }
                return;

WrongArguments:
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #isonline command:"));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#isonline <playername> <server>            "));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #isonline DogBreath test          "));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
                return;
            }
        }
Exemplo n.º 4
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#pm")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#pm", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#pm", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                int i;
                Message = "";

                if (CommandArray.Length < 3)
                {
                    goto WrongArguments;
                }

                for (i = 2; i < CommandArray.Length; i++)
                {
                    Message += CommandArray[i] + " ";
                }
                Message = Message.Trim();
                TheTCPWrapper.Send(CommandCreator.SEND_PM(CommandArray[1], Message));
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "-------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Here is the usage of the #pm command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#pm <username> <message>             "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "-------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #pm artem Hi, how are You?  "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "-------------------------------------"));
            return;
        }
Exemplo n.º 5
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#useobject")
            {
                if (CommandArray.Length < 2)
                {
                    goto WrongArguments;
                }

                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#useobject", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#useobject", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray[1].Contains(","))
                {
                    goto WrongArguments;
                }
                int objectid = int.Parse(CommandArray[1]);
                TheTCPWrapper.Send(CommandCreator.USE_MAP_OBJECT((uint)objectid, -1));
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #useobject command:   "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#useobject x                                   "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-----------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #useobject 520                        "));
            return;
        }
Exemplo n.º 6
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int    lineSize = 56;
            string Message  = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#adminhelp")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#adminhelp", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#adminhelp", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '-')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[List of admin commands:".PadRight(lineSize, ' ')));

                // display the admin help commands
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '=')));
                foreach (string MyCommand in CommandArrayList)
                {
                    if (!MyCommand.ToLower().Contains("null"))
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[" + MyCommand.PadRight(lineSize - 1, ' ')));
                    }
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '=')));
            }
        }
Exemplo n.º 7
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#gt")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#gt", Settings.botid);

                if (disabled == true)
                {
                    //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (e.username.ToLower() != "gossip")
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                string name = "", temp = "", guild = "";
                temp = CommandArray[1].Trim();
                if (guild == "")
                {
                    guild = "";
                }
                if (guild.ToLower() == "noexist")
                {
                    return;
                }
                TheMySqlManager.UpdatePlayer(name, guild);
            }
            return;
        }
Exemplo n.º 8
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#kickme")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#kickme", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#kickme", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheMySqlManager.CheckIfGuildMember(e.username, Settings.botid) == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, but you are not a guild member."));
                    return;
                }

                Message = "#remove " + e.username;

                TheTCPWrapper.Send(CommandCreator.RAW_TEXT(Message));
            }

            return;
        }
Exemplo n.º 9
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#quit" || CommandArray[0] == "#exit" || CommandArray[0] == "#shutdown")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#quit", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#quit", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                //if (TheTradeHandler.AmITrading())
                //{
                //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                //    return;
                //}

                //shut the bot down here
                //TheMessageParser.FakePM("Console:\\>", "#say  Returning to my slumber...  Wake me at your own risk!");
                //                TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#gm ### SHUTTING DOWN UNTIL NEEDED AGAIN ###"));
                TheMessageParser.FakePM("Console:\\>", "#say #gm ### SHUTTING DOWN UNTIL NEEDED AGAIN ###");
                TheMySqlManager.ImLoggedOut(Settings.botid);
                return;
            }
        }
Exemplo n.º 10
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }
            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#acceptme")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#acceptme", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#acceptme", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheMySqlManager.CheckIfGuildMember(e.username, Settings.botid) == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, but you are not a guild member."));
                    return;
                }

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "If you don't get accepted check if you have typed in #join_guild " + TheMySqlManager.guildlongname(Settings.botid) + " before using this command."));

                TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#accept " + e.username));
            }

            return;
        }
Exemplo n.º 11
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#whoistrading")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#whoistrading", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#quit", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (TradeHandler.username == "")
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "No one is trading with me."));
                }
                else
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, TradeHandler.username + " is trading with me."));
                }
//                TheMessageParser.FakePM("Console:\\>", "#say #gm ### SHUTTING DOWN UNTIL NEEDED AGAIN ###");
//                TheMySqlManager.ImLoggedOut(Settings.botid);
                return;
            }
        }
Exemplo n.º 12
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#loc" || CommandArray[0].ToLower() == "#l" || CommandArray[0].ToLower() == "#location" || CommandArray[0].ToLower() == "#lo" || CommandArray[0].ToLower() == "#where")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#loc", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#loc", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                string locString = "I am in " + Settings.LocationInfo;
                if (Settings.ServerPort == 2001)
                {
                    locString += "(" + MainClass.mapName + ")";
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, locString));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, TheMySqlManager.locationdescription(Settings.botid).Trim()));
            }

            return;
        }
Exemplo n.º 13
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int nameToID = -1;

            username = e.username;

            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#useitem")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled(CommandArray[0], Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (CommandArray[0] == "#useitem")
                {
                    if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#useitem", Settings.botid))
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                        return;
                    }
                }

                if (TheTradeHandler.AmITrading())
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                    return;
                }

                if (TheInventory.GettingInventoryItems == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for me to finish getting my inventory..."));
                    return;
                }


                try
                {
                    if (CommandArray.Length < 2)
                    {
                        goto WrongArguments;
                    }
                    string str = "";
                    int    i;
                    for (i = 1; i < CommandArray.Length; i++)
                    {
                        str += CommandArray[i] + " ";
                    }
                    str = str.Trim();
                    if (str == "")
                    {
                        goto WrongArguments;
                    }
                    nameToID = TheMySqlManager.GetItemID(str, Settings.botid, false);
                    if (nameToID == -1)
                    {
                        SQLID = int.Parse(CommandArray[1]);
                    }
                    if (nameToID != -1)
                    {
                        SQLID = nameToID;
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
                username = e.username;
                UseItem(SQLID);
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Usage of the #useitem command:         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|#useitem <item>                        "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #useitem ring of portland     "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            return;
        }
Exemplo n.º 14
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#say" || CommandArray[0].ToLower() == "#s")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#say", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#say", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                int i;
                Message = "";

                if (CommandArray.Length < 2)
                {
                    goto WrongArguments;
                }

                for (i = 1; i < CommandArray.Length; i++)
                {
                    Message += CommandArray[i];
                    if (i < CommandArray.Length - 1)
                    {
                        Message += " ";
                    }
                }
                if (Message.ToLower().Contains("#killme") ||
                    Message.ToLower().Contains("#reset") ||
                    Message.ToLower().Contains("#abuse") ||
                    Message.ToLower().Contains("#help_me") ||
                    Message.ToLower().Contains("#suicide") ||
                    Message.ToLower().Contains("#destroy_guild") ||
                    (Message.ToLower().Contains("#beam") && TheMySqlManager.GetUserRank(e.username, Settings.botid) < 100) ||
                    (Message.ToLower().Contains("#change_owner") && TheMySqlManager.GetUserRank(e.username, Settings.botid) < 100))
                {
                    TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#GM " + System.Convert.ToChar(141) + "ALERT " + e.username + " tried to get me to send a prohibited command"));
                    TheTCPWrapper.Send(CommandCreator.RAW_TEXT("#GM " + System.Convert.ToChar(136) + Message));
                }
                else
                {
                    TheTCPWrapper.Send(CommandCreator.RAW_TEXT(Message));
                }
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Here is the usage of the #say command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#say <message>"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #say Hi, how are You?"));
            return;
        }
Exemplo n.º 15
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#donate" || CommandArray[0] == "#donation" || (CommandArray[0] == "#d" && CommandArray.Length == 1))
            {
                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#donate", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#donate", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (Settings.IsTradeBot == false && TheTradeHandler.storageAvailable == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I am not a trade bot!"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#donate", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheTradeHandler.Trading == false || TradeHandler.username.ToLower() != e.username.ToLower())
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please trade with me first!"));
                    return;
                }

                if (TheTradeHandler.storageAvailable == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Items will be put in my inventory."));
                    TheTradeHandler.storageAvailable = false;
                }

                try
                {
                    if (CommandArray.Length != 1 && CommandArray[1] != "")
                    {
                        goto WrongArguments;
                    }

                    if (TheTradeHandler.PutOnSale == false && TheTradeHandler.Billance == 0 && TheTradeHandler.PartnerTradeItemsList.Count == 0 && TheTradeHandler.MyItemList.Count == 0)
                    {
                        TheTradeHandler.Donating = true;
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You can donate to me now."));
//                        if (Settings.IsTradeBot == false)
//                        {
//                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Move me away from storage if you want to donate into my inventory..."));
//                        }
                    }
                    else
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Plese restart the trade. And put no items on the trade before sending #donate."));
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Here is the usage of the #donate command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#donate"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #donate"));
            return;
        }
Exemplo n.º 16
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv = new string[64];

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');
            if (CommandArray[0] == "#withdraw")
            {
                username = e.username;
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#withdraw", Settings.botid);


                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);

                if (rank < TheMySqlManager.GetCommandRank("#withdraw", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }

                if (TheStorage.TheStorageCategories.Count == 0)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You must open storage first!"));
                    return;
                }

                if (TradeHandler.openingStorage)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for storage to finish opening!"));
                    return;
                }

                if (TheInventory.GettingInventoryItems == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for me to finish getting my inventory..."));
                    return;
                }

                //ok, let's do a withdraw
                totalWithdrawn = 0;
                string itemName = "";
                int    SQLID    = -1;
                int    nameToID = -1;
                string str      = "";
                try
                {
                    if (CommandArray.Length < 2)
                    {
                        goto WrongArguments;
                    }
                    if (CommandArray.Length < 3)
                    {
                        quantity = 1;
                        try
                        {
                            SQLID    = int.Parse(CommandArray[1]);
                            nameToID = SQLID;
                        }
                        catch
                        {
                            itemName = CommandArray[1] + " ";
                            nameToID = TheMySqlManager.GetItemID(CommandArray[1], Settings.botid, true);
                        }
                    }
                    if (CommandArray.Length > 2)
                    {
                        int i;
                        try
                        {
                            quantity = uint.Parse(CommandArray[1]);
                            for (i = 2; i < CommandArray.Length; i++)
                            {
                                str += CommandArray[i] + " ";
                            }
                        }
                        catch
                        {
                            quantity = 1;
                            for (i = 1; i < CommandArray.Length; i++)
                            {
                                str += CommandArray[i] + " ";
                            }
                        }
                        finally
                        {
                            str      = str.Trim();
                            nameToID = TheMySqlManager.GetItemID(str, Settings.botid, true);
                            itemName = str + " ";
                        }
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
                finally
                {
                    try
                    {
                        SQLID = int.Parse(str);
                    }
                    catch
                    {
                        SQLID = nameToID;
                    }
                }
                //Console.WriteLine(quantity + " " + SQLID);
                //try
                //{
                //    quantity = UInt32.Parse(CommandArray[1]);
                //    try
                //    {
                //        SQLID = int.Parse(CommandArray[2]);
                //    }
                //    catch
                //    {
                //        for (int i = 2; i < CommandArray.Length; i++)
                //        {
                //            itemName += CommandArray[i] + " ";
                //        }
                //        SQLID = TheMySqlManager.GetItemID(itemName, Settings.botid, true);
                //    }
                //}
                //catch
                //{
                //    quantity = 1;
                //    try
                //    {
                //        SQLID = int.Parse(CommandArray[1]);
                //    }
                //    catch
                //    {
                //        for (int i = 1; i < CommandArray.Length; i++)
                //        {
                //            itemName += CommandArray[i] + " ";
                //        }
                //        SQLID = TheMySqlManager.GetItemID(itemName,Settings.botid, true);
                //    }
                //}
                System.Collections.ArrayList StorageSnapshot = new System.Collections.ArrayList();
                StorageSnapshot = TheStorage.GetStorageList();
                int total_items = StorageSnapshot.Count;

                //Console.WriteLine(quantity + "|" + itemName + "|" + SQLID);
                //Console.WriteLine("total items: " + total_items);
                for (int i = 0; i < total_items; i++)
                {
                    MyStorageItem = (Storage.StorageItem)StorageSnapshot[i];
                    if (MyStorageItem.knownItemsID == SQLID)
                    {
                        TheTradeHandler.makingWithdraw = true;
                        //Console.WriteLine(MyStorageItem.pos + MyStorageItem.name + MyStorageItem.knownItemsID + "|" + MyStorageItem.quantity);
                        TheTCPWrapper.Send(CommandCreator.GET_STORAGE_CATEGORY((byte)MyStorageItem.category_num));
                        break;
                    }
                }
                if (!TheTradeHandler.makingWithdraw)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I don't seem to have any " + itemName + "in storage!"));
                }
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #withdraw command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#withdraw amt item                         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #withdraw 1 silver ore            "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
            return;
        }
Exemplo n.º 17
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int    lineSize = 55;
            string Message  = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#help" || CommandArray[0] == "#h")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#help", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#help", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '-')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[List of available basic commands:".PadRight(lineSize, ' ')));

                // display a list of commands/text
                // for now, gonna cluge in some important ones being listed first
                // later I'll either add an element to the array or use the database to build the list

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '-')));
                foreach (string MyCommand in CommandArrayList)
                {
                    if (!MyCommand.ToLower().Contains("null"))
                    {
                        if (MyCommand.ToLower().Contains("#inv") || MyCommand.ToLower().Contains("#buy") || MyCommand.ToLower().Contains("#wanted") ||
                            MyCommand.ToLower().Contains("#loc"))
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[" + MyCommand.PadRight(lineSize - 1, ' ')));
                        }
                    }
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '-')));

                foreach (string MyCommand in CommandArrayList)
                {
                    if (!MyCommand.ToLower().Contains("null") && !MyCommand.ToLower().Contains("#buy") && !MyCommand.ToLower().Contains("#wanted") &&
                        !MyCommand.ToLower().Contains("#loc"))
                    {
                        if (!MyCommand.ToLower().Contains("#inv"))
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[" + MyCommand.PadRight(lineSize - 1, ' ')));
                        }
                    }
                }

                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '=')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[" + Settings.URL.PadRight(lineSize - 1, ' ')));
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[".PadRight(lineSize, '=')));
                //				TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username,"To see the usage of the commands write help after the command. Example: #buy help"));
            }
        }
Exemplo n.º 18
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#openstorage" || CommandArray[0] == "#os")
            {
                if (CommandArray.Length > 2)
                {
                    goto WrongArguments;
                }
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#openstorage", Settings.botid);
                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }
                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#openstorage", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                string npcName = "";
                if (CommandArray.Length > 1)
                {
                    npcName = CommandArray[1];
                }
                if (npcName == "")
                {
                    //get the npc name from their storage selection...
                    npcName = TheMySqlManager.getStorageNPCName();
                }
                int storageActorID         = TheActorHandler.GetUserIDFromname(npcName);
                ActorHandler.Actor myActor = (ActorHandler.Actor)TheActorHandler.ActorsHashTable[TheActorHandler.GetUserIDFromname(npcName)];
                try
                {
                    if (myActor.kind_of_actor == 2)
                    {
                        TheTCPWrapper.Send(CommandCreator.TOUCH_PLAYER((uint)storageActorID));
                        TheTCPWrapper.Send(CommandCreator.RESPOND_TO_NPC((ushort)storageActorID));
                        TradeHandler.openingStorage = true;
                        TradeHandler.storageOpen    = false;
                        TradeHandler.username       = e.username;
                        Settings.IsTradeBot         = false;
                    }
                }
                catch
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "It appears that " + npcName + " is not a storage NPC! (or I'm not in range...)"));
                }
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #openstorage command: "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#openstorage <name>                            "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-----------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #openstorage                          "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #openstorage raven                    "));
            return;
        }
Exemplo n.º 19
0
        //private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        //{
        //    uint quantity = 0;
        //    int SQLID = 0;
        //    int nameToID = -1;
        //    uint ItemsPlacedOnTrade = 0;

        //    string Message = e.Message.ToLower();

        //    if (Message[0] != '#')
        //    {
        //        Message = "#" + Message;
        //    }

        //    string[] CommandArray = Message.Split(' ');

        //    if (CommandArray[0] == "#buy" || CommandArray[0] == "#b" || CommandArray[0] == "#byt")
        //    {
        //        if (Settings.IsTradeBot == false)
        //        {
        //            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I am not a trade bot!"));
        //            return;
        //        }

        //        bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#buy", Settings.botid);

        //        if (disabled == true)
        //        {
        //            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
        //            return;
        //        }

        //        if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#buy", Settings.botid))
        //        {
        //            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
        //            return;
        //        }

        //        if (TheTradeHandler.Trading == false || TradeHandler.username.ToLower() != e.username.ToLower())
        //        {
        //            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please trade with me first!"));
        //            return;
        //        }

        //        try
        //        {
        //            if (CommandArray.Length < 2)
        //            {
        //                goto WrongArguments;
        //            }
        //            if (CommandArray.Length < 3)
        //            {
        //                quantity = 1;
        //                nameToID = TheMySqlManager.GetItemID(CommandArray[1], Settings.botid, false);
        //                if (nameToID != -1)
        //                {
        //                    SQLID = nameToID;
        //                }
        //                if (nameToID == -1)
        //                {
        //                    SQLID = int.Parse(CommandArray[1]);
        //                }
        //            }
        //            if (CommandArray.Length > 2)
        //            {
        //                string str = "";
        //                int i;
        //                if (!uint.TryParse(CommandArray[1], out quantity))
        //                {
        //                    quantity = 1;
        //                    for (i = 1; i < CommandArray.Length; i++)
        //                    {
        //                        str += CommandArray[i] + " ";
        //                    }
        //                }
        //                else
        //                {
        //                    for (i = 2; i < CommandArray.Length; i++)
        //                    {
        //                        str += CommandArray[i] + " ";
        //                    }
        //                }
        //                str = str.Trim();
        //                nameToID = TheMySqlManager.GetItemID(str, Settings.botid,false);
        //                if (nameToID == -1)
        //                {
        //                    SQLID = int.Parse(CommandArray[2]);
        //                }
        //                if (nameToID != -1)
        //                {
        //                    SQLID = nameToID;
        //                }
        //            }
        //        }
        //        catch
        //        {
        //            goto WrongArguments;
        //        }
        //        if (TheTradeHandler.Donating == true)
        //        {
        //            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I can't sell you items while donating. Please start a new trade session."));
        //            return;
        //        }

        //        System.Collections.Hashtable MySellingItemList = TheMySqlManager.GetSellingItemList(0);

        //        if (MySellingItemList.Contains(SQLID))
        //        {
        //            ItemsPlacedOnTrade = TheTradeHandler.PutItemsOnTrade(SQLID, quantity);
        //            TradeHandler.SellingItem MySellingItem = (TradeHandler.SellingItem)MySellingItemList[SQLID];
        //            if (ItemsPlacedOnTrade > 0)
        //            {
        //                 Check if the user is member if the trade alliance
        //                decimal temp = 0;
        //                if (TheMySqlManager.CheckIfTradeMember(e.username, Settings.botid) == true)
        //                {
        //                    TheTradeHandler.AddTrade(SQLID, MySellingItem.pricesalemembers, ItemsPlacedOnTrade, "sold to");
        //                    temp = (decimal)MySellingItem.pricesalemembers * ItemsPlacedOnTrade;
        //                    TheTradeHandler.ChangeBillance(-(System.Convert.ToInt32(System.Math.Ceiling(temp))));
        //                }
        //                else
        //                {
        //                    TheTradeHandler.AddTrade(SQLID, MySellingItem.pricesale, ItemsPlacedOnTrade, "sold to");
        //                    temp = (decimal)MySellingItem.pricesale * ItemsPlacedOnTrade;
        //                    TheTradeHandler.ChangeBillance(-((System.Convert.ToInt32(System.Math.Ceiling(temp)))));
        //                }
        //            }
        //        }


        //        if (ItemsPlacedOnTrade < quantity)
        //        {
        //            if (ItemsPlacedOnTrade == 0)
        //            {
        //                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I don't have this item!"));
        //            }
        //            else
        //            {
        //                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I only have " + ItemsPlacedOnTrade.ToString() + " of this item!"));
        //            }
        //        }
        //    }

        //    return;

        //WrongArguments:
        //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
        //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Here is the usage of the #buy command: "));
        //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|#buy <quantity> <name or itemid>       "));
        //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
        //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #buy 12 2                     "));
        //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #buy 1 Pickaxe                "));
        //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
        //    return;
        //}
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            uint quantity           = 0;
            int  SQLID              = 0;
            int  nameToID           = -1;
            uint ItemsPlacedOnTrade = 0;

            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#buy" || CommandArray[0] == "#b" || CommandArray[0] == "#byt")
            {
                if (Settings.IsTradeBot == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I am not a trade bot!"));
                    return;
                }

                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#buy", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#buy", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheTradeHandler.Trading == false || TradeHandler.username.ToLower() != e.username.ToLower())
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please trade with me first!"));
                    return;
                }

                if (TheTradeHandler.AcceptStateMe > 0)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You cannont issue more buy commands once I've partially accepted the trade!"));
                    return;
                }
                try
                {
                    if (CommandArray.Length < 2)
                    {
                        goto WrongArguments;
                    }
                    if (CommandArray.Length < 3)
                    {
                        quantity = 1;
                        nameToID = TheMySqlManager.GetItemID(CommandArray[1], Settings.botid, false);
                        if (nameToID != -1)
                        {
                            SQLID = nameToID;
                        }
                        if (nameToID == -1)
                        {
                            SQLID = int.Parse(CommandArray[1]);
                        }
                    }
                    if (CommandArray.Length > 2)
                    {
                        string str = "";
                        int    i;
                        if (!uint.TryParse(CommandArray[1], out quantity))
                        {
                            quantity = 1;
                            for (i = 1; i < CommandArray.Length; i++)
                            {
                                str += CommandArray[i] + " ";
                            }
                        }
                        else
                        {
                            for (i = 2; i < CommandArray.Length; i++)
                            {
                                str += CommandArray[i] + " ";
                            }
                        }
                        str      = str.Trim();
                        nameToID = TheMySqlManager.GetItemID(str, Settings.botid, false);
                        if (nameToID == -1)
                        {
                            SQLID = int.Parse(CommandArray[2]);
                        }
                        if (nameToID != -1)
                        {
                            SQLID = nameToID;
                        }
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
                if (TheTradeHandler.Donating == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I can't sell you items while donating. Please start a new trade session."));
                    return;
                }

                System.Collections.Hashtable MySellingItemList = TheMySqlManager.GetSellingItemList(0);
                bool itemFound = false;
                foreach (int itemId in MySellingItemList.Keys)
                {
                    if (SQLID == itemId)
                    {
                        itemFound = true;
                    }
                }

                if (itemFound)
                {
                    TheTradeHandler.totalCalculated = false;
                    ItemsPlacedOnTrade = TheTradeHandler.PutItemsOnTrade(SQLID, quantity);
                    TradeHandler.SellingItem MySellingItem = (TradeHandler.SellingItem)MySellingItemList[SQLID];
                    if (ItemsPlacedOnTrade > 0)
                    {
                        // Check if the user is member if the trade alliance
                        //decimal temp = 0;
                        if (TheMySqlManager.CheckIfTradeMember(e.username, Settings.botid) == true)
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I sell " + TheMySqlManager.GetKnownItemsname(MySellingItem.KnownItemsSqlID) + " for " + MySellingItem.pricesalemembers + "gc each."));
                            TheTradeHandler.AddTrade(SQLID, MySellingItem.pricesalemembers, ItemsPlacedOnTrade, "sold to");
                            //temp = (decimal)MySellingItem.pricesalemembers * ItemsPlacedOnTrade;
                            //TheTradeHandler.ChangeBillance(-(System.Convert.ToInt32(System.Math.Ceiling(temp))));
                        }
                        else
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I sell " + TheMySqlManager.GetKnownItemsname(MySellingItem.KnownItemsSqlID) + " for " + MySellingItem.pricesale + "gc each."));
                            TheTradeHandler.AddTrade(SQLID, MySellingItem.pricesale, ItemsPlacedOnTrade, "sold to");
                            //temp = (decimal)MySellingItem.pricesale * ItemsPlacedOnTrade;
                            //TheTradeHandler.ChangeBillance(-((System.Convert.ToInt32(System.Math.Ceiling(temp)))));
                        }
                    }
                }


                //if (ItemsPlacedOnTrade < quantity)
                {
                    if (ItemsPlacedOnTrade == 0)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I don't have this item!"));
                    }
                    else if (ItemsPlacedOnTrade < quantity)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I only have " + ItemsPlacedOnTrade.ToString() + " of this item!"));
                    }
                }
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I don't sell this item or invalid syntax"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Here is the usage of the #buy command: "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|#buy <quantity> <name or itemid>       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #buy 12 2                     "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #buy 1 Pickaxe                "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            return;
        }
Exemplo n.º 20
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv          = new string[64];
            int      maxlen       = 4;
            bool     validCommand = false;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');
            if (CommandArray[0] == "#reserve")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#reserve", Settings.botid);

                string str1 = "", str2 = "";

                if (TheInventory.GettingInventoryItems == true)
                {
                    str2 = "I am building my inventory list, please try again in a few seconds";
                    str1 = str1.PadRight(str2.Length, '=');
                    str1 = "[" + str1;
                    str2 = "[" + str2;
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));

                    return;
                }

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);
                if (rank < TheMySqlManager.GetCommandRank("#reserve", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (this.TheTradeHandler.AmITrading() && e.username != TradeHandler.username)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                    return;
                }

                if (CommandArray.Length <= 1)
                {
                    goto WrongArguments;
                }

                if (CommandArray[1] == "withdraw")
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Still working on this function..."));
                    validCommand = true;
                }

                if (CommandArray[1] == "details")
                {
                    TheMySqlManager.reservedDetails(Settings.botid, e.username);
                    validCommand = true;
                }

                if (CommandArray[1] == "list")
                {
                    validCommand = true;
                    // list all of the inventory items that have reserved amounts

                    //set up the current inventory list
                    System.Collections.ArrayList MyInventoryList = TheInventory.GetInventoryList();

                    //set up a sorted inventory list for output purposes
                    System.Collections.SortedList TheInventoryList = new System.Collections.SortedList();

                    //loop through the inventory finding reserved amounts
                    foreach (Inventory.inventory_item MyInventoryItem in MyInventoryList)
                    {
                        //find the largest name length for output purposes
                        if (maxlen < MyInventoryItem.name.Length && (MyInventoryItem.pos < 36))
                        {
                            maxlen = MyInventoryItem.name.Length;
                        }
                        //if it's not in the output array, put it there
                        if (TheInventoryList.Contains(MyInventoryItem.SqlID) && MyInventoryItem.pos < 36)
                        {
                            //add the item quantities (these should be the unstackables...)
                            Inventory.inventory_item TempInventoryItem = (Inventory.inventory_item)TheInventoryList[MyInventoryItem.SqlID];
                            TempInventoryItem.quantity += MyInventoryItem.quantity;
                            TheInventoryList[MyInventoryItem.SqlID] = TempInventoryItem;
                        }
                        else
                        {
                            if (MyInventoryItem.pos < 36)
                            {
                                TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem);
                            }
                        }
                    }

                    //loop through the storage finding reserved amounts
                    System.Collections.ArrayList MyStorageList = TheStorage.GetStorageList();
                    foreach (Storage.StorageItem MyStorageItem in MyStorageList)
                    {
                        if (maxlen < MyStorageItem.name.Length)
                        {
                            maxlen = MyStorageItem.name.Length;
                        }
                        if (TheInventoryList.Contains(MyStorageItem.knownItemsID))
                        {
                            //already in the list, do nothing since storage quantity is already the total
                            //and it repeats, kinda like an unstackable item
                        }
                        else
                        {
                            Inventory.inventory_item MyInventoryItem = new Inventory.inventory_item();
                            MyInventoryItem.name             = MyStorageItem.name;
                            MyInventoryItem.SqlID            = MyStorageItem.knownItemsID;
                            MyInventoryItem.quantity         = MyStorageItem.quantity;
                            MyInventoryItem.reservedQuantity = MyStorageItem.reservedQuantity;
                            TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem);
                        }
                    }
                    // pm the reserved items
                    string str = "";
                    string msg = "";
                    str = "[";
                    str = str.PadRight(maxlen + 27, '-');
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                    foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values)
                    {
                        uint reservedQuantity = TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID);
                        if (MyInventoryItem.pos < 36 && reservedQuantity > 0)
                        {
                            msg  = "[";
                            msg += MyInventoryItem.name + " " + reservedQuantity + " of " + MyInventoryItem.quantity;
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, msg));
                        }
                    }
                    str = "[";
                    str = str.PadRight(maxlen + 27, '-');
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                }

                if (CommandArray.Length > 2)
                {
                    validCommand = true;
                    try
                    {
                        if (CommandArray[1] == "delete")
                        {
                            Int32 rowIndex = Int32.Parse(CommandArray[2]);
                            if (TheMySqlManager.reservedDelete(Settings.botid, e.username, rowIndex))
                            {
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Row Deleted."));
                            }
                            else
                            {
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Index not found."));
                            }
                        }
                        else
                        {
                            Int32  numberToReserve = Int32.Parse(CommandArray[1]);
                            int    i;
                            string itemName = "";
                            for (i = 2; i < CommandArray.Length; i++)
                            {
                                itemName += CommandArray[i] + " ";
                            }
                            int itemId = TheMySqlManager.GetItemID(itemName, false);
                            if (itemId > 0)
                            {
                                if (TheMySqlManager.reserveItem(itemId, (uint)numberToReserve, e.username) == true)
                                {
                                    TheTradeHandler.AddTrade(itemId, 0, (uint)numberToReserve, "reserved");
                                    TradeHandler.TradeLogItem myItem = new TradeHandler.TradeLogItem();
                                    myItem.KnownItemsSqlID = itemId;
                                    myItem.quantity        = (uint)numberToReserve;
                                    myItem.action          = "reserved by";
                                    TheMySqlManager.LogTrade(myItem, e.username, Settings.botid, true);
                                    TheInventory.requestInventory();
                                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[You just reserved " + myItem.quantity + " " + TheMySqlManager.GetKnownItemsname(myItem.KnownItemsSqlID)));
                                }
                                else //probably never get to this one...
                                {
                                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Item not found!"));
                                }
                            }
                            else
                            {
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Item not found!"));
                            }
                        }
                    }
                    catch
                    {
                        goto WrongArguments;
                    }
                }
                else
                {
                    if (!validCommand)
                    {
                        goto WrongArguments;
                    }
                }
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[----------------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #reserve command:          "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#reserve <list>[withdraw] <amount item>             "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[----------------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #reserve list                              "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #reserve amount item                       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #reserve details                           "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #reserve delete <idx>*                     "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[*<idx> provided by #reserve details command.        "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[----------------------------------------------------"));
            return;
        }
Exemplo n.º 21
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#putonsale")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#putonsale", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (Settings.IsTradeBot == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I am not a trade bot!"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#putonsale", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheMySqlManager.CheckIfTradeMember(e.username, Settings.botid) == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not a trade alliance member!"));
                    return;
                }

                if (TheTradeHandler.Trading == false || TradeHandler.username.ToLower() != e.username.ToLower())
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please trade with me first!"));
                    return;
                }

                try
                {
                    if (CommandArray.Length < 1)
                    {
                        goto WrongArguments;
                    }

                    if (TheTradeHandler.Donating == false && TheTradeHandler.Billance == 0 && TheTradeHandler.PartnerTradeItemsList.Count == 0 && TheTradeHandler.MyItemList.Count == 0)
                    {
                        TheTradeHandler.PutOnSale = true;
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You can give the items to me now."));
                    }
                    else
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Plese restart the trade. And put no items on the trade before sending #putonsale."));
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Here is the usage of the #putonsale command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "#putonsale"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #putonsale"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Example: #putonsale 44"));
            return;
        }
Exemplo n.º 22
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int    UsedSlots = 0;
            string Message   = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv    = new string[64];
            int      maxlen = 4;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');
            bool     isinv = false, isinvmembers = false;

            if (CommandArray[0] == "#inv" || CommandArray[0] == "#i" || CommandArray[0] == "#inb" || CommandArray[0] == "#sell" || CommandArray[0] == "#selling" || CommandArray[0] == "#inventory")
            {
                isinv = true;
            }
            if (CommandArray[0] == "#invmembers" || CommandArray[0] == "#im" || CommandArray[0] == "#invmemvers" || CommandArray[0] == "#invmember" || CommandArray[0] == "#invmemver")
            {
                isinvmembers = true;
            }
            if (isinv || isinvmembers)
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#inv", Settings.botid);

                string str1 = "", str2 = "";

                if (TheInventory.GettingInventoryItems == true)
                {
                    str2 = "I am building my inventory list, please try again in a few seconds";
                    str1 = str1.PadRight(str2.Length, '=');
                    str1 = "[" + str1;
                    str2 = "[" + str2;
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));

                    return;
                }

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (Settings.IsTradeBot == false)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I am not a trade bot!"));
                    return;
                }
                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);
                if (rank < TheMySqlManager.GetCommandRank("#inv", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if ((CommandArray[0] == "#im" || CommandArray[0] == "#invmembers" || CommandArray[0] == "#invmemvers" || CommandArray[0] == "#invmember" || CommandArray[0] == "#invmemver") && ((rank < TheMySqlManager.GetCommandRank("#invmembers", Settings.botid)) && TheMySqlManager.CheckIfBannedGuild(e.username, Settings.botid) < 1))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (this.TheTradeHandler.AmITrading() && e.username != TradeHandler.username)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                    return;
                }

                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }

                char invFiller = TheMySqlManager.getInvFiller();

                System.Collections.ArrayList MyInventoryList    = TheInventory.GetInventoryList();
                System.Collections.Hashtable MySellingItemsList = TheMySqlManager.GetSellingItemList(0);

                // sum up all inventory items if the items are on sale
                System.Collections.SortedList TheInventoryList = new System.Collections.SortedList();

                foreach (Inventory.inventory_item MyInventoryItem in MyInventoryList)
                {
                    //adjust the number of slots used...
                    if (MyInventoryItem.pos < 36)
                    {
                        if (MyInventoryItem.is_stackable)
                        {
                            UsedSlots++;
                        }
                        else
                        {
                            UsedSlots = UsedSlots + (int)(MyInventoryItem.quantity);
                        }
                    }
                    //adjust the amount

                    //only display if in selling list
                    if (MySellingItemsList.Contains(MyInventoryItem.SqlID))
                    {
                        //if already in inventory output (eg.., two slots) just sum the quantity
                        //otherwise add to inventory output
                        if (TheInventoryList.Contains(MyInventoryItem.SqlID) && MyInventoryItem.pos < 36)
                        {
                            Inventory.inventory_item TempInventoryItem = (Inventory.inventory_item)TheInventoryList[MyInventoryItem.SqlID];
                            TempInventoryItem.quantity += MyInventoryItem.quantity;
                            TheInventoryList[MyInventoryItem.SqlID] = TempInventoryItem;
                        }
                        else
                        {
                            if (MyInventoryItem.pos < 36)
                            {
                                TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem);
                            }
                        }
                    }
                }

                //foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values)
                //{
                //    if(maxlen<MyInventoryItem.name.Length && (MyInventoryItem.pos < 36))
                //        maxlen = MyInventoryItem.name.Length;
                //}
                //maxlen++;
                maxlen = 20 + 25 - Settings.Loginname.Length;
                // pm all summed up inventory items on sale
                int i = 0;
                for (i = 0; i < 64; i++)
                {
                    Inv[i] = "ZZZZZZZZZZZZZZZZ";
                }
                int    c   = 0;
                string str = "";
                str2 = "";
                str  = "[";
                str  = str.PadRight(maxlen + 27, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                bool Member = (TheMySqlManager.CheckIfTradeMember(e.username, Settings.botid) == true);

                str = "[name".PadRight(maxlen, ' ');
                str = str + "|qty".PadRight(7, ' ');
                str = str + "|price".PadRight(14, ' ');
                str = str + "|id".PadRight(6, ' ');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));

                str = "[";
                str = str.PadRight(maxlen + 27, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));

                string msg, msg2;

                foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values)
                {
                    if (MyInventoryItem.pos < 36)
                    {
                        msg = ("[" + MyInventoryItem.name).PadRight(maxlen, i == 0 ? ' ' : invFiller);
                        {
                            uint tempAmount = 0;
                            if ((TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID)) < MyInventoryItem.quantity)
                            {
                                tempAmount = MyInventoryItem.quantity;
                                tempAmount = tempAmount - (TheMySqlManager.ReservedAmount(MyInventoryItem.SqlID));
                            }
                            else
                            {
                                continue;
                            }

                            msg2 = tempAmount.ToString();
                        }
                        msg2 = msg2.PadLeft(6, i == 0 ? ' ' : invFiller);
                        msg  = msg + "|" + msg2;
                        TradeHandler.SellingItem MySellingItem = (TradeHandler.SellingItem)(MySellingItemsList[MyInventoryItem.SqlID]);
                        if (isinv)
                        {
                            msg2 = MySellingItem.pricesale.ToString();
                        }
                        else
                        {
                            msg2 = MySellingItem.pricesalemembers.ToString();
                        }
                        if (!msg2.Contains("."))
                        {
                            msg2 += ".00gc";
                        }
                        else if (msg2[msg2.Length - 2] == '.')
                        {
                            msg2 += "0gc";
                        }
                        else
                        {
                            msg2 += "gc";
                        }
                        msg2   = msg2.PadLeft(13, i == 0 ? ' ' : invFiller);
                        msg    = msg + "|" + msg2;
                        msg2   = MyInventoryItem.SqlID.ToString().PadLeft(5, i == 0 ? ' ' : invFiller);
                        msg    = msg + "|" + msg2;
                        Inv[c] = msg;
                        c++;
                        i = 1 - i;
                    }
                }
                int d;
//                for (d = 0; d < c; d++)
//                {
//                    str = Inv[d].Substring(16) + Inv[d].Substring(0, 16);
//                    Inv[d] = str;
//                }
                Array.Sort(Inv);
                i = maxlen + 13;

                string filter = "";
                if (CommandArray.Length > 1)
                {
                    bool firstTime = true;
                    foreach (string filterPart in CommandArray)
                    {
                        if (firstTime)
                        {
                            firstTime = false;
                            continue;
                        }
                        filter += (" " + filterPart);
                    }
                    //filter = Message.Substring(CommandArray[0].Length);
                }
                else
                {
                    filter = "";
                }

                for (d = 0; d < c; d++)
                {
                    str = Inv[d];
                    //27 chars after the name....
                    if (filter == "" || Inv[d].ToLower().Contains(filter.ToLower().Trim()))
                    {
                        string[] outFields = Inv[d].Split('|');
                        string   outString = Inv[d];
                        if (outFields[0].Length > maxlen)
                        {
                            outString = outFields[0].Substring(0, maxlen - 3) + "...";
                            outString = outString.PadRight(maxlen, ' ') + "|".PadRight(7, ' ') + "|".PadRight(14, ' ') + "|".PadRight(6, ' ');
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                            outString = ("[..." + outFields[0].Substring(maxlen - 3).Trim()).PadRight(maxlen, ' ');
                            int count = 0;
                            foreach (string tempString in outFields)
                            {
                                if (count == 0)
                                {
                                    count++;
                                    continue;
                                }
                                outString += "|" + tempString;
                            }
                        }
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                    }
                    else
                    {
                        //for (i = 1; i < CommandArray.Length; i++)
                        {
                            //if (Inv[d].ToLower().Contains(CommandArray[i].ToLower().Trim()))
                            Console.WriteLine("inv(d): " + Inv[d] + " filter: " + filter);
                            if (Inv[d].ToLower().Contains(filter.ToLower().Trim()))
                            {
                                string[] outFields = Inv[d].Split('|');
                                string   outString = Inv[d];
                                if (outFields[0].Length > maxlen)
                                {
                                    outString = outFields[0].Substring(0, maxlen - 3) + "...";
                                    outString = outString.PadRight(maxlen, ' ') + "|".PadRight(14, ' ') + "|".PadRight(9, ' ');
                                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                                    outString = ("[..." + outFields[0].Substring(maxlen - 3).Trim()).PadRight(maxlen, ' ');
                                    foreach (string tempString in outFields)
                                    {
                                        outString += "|" + tempString;
                                    }
                                }
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                                i = CommandArray.Length;
                            }
                        }
                    }
                }

                int Phys  = TheMySqlManager.GetBotPhysqiue(Settings.botid);
                int Coord = TheMySqlManager.GetBotCoordination(Settings.botid);
                int carry = (Phys + Coord) * 10;
                //int UsedSpace = TheMySqlManager.GetBotUsedSpace(Settings.botid);
                //int UsedSlots = TheMySqlManager.GetBotUsedSlots(Settings.botid);
                int UsedSpace = TheStats.MyCurrentCarryingAmt;
                int FreeSpace = carry - UsedSpace;
                str = "[";
                str = str.PadRight(maxlen + 27, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                str  = "[";
                str += FreeSpace.ToString() + " EMU Avail|";
                str += (36 - UsedSlots).ToString() + " Open slot(s)";
                if (rank > 89)
                {
                    //str += TheMySqlManager.moneylevel(Settings.botid).ToString() + " gc";
                    str += "|" + TheInventory.GetMoneyAmount().ToString() + " gc";
                }

                str = str.PadRight(maxlen + 27, ' ');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                str = "[";
                if (Member)
                {
                    if ((CommandArray[0] != "#im" && CommandArray[0] != "#invmembers" && CommandArray[0] != "#invmemvers" && CommandArray[0] != "#invmember" && CommandArray[0] != "#invmemver"))
                    {
                        str = str.PadRight(maxlen + 27, '-');
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        str = "[Use invmembers (im) to see member prices";
                        str = str.PadRight(maxlen + 27, ' ');
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                    }
                    //if (isinv)
                    //{
                    //    str = "[to see member prices use invmembers or im";
                    //    str = str.PadRight(maxlen + 28, ' ');
                    //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                    //}
                }
                str = "[";
                str = str.PadRight(maxlen + 27, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));

                return;
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #inv command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#inv                                  "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #inv                         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #inv silver ore              "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            return;
        }
Exemplo n.º 23
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv           = new string[64];
            string   searchName    = "";
            string   inputCategory = "";

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');
            bool     issto        = false;

            if (CommandArray[0] == "#sto")
            {
                issto = true;
            }
            if (issto)
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#sto", Settings.botid);


                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);
                if (rank < TheMySqlManager.GetCommandRank("#sto", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

//                if (TheTradeHandler.Trading == false || TheTradeHandler.username.ToLower() == "")
////                if (TheTradeHandler.Trading == false || TheTradeHandler.username.ToLower() != e.username.ToLower())
//                {
//                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Someone must be trading with me first!"));
//                    return;
//                }
                if (!TradeHandler.storageOpen)
                {
                    if (TradeHandler.openingStorage)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for storage to finish opening."));
                    }
                    else
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You must open storage first!"));
                    }
                    return;
                }

                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }
                else if (CommandArray.Length > 1)
                //inputCategory = (string)CommandArray.GetValue(1);
                {
                    for (int i = 1; i < CommandArray.Length; i++)
                    {
                        if (inputCategory.Length > 0)
                        {
                            inputCategory += (" " + (string)CommandArray[i]);
                        }
                        else
                        {
                            inputCategory += (string)CommandArray[i];
                        }
                    }
                    //Console.WriteLine("inputCategory:{0}", inputCategory);
                }
                else
                {
                    if (TheStorage.TheStorageCategories.Count > 0 && TradeHandler.storageOpen)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please enter one of the following categories (or an item name)!"));

                        foreach (Storage.StorageCategory MyStorageCategory in TheStorage.TheStorageCategories)
                        {
                            if (MyStorageCategory.num != -1)
                            {
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, MyStorageCategory.name));
                            }
                        }
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "All"));
                    }
                    return;
                }

                string searchcategory = "";
                bool   categoryFound  = false;

                searchName = inputCategory;
                foreach (Storage.StorageCategory MyStorageCategory in TheStorage.TheStorageCategories)
                {
                    searchcategory = MyStorageCategory.name.ToLower();
                    if (searchcategory.Contains(inputCategory) || (inputCategory.Contains("all")))
                    {
                        searchName    = "";
                        categoryFound = true;
                    }
                }

                if (categoryFound == false)
                {
                    inputCategory = "all";
                }
                //pm the boarder
                string str        = "";
                string str2       = "";
                int    lineLength = 55;
                str  = "[";
                str  = str.PadRight(lineLength, '-');
                str2 = "[";
                str2 = str2.PadRight(lineLength, '=');
                //string header = "[ItemID:    Qty:  Name:";
                //header = header.PadRight(lineLength, ' ');
                string catname    = "";
                bool   itemsFound = false;
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2));
                bool Member = (TheMySqlManager.CheckIfTradeMember(e.username, Settings.botid) == true);

                //loop through the storage sending pms
                foreach (Storage.StorageCategory MyStorageCategory in TheStorage.TheStorageCategories)
                {
                    catname        = "[Item ID:  Count: Category: " + MyStorageCategory.name.Substring(0, MyStorageCategory.name.Length);
                    catname        = catname.PadRight(lineLength, ' ');
                    searchcategory = MyStorageCategory.name.ToLower();
                    if (searchcategory.Contains(inputCategory) || (inputCategory.Contains("all")))
                    {
                        if (searchName == "")
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, catname));
                            // send header
                            //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, header));
                        }
                        bool categoryPrinted = false;
                        foreach (Storage.StorageItem MyStorageItem in TheStorage.GetStorageList())
                        {
                            string outputLine = "";
                            Int32  tempAmount = 0;
                            string temp;
                            string spaces = "   ";
                            temp       = MyStorageItem.knownItemsID.ToString();
                            temp       = temp.PadLeft(6, ' ');
                            outputLine = "[" + temp + spaces;
                            tempAmount = (Int32)(MyStorageItem.quantity - MyStorageItem.reservedQuantity);
                            if (tempAmount < 0)
                            {
                                tempAmount = 0;
                            }
//                            temp = (MyStorageItem.quantity - MyStorageItem.reservedQuantity).ToString();
                            temp        = tempAmount.ToString();
                            temp        = temp.PadLeft(5, ' ');
                            outputLine += temp + spaces + MyStorageItem.name.Substring(0, MyStorageItem.name.Length);
                            outputLine  = outputLine.PadRight(lineLength, ' ');
                            if (searchName != "")
                            {
                                if (MyStorageItem.name.ToLower().Contains(searchName) && MyStorageItem.category_num == MyStorageCategory.num)
                                {
                                    if (categoryPrinted == false)
                                    {
                                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, catname));
                                    }
                                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outputLine));
                                    itemsFound      = true;
                                    categoryPrinted = true;
                                }
                            }
                            else if (MyStorageItem.category_num == MyStorageCategory.num)
                            {
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outputLine));
                                itemsFound = true;
                            }
                        }
                        if (itemsFound == false && searchName == "")
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[None found"));
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        }
                        else if (itemsFound == true)
                        {
                            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                        }
                        itemsFound = false;
                    }
                }

                return;
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #sto command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#sto <item>                           "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #sto                         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #sto silver                  "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------"));
            return;
        }
Exemplo n.º 24
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#move" || CommandArray[0] == "#m")
            {
                if (CommandArray.Length < 3)
                {
                    goto WrongArguments;
                }

                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#move", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#move", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray[1].Contains(","))
                {
                    goto WrongArguments;
                }
                int x = int.Parse(CommandArray[1]);
                int y = int.Parse(CommandArray[2]);
                TheTCPWrapper.Send(CommandCreator.MOVE_TO(x, y));
                System.Threading.Thread.Sleep(1000);
                TheTCPWrapper.Send(CommandCreator.LOCATE_ME());
            }
            if (CommandArray[0] == "#turnleft" || CommandArray[0] == "#tl")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#move", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#tl", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray.Length > 2)
                {
                    goto WrongArgumentsTL;
                }
                int i = 0;
                if (CommandArray.Length > 1)
                {
                    i = int.Parse(CommandArray[1]);
                    i = i % 5;
                }
                i++;
                while (i > 0)
                {
//                    TheTCPWrapper.Send(CommandCreator.TURN_LEFT());
                    TheTCPWrapper.Send(CommandCreator.TURN_RIGHT());
                    i--;
                    System.Threading.Thread.Sleep(1000);
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I have " + (i * 45).ToString() + " degrees remaining"));
                }
            }
            if (CommandArray[0] == "#turnright" || CommandArray[0] == "#tr")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#move", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#tr", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray.Length > 2)
                {
                    goto WrongArgumentsTR;
                }
                int i = 0;
                if (CommandArray.Length > 1)
                {
                    i = int.Parse(CommandArray[1]);
                    i = i % 5;
                }
                i++;
                while (i > 0)
                {
//                    TheTCPWrapper.Send(CommandCreator.TURN_RIGHT());
                    TheTCPWrapper.Send(CommandCreator.TURN_LEFT());
                    i--;
                    System.Threading.Thread.Sleep(1000);
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I have " + (i * 45).ToString() + " degrees remaining"));
                }
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #move command:   "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#move x y                                 "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #move 192 168                    "));
            return;

WrongArgumentsTL:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #turnleft command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#turnleft (optional turns)                 "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[-------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #turnleft                         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Turn left 45 degrees                       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #turnleft 3                       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Turn left 135 degrees                      "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[nothing or 1 rotates 45 degrees            "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[2 rotates 90 degrees                       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[3 rotates 135 degrees                      "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[4 rotates 180 degrees                      "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Any more than 4 will stop at 180 degrees   "));
            return;

WrongArgumentsTR:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #turnright command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#turnright (optional turns)                 "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[--------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #turnright                         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Turn right 45 degrees                       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #turnright 3                       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Turn right 135 degrees                      "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[nothing or 1 rotates 45 degrees             "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[2 rotates 90 degrees                        "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[3 rotates 135 degrees                       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[4 rotates 180 degrees                       "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Any more than 4 will stop at 180 degrees    "));
            return;
        }
Exemplo n.º 25
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            uint quantity      = 0;
            int  SQLID         = 0;
            bool fromInventory = false;

            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#giveto")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#giveto", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#giveto", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheTradeHandler.Trading == false || TradeHandler.username.ToLower() == "")
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Someone must be trading with me first!"));
                    return;
                }

                if (CommandArray.Length < 2)
                {
                    goto WrongArguments;
                }
                //try
                //{
                //    if (CommandArray.Length < 2)
                //    {
                //        goto WrongArguments;
                //    }
                //    if (CommandArray.Length < 3)
                //    {
                //        quantity = 1;
                //        nameToID = TheMySqlManager.GetItemID(CommandArray[1], Settings.botid, false);
                //        if (nameToID != -1)
                //        {
                //            SQLID = nameToID;
                //        }
                //        if (nameToID == -1)
                //        {
                //            SQLID = int.Parse(CommandArray[1]);
                //        }
                //    }
                //    if (CommandArray.Length > 2)
                //    {
                //        quantity = uint.Parse(CommandArray[1]);
                //        string str = "";
                //        int i;
                //        for (i = 2; i < CommandArray.Length; i++)
                //        {
                //            if (CommandArray[i] == "inv" || CommandArray[i] == "inventory")
                //            {
                //                fromInventory = true;
                //            }
                //            else
                //            {
                //                str += CommandArray[i] + " ";
                //            }
                //        }
                //        str = str.Trim();
                //        if (fromInventory)
                //        {
                //            nameToID = TheMySqlManager.GetItemID(str, Settings.botid, false);
                //        }
                //        else
                //        {
                //            nameToID = TheMySqlManager.GetItemID(str, Settings.botid, true);
                //        }

                //        if (nameToID == -1)
                //        {
                //            SQLID = int.Parse(CommandArray[2]);
                //        }
                //        if (nameToID != -1)
                //        {
                //            SQLID = nameToID;
                //        }
                //    }
                //}
                //catch
                //{
                //    goto WrongArguments;
                //}
                int    i        = 0;
                string itemName = "";
                try
                {
                    //there is a quantity given
                    quantity = uint.Parse(CommandArray[1]);
                    i        = 2;
                }
                catch
                {
                    //no quantity given
                    quantity = 1;
                    i        = 1;
                }
                if (!TradeHandler.storageOpen)
                {
                    fromInventory = true;
                }
                for (; i < CommandArray.Length; i++)
                {
                    if (CommandArray[i] == "inv" || CommandArray[i] == "inventory")
                    {
                        fromInventory = true;
                        break;
                    }
                    itemName += CommandArray[i] + " ";
                }
                try
                {
                    SQLID = int.Parse(itemName);
                }
                catch
                {
                    SQLID = TheMySqlManager.GetItemID(itemName, Settings.botid, !fromInventory);
                }

                uint ItemsPlacedOnTrade = TheTradeHandler.PutItemsOnTrade(SQLID, quantity, fromInventory);
                if (ItemsPlacedOnTrade > 0)
                {
                    //turn the trade timer off here, put in cancel trade command to avert
                    //abuse turning the timer off... (if trade is canceled, it'll be reset)
//                    TheTradeHandler.TradeTimer.Stop();
//                    TheTradeHandler.Giving = true;
                    TheTradeHandler.itemTraded = true;
                    if (fromInventory == true)
                    {
                        TheTradeHandler.AddTrade(SQLID, 0, ItemsPlacedOnTrade, "gave from inv");
                    }
                    else
                    {
                        TheTradeHandler.AddTrade(SQLID, 0, ItemsPlacedOnTrade, "gave from sto");
                    }
                }

                if (ItemsPlacedOnTrade < quantity)
                {
                    if (ItemsPlacedOnTrade == 0)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I don't have this item!"));
                    }
                    else
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I only have " + ItemsPlacedOnTrade.ToString() + " of this item!"));
                    }
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Put " + ItemsPlacedOnTrade.ToString() + " of " + TheMySqlManager.GetKnownItemsname(SQLID) + " into the trade window(" + TradeHandler.username + ")"));
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|-----------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Here is the usage of the #giveto command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|#giveto <quantity> <name or itemid>      "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|-----------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #giveto 100 2                   "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #giveto 1 Pickaxe               "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #giveto 1 Pickaxe inv           "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|-----------------------------------------"));
            return;
        }
Exemplo n.º 26
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            int    UsedSlots = 0;
            string Message   = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv = new string[512];

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#invlist" || CommandArray[0] == "#il")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#invlist", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);
                if (rank < TheMySqlManager.GetCommandRank("#invlist", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (this.TheTradeHandler.AmITrading() && e.username != TradeHandler.username)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                    return;
                }

                char invFiller = TheMySqlManager.getInvFiller();

                string str1 = "", str2 = "";
                if (TheInventory.GettingInventoryItems == true)
                {
                    str2 = "I am building my inventory list, please try again in a few seconds";
                    str1 = str1.PadRight(str2.Length, '=');
                    str1 = "[" + str1;
                    str2 = "[" + str2;
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str2));
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));

                    return;
                }
                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }

                System.Collections.ArrayList MyInventoryList    = TheInventory.GetInventoryList();
                System.Collections.Hashtable MySellingItemsList = TheMySqlManager.GetSellingItemList(0);

                // sum up all inventory items if the items are on sale
                int i = 0;
                for (i = 0; i < 512; i++)
                {
                    Inv[i] = "ZZZZZZZZZZZZZZZZ";
                }
                int c = 0;

                System.Collections.SortedList TheInventoryList = new System.Collections.SortedList();
                System.Collections.SortedList TheWornList      = new System.Collections.SortedList();
                int ii = 0;
                foreach (Inventory.inventory_item MyInventoryItem in MyInventoryList)
                {
                    ii++;
                    if (TheInventoryList.Contains(MyInventoryItem.SqlID) && MyInventoryItem.pos < 36)
                    {
//                        if (MyInventoryItem.pos < 36)
                        {
                            Inventory.inventory_item TempInventoryItem = (Inventory.inventory_item)TheInventoryList[MyInventoryItem.SqlID];
                            TempInventoryItem.quantity += MyInventoryItem.quantity;
                            TheInventoryList[MyInventoryItem.SqlID] = TempInventoryItem;
                        }
                    }
                    else
                    {
                        if (MyInventoryItem.pos < 36)
                        {
                            TheInventoryList.Add(MyInventoryItem.SqlID, MyInventoryItem);
                        }
                    }
                    if (MyInventoryItem.pos > 35 && MyInventoryItem.pos < 44)
                    {
                        TheWornList.Add(MyInventoryItem.SqlID, MyInventoryItem);
                    }
                }
                int maxlen = 4;
                foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values)
                {
//                    if (maxlen < MyInventoryItem.name.Length && MyInventoryItem.pos < 44)
                    if (maxlen < MyInventoryItem.name.Length && MyInventoryItem.pos < 36)
                    {
                        maxlen = MyInventoryItem.name.Length;
                    }
                }
                foreach (Inventory.inventory_item MyInventoryItem in TheWornList.Values)
                {
                    if (maxlen <= MyInventoryItem.name.Length + 3)
                    {
                        maxlen = MyInventoryItem.name.Length + 3;
                    }
                }
                str2 = "";
                str1 = "[";
                str1 = str1.PadRight(maxlen + 16, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                str1  = "[ id |";
                str2  = "quantity";
                str2  = str2.PadRight(9, ' ') + "|";
                str1 += str2;
                str2  = "name";
                str2  = str2.PadRight(maxlen, ' ');
                str1  = str1 + str2;
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                str1 = "[";
                str1 = str1.PadRight(maxlen + 16, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                // pm all summed up inventory items on sale
                c = 0;
                i = 1;
                foreach (Inventory.inventory_item MyInventoryItem in TheWornList.Values)
                {
                    if (MyInventoryItem.pos < 44)
                    {
                        if (MyInventoryItem.pos < 36)
                        {
                            if (MyInventoryItem.is_stackable)
                            {
                                UsedSlots++;
                            }
                            else
                            {
                                UsedSlots = UsedSlots + (int)(MyInventoryItem.quantity);
                            }
                        }
                        str1  = "";
                        str2  = "";
                        str2 += MyInventoryItem.SqlID.ToString();
                        str2  = str2.PadLeft(4, i == 0 ? ' ' : invFiller);
                        str2  = "[" + str2 + "|";
                        str1  = MyInventoryItem.quantity.ToString();
                        str1  = str1.PadLeft(9, i == 0 ? ' ' : invFiller);
                        str2 += str1 + "|";
                        if (MyInventoryItem.pos > 35)
                        {
                            str1 = "{E}" + MyInventoryItem.name;
                        }
                        else
                        {
                            str1 = MyInventoryItem.name;
                        }
                        str1 = str1.PadRight(maxlen, i == 0 ? ' ' : invFiller);
                        str1 = str2 + str1;
                        //TradeHandler.SellingItem MySellingItem = (TradeHandler.SellingItem)(MySellingItemsList[MyInventoryItem.SqlID]);
                        //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                        Inv[c++] = str1;
                        //i = 1 - i;
                    }
                }
                foreach (Inventory.inventory_item MyInventoryItem in TheInventoryList.Values)
                {
                    if (MyInventoryItem.pos < 44)
                    {
                        if (MyInventoryItem.pos < 36)
                        {
                            if (MyInventoryItem.is_stackable)
                            {
                                UsedSlots++;
                            }
                            else
                            {
                                UsedSlots = UsedSlots + (int)(MyInventoryItem.quantity);
                            }
                        }
                        str1  = "";
                        str2  = "";
                        str2 += MyInventoryItem.SqlID.ToString();
                        str2  = str2.PadLeft(4, i == 0 ? ' ' : invFiller);
                        str2  = "[" + str2 + "|";
                        str1  = MyInventoryItem.quantity.ToString();
                        str1  = str1.PadLeft(9, i == 0 ? ' ' : invFiller);
                        str2 += str1 + "|";
                        if (MyInventoryItem.pos > 35)
                        {
                            str1 = "{E}" + MyInventoryItem.name;
                        }
                        else
                        {
                            str1 = MyInventoryItem.name;
                        }
                        str1 = str1.PadRight(maxlen, i == 0 ? ' ' : invFiller);
                        str1 = str2 + str1;
                        //TradeHandler.SellingItem MySellingItem = (TradeHandler.SellingItem)(MySellingItemsList[MyInventoryItem.SqlID]);
                        //TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                        Inv[c++] = str1;
                        //i = 1 - i;
                    }
                }
                int    d;
                string str;
                for (d = 0; d < c; d++)
                {
                    str    = Inv[d].Substring(16) + Inv[d].Substring(0, 16);
                    Inv[d] = str;
                }
                Array.Sort(Inv);
                i = maxlen + 13;

                string filter = "";
                if (CommandArray.Length > 1)
                {
                    bool firstTime = true;
                    foreach (string filterPart in CommandArray)
                    {
                        if (firstTime)
                        {
                            firstTime = false;
                            continue;
                        }
                        filter += (" " + filterPart);
                    }
                    //filter = Message.Substring(CommandArray[0].Length);
                }
                else
                {
                    filter = "";
                }

                //for (d = c - 1; d >= 0; d--)
                for (d = 0; d < c; d++)
                {
                    i      = Inv[d].Length - 16;
                    str    = Inv[d].Substring(i);
                    str   += Inv[d].Substring(0, i);
                    Inv[d] = str.Substring(str.Length - 16);
                    if (filter == "" || str.ToLower().Contains(filter.ToLower().Trim()))
                    {
                        //string[] outFields = Inv[d].Split('|');
                        //string outString = Inv[d];
                        //if (outFields[0].Length > maxlen)
                        //{
                        //    outString = outFields[0].Substring(0, maxlen - 3) + "...";
                        //    outString = outString.PadRight(maxlen, ' ') + "|".PadRight(14, ' ') + "|".PadRight(9, ' ');
                        //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                        //    outString = "[...".PadRight(maxlen, ' ');
                        //    foreach (string tempString in outFields)
                        //    {
                        //        outString += "|" + tempString;
                        //    }
                        //}
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                    }
                    else
                    {
                        //for (i = 1; i < CommandArray.Length; i++)
                        {
                            if (str.ToLower().Contains(filter.ToLower().Trim()))
                            {
                                //string[] outFields = Inv[d].Split('|');
                                //string outString = Inv[d];
                                //if (outFields[0].Length > maxlen)
                                //{
                                //    outString = outFields[0].Substring(0, maxlen - 3) + "...";
                                //    outString = outString.PadRight(maxlen, ' ') + "|".PadRight(14, ' ') + "|".PadRight(9, ' ');
                                //    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outString));
                                //    outString = "[...".PadRight(maxlen, ' ');
                                //    foreach (string tempString in outFields)
                                //    {
                                //        outString += "|" + tempString;
                                //    }
                                //}
                                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str));
                                i = CommandArray.Length;
                            }
                        }
                    }
                }

                int Phys      = TheMySqlManager.GetBotPhysqiue(Settings.botid);
                int Coord     = TheMySqlManager.GetBotCoordination(Settings.botid);
                int carry     = (Phys + Coord) * 10;
                int UsedSpace = TheStats.MyCurrentCarryingAmt;
                int FreeSpace = carry - UsedSpace;
                str1 = "[";
                str1 = str1.PadRight(maxlen + 16, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));
                str1  = "[";
                str1 += FreeSpace.ToString() + " EMU Avail|";
                str1 += (36 - UsedSlots).ToString() + " Open slot(s)";
                if (rank > 89)
                {
                    str1 += "|" + TheInventory.GetMoneyAmount().ToString() + " gc";
                }

                str1 = str1.PadRight(maxlen + 16, ' ');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));

                str1 = "[";
                str1 = str1.PadRight(maxlen + 16, '-');
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, str1));

                return;
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #invlist command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#invlist                                  "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #invlist                         "));
            return;
        }
Exemplo n.º 27
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message;

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0].ToLower() == "#ban" ||
                CommandArray[0].ToLower() == "#unban" ||
                CommandArray[0].ToLower() == "#banguild" ||
                CommandArray[0].ToLower() == "#bg" ||
                CommandArray[0].ToLower() == "#unbanguild" ||
                CommandArray[0].ToLower() == "#ug" ||
                CommandArray[0].ToLower() == "#prefer" ||
                CommandArray[0].ToLower() == "#preferguild" ||
                CommandArray[0].ToLower() == "#pg" ||
                CommandArray[0].ToLower() == "#rank"
                )
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#ban", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank(CommandArray[0], Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (CommandArray[0].ToLower() == "#rank")
                {
                    if (CommandArray.Length != 3)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "The " + CommandArray[0].ToLower() + " command requires two parameters, the name and the rank."));
                        return;
                    }
                    TheMySqlManager.UpdatePlayer(CommandArray[1].ToLower(), int.Parse(CommandArray[2]), e.username);
                    return;
                }
                else if (CommandArray.Length != 2)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "The " + CommandArray[0].ToLower() + " command requires one parameter, the name."));
                    return;
                }
                string name = CommandArray[1];
                if (CommandArray[0] == "#ban")
                {
                    TheMySqlManager.UpdatePlayer(name.ToLower(), -1, e.username);
                }
                else if (CommandArray[0] == "#unban")
                {
                    TheMySqlManager.UpdatePlayer(name.ToLower(), 0, e.username);
                }
                else if (CommandArray[0] == "#prefer")
                {
                    TheMySqlManager.UpdatePlayer(name.ToLower(), 1, e.username);
                }
                else if (CommandArray[0] == "#banguild" || CommandArray[0] == "#bg")
                {
                    TheMySqlManager.BanGuild(CommandArray[1], -1, e.username);
                }
                else if (CommandArray[0] == "#unbanguild" || CommandArray[0] == "#ug")
                {
                    TheMySqlManager.BanGuild(CommandArray[1], 0, e.username);
                }
                else if (CommandArray[0] == "#preferguild" || CommandArray[0] == "#pg")
                {
                    TheMySqlManager.BanGuild(CommandArray[1], 1, e.username);
                }
                TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Command executed."));
            }

            return;
        }
Exemplo n.º 28
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            uint quantity = 0;
            int  SQLID    = 0;
            //int nameToID = -1;
            //bool fromInventory = true;
            bool   fromInventory = false;
            string itemName      = "";

            string Message = e.Message.ToLower();

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#give" || CommandArray[0] == "#g")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#give", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#give", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (TheTradeHandler.Trading == false || TradeHandler.username.ToLower() != e.username.ToLower())
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please trade with me first!"));
                    return;
                }
                if (TradeHandler.openingStorage)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for storage to finish opening!"));
                    return;
                }

                if (CommandArray.Length < 2)
                {
                    goto WrongArguments;
                }

                int i = 0;
                try
                {
                    //there is a quantity given
                    quantity = uint.Parse(CommandArray[1]);
                    i        = 2;
                }
                catch
                {
                    //no quantity given
                    quantity = 1;
                    i        = 1;
                }
                if (!TradeHandler.storageOpen)
                {
                    fromInventory = true;
                }
                for (; i < CommandArray.Length; i++)
                {
                    if (CommandArray[i] == "inv" || CommandArray[i] == "inventory")
                    {
                        fromInventory = true;
                        break;
                    }
                    itemName += CommandArray[i] + " ";
                }
                try
                {
                    SQLID = int.Parse(itemName);
                }
                catch
                {
                    SQLID = TheMySqlManager.GetItemID(itemName, Settings.botid, !fromInventory);
                }
                uint ItemsPlacedOnTrade = TheTradeHandler.PutItemsOnTrade(SQLID, quantity, fromInventory);
                if (ItemsPlacedOnTrade > 0)
                {
                    TheTradeHandler.Donating   = true;
                    TheTradeHandler.itemTraded = true;
                    if (fromInventory == true)
                    {
                        TheTradeHandler.AddTrade(SQLID, 0, ItemsPlacedOnTrade, "gave from inv");
                    }
                    else
                    {
                        TheTradeHandler.AddTrade(SQLID, 0, ItemsPlacedOnTrade, "gave from sto");
                    }
                }

                if (ItemsPlacedOnTrade < quantity)
                {
                    if (ItemsPlacedOnTrade == 0 && !fromInventory)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I don't have this item in storage!"));
                    }
                    else if (ItemsPlacedOnTrade == 0)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I don't have this item in inventory!"));
                    }
                    else
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I only have " + ItemsPlacedOnTrade.ToString() + " of this item!"));
                    }
                }
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Here is the usage of the #give command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|#give <quantity> <name or itemid>      "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #give 100 2                   "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #give 1 Pickaxe               "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #give 1 Pickaxe inv           "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            return;
        }
Exemplo n.º 29
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            string[] Inv = new string[64];

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');
            if (CommandArray[0] == "#deposit")
            {
                username = e.username;
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#deposit", Settings.botid);


                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                int rank = TheMySqlManager.GetUserRank(e.username, Settings.botid);

                if (rank < TheMySqlManager.GetCommandRank("#deposit", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }

                if (CommandArray.Length < 1)
                {
                    goto WrongArguments;
                }

                if (!TradeHandler.storageOpen)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You must open storage first!"));
                    return;
                }

                if (TheInventory.GettingInventoryItems == true || TheInventory.inventoryRequested)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Please wait a moment for me to finish getting my inventory..."));
                    return;
                }

                TheTradeHandler.makingDeposit = true;
                //ok, let's do a deposit
                uint   quantity = 0;
                string itemName = "";
                int    SQLID    = -1;

                int    nameToID = -1;
                string str      = "";
                try
                {
                    if (CommandArray.Length < 2)
                    {
                        goto WrongArguments;
                    }
                    if (CommandArray.Length < 3)
                    {
                        quantity = 1;
                        try
                        {
                            SQLID    = int.Parse(CommandArray[1]);
                            nameToID = SQLID;
                        }
                        catch
                        {
                            itemName = CommandArray[1] + " ";
                            nameToID = TheMySqlManager.GetItemID(CommandArray[1], Settings.botid, true);
                        }
                    }
                    if (CommandArray.Length > 2)
                    {
                        int i;
                        try
                        {
                            quantity = uint.Parse(CommandArray[1]);
                            for (i = 2; i < CommandArray.Length; i++)
                            {
                                str += CommandArray[i] + " ";
                            }
                        }
                        catch
                        {
                            quantity = 1;
                            for (i = 1; i < CommandArray.Length; i++)
                            {
                                str += CommandArray[i] + " ";
                            }
                        }
                        finally
                        {
                            str      = str.Trim();
                            nameToID = TheMySqlManager.GetItemID(str, Settings.botid, true);
                            itemName = str + " ";
                        }
                    }
                }
                catch
                {
                    goto WrongArguments;
                }
                finally
                {
                    try
                    {
                        SQLID = int.Parse(str);
                    }
                    catch
                    {
                        SQLID = nameToID;
                    }
                }

                int invCount = 0;
                MyStorageItem = new Storage.StorageItem();
                foreach (Inventory.inventory_item myInventoryItem in TheInventory.GetInventoryList())
                {
                    if (myInventoryItem.SqlID == SQLID)
                    {
                        TheTCPWrapper.Send(CommandCreator.DEPOSIT_ITEM(myInventoryItem.pos, (UInt16)quantity));
                        TheInventory.requestInventory();
                        TheTradeHandler.makingDeposit  = false;
                        TheTradeHandler.depositMade    = true;
                        MyStorageItem.knownItemsID     = myInventoryItem.SqlID;
                        MyStorageItem.imageid          = myInventoryItem.imageid;
                        MyStorageItem.category_num     = -1;
                        MyStorageItem.name             = myInventoryItem.name;
                        MyStorageItem.reservedQuantity = 0;
                        MyStorageItem.name             = myInventoryItem.name;
                        break;
                    }
                    invCount++;
                }
                if (!TheTradeHandler.depositMade)
                {
                    TheTradeHandler.makingDeposit = false;
                    string outputString = "I don't seem to have any " + itemName + " in inventory!";
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, outputString));
                }
            }
            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Here is the usage of the #deposit command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[#deposit amt item                         "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[Example: #deposit 1 silver ore            "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "[------------------------------------------"));
            return;
        }
Exemplo n.º 30
0
        private void OnGotPM(object sender, BasicCommunication.MessageParser.Got_PM_EventArgs e)
        {
            UInt32 quantity = 0;
            int    SQLID    = 0;
            int    nameToID = -1;

            string Message = e.Message.ToLower().Replace("\'", "\\\'").Replace("\"", "\\\"");

            if (Message[0] != '#')
            {
                Message = "#" + Message;
            }

            string[] CommandArray = Message.Split(' ');

            if (CommandArray[0] == "#drop")
            {
                bool disabled = TheMySqlManager.CheckIfCommandIsDisabled("#drop", Settings.botid);

                if (disabled == true)
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "This command is disabled"));
                    return;
                }

                if (TheMySqlManager.GetUserRank(e.username, Settings.botid) < TheMySqlManager.GetCommandRank("#drop", Settings.botid))
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "You are not authorized to use this command!"));
                    return;
                }
                if (TheTradeHandler.AmITrading())
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I am currently trading, please retry shortly."));
                    return;
                }

                try
                {
                    if (CommandArray.Length < 2)
                    {
                        goto WrongArguments;
                    }
                    if (CommandArray.Length < 3)
                    {
                        quantity = 1;
                        nameToID = TheMySqlManager.GetItemID(CommandArray[1], false);
                        if (nameToID != -1)
                        {
                            SQLID = nameToID;
                        }
                        if (nameToID == -1)
                        {
                            SQLID = int.Parse(CommandArray[1]);
                        }
                    }
                    if (CommandArray.Length > 2)
                    {
                        quantity = UInt32.Parse(CommandArray[1]);
                        string str = "";
                        int    i;
                        for (i = 2; i < CommandArray.Length; i++)
                        {
                            str += CommandArray[i] + " ";
                        }
                        str      = str.Trim();
                        nameToID = TheMySqlManager.GetItemID(str, false);
                        if (nameToID == -1)
                        {
                            SQLID = int.Parse(CommandArray[2]);
                        }
                        if (nameToID != -1)
                        {
                            SQLID = nameToID;
                        }
                    }
                }
                catch
                {
                    goto WrongArguments;
                }

                UInt32 ItemsDropped = DropItems(SQLID, quantity);
                //TheInventory.GettingInventoryItems = true;

                if (ItemsDropped > 0)
                {
                    TradeHandler.TradeLogItem MyTradeLogItem;
                    MyTradeLogItem.action          = "dropped";
                    MyTradeLogItem.quantity        = ItemsDropped;
                    MyTradeLogItem.price           = 0;
                    MyTradeLogItem.KnownItemsSqlID = SQLID;
                    MyTradeLogItem.categoryNum     = -1;
                    this.TheMySqlManager.LogTrade(MyTradeLogItem, e.username, Settings.botid, true);
                }

                if (ItemsDropped < quantity)
                {
                    if (ItemsDropped == 0)
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "Sorry, I don't have this item!"));
                    }
                    else
                    {
                        TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I dropped only " + ItemsDropped.ToString() + " of this item!"));
                    }
                }
                else
                {
                    TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "I dropped " + ItemsDropped.ToString() + " of this item!"));
                }
                TheInventory.requestInventory();
            }

            return;

WrongArguments:
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Here is the usage of the #drop command:"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|#drop <quantity> <name or itemid>      "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|Example: #drop 100 Fruits              "));
            TheTCPWrapper.Send(CommandCreator.SEND_PM(e.username, "|---------------------------------------"));
            return;
        }