示例#1
0
        public override bool HandleCommand(ulong userId, string[] words)
        {
            MyObjectBuilder_Faction currentfaction;
            try
            {
               currentfaction = Faction.getFaction(Faction.getFactionID(userId));
            }
            catch (NullReferenceException)
            {
                 ChatUtil.SendPrivateChat(userId, "Faction has 0 FactionPoints");
                return false;
            }

                    int currentFP = FactionPoints.getFP(Convert.ToUInt64( Faction.getFactionID(userId)));
                    if (currentFP != -1)
                    {
                        ChatUtil.SendPrivateChat(userId, "Faction Currently has " + currentFP + " FactionPoints.");
                    }
                    else
                    {
                        ChatUtil.SendPrivateChat(userId, "Faction does not exist.");
                    }

            return true;
        }
示例#2
0
 public override bool HandleCommand(ulong userId, string[] words)
 {
     try
     {
         MyObjectBuilder_Faction currentfaction;
         currentfaction = Utility.Faction.getFaction(Utility.Faction.getFactionID(userId));
         foreach (MyObjectBuilder_FactionMember currentmember in currentfaction.Members)
         {
             if (currentmember.IsLeader == true && currentmember.PlayerId == PlayerMap.Instance.GetPlayerIdsFromSteamId(userId).First())//currentmember.isleader(currentfaction)
             {
                 string output = "";
                 output = Utility.Shop.Shop.getShopList(userId);
                 ChatUtil.DisplayDialog(userId, "Faction Store", "Spend FP Here!", output);
                 break;
             }
             else if (currentmember.PlayerId == PlayerMap.Instance.GetPlayerIdsFromSteamId(userId).First())
             {
                 ChatUtil.SendPrivateChat(userId, "You do not have Permission to use this command.");
             }
         }
     }
     catch (NullReferenceException)
     {
         log.Info(string.Format("Error getting shop list nullreferenceexception"));
     }
     return(true);
 }
 public static bool transferFP(ulong userID, string factiontag, int amount)
 {
     if (amount < 0)
     {
         ChatUtil.SendPrivateChat(userID, "Please enter a positive value");
         return(false);
     }
     if (Faction.getFactionIDfromTag(factiontag) != 0)
     {
         if (FactionPoints.RemoveFP((ulong)Faction.getFactionID(userID), amount) == true)
         {
             FactionPoints.AddFP(Faction.getFactionIDfromTag(factiontag), amount);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         ChatUtil.SendPrivateChat(userID, "Factionx tag does not exist");
         return(false);
     }
 }
示例#4
0
        public override bool HandleCommand(ulong userId, string[] words)
        {
            if (Conquest.processingShop == true)
            {
                ChatUtil.SendPrivateChat(userId, "A buy request is currently processing. Please try again soon.");
                return(false);
            }
            else
            {
                Conquest.processingShop = true;
            }
            MyObjectBuilder_Faction currentfaction;

            currentfaction = Utility.Faction.getFaction(Utility.Faction.getFactionID(userId));
            long amount;

            try
            {
                amount = Convert.ToInt64(words[1]);
            }
            catch (Exception)
            {
                ChatUtil.SendPrivateChat(userId, "Not a valid command.");
                Conquest.processingShop = false;
                return(false);
            }
            foreach (MyObjectBuilder_FactionMember currentmember in currentfaction.Members)
            {
                if (currentmember.IsLeader == true && currentmember.PlayerId == PlayerMap.Instance.GetPlayerIdsFromSteamId(userId).First())
                {
                    if (Shop.buyItem(words[0], amount, userId))
                    {
                        ChatUtil.SendPrivateChat(userId, "Your purchase has been successful.");
                        Conquest.processingShop = false;
                        break;
                    }
                }
                else if (currentmember.PlayerId == PlayerMap.Instance.GetPlayerIdsFromSteamId(userId).First())
                {
                    ChatUtil.SendPrivateChat(userId, "You do not have Permission to use this command.");
                }
            }
            Conquest.processingShop = false;
            return(true);
        }
示例#5
0
        /// <summary>
        /// Displays the available commands for the command entered
        /// </summary>
        /// <param name="remoteUserId"></param>
        /// <param name="recvMessage"></param>
        private void DisplayAvailableCommands(ulong remoteUserId, string recvMessage)
        {
            string        message           = recvMessage.ToLower().Trim();
            List <string> availableCommands = new List <string>();

            foreach (ChatHandlerBase chatHandler in _chatHandlers)
            {
                // Cleanup to one function
                if (chatHandler.GetMultipleCommandText().Length < 1)
                {
                    string command = chatHandler.GetCommandText();
                    if (command.StartsWith(message))
                    {
                        string[] cmdPart = command.Replace(message, string.Empty).Trim().Split(new[] { ' ' });

                        if (!availableCommands.Contains(cmdPart[0]))
                        {
                            availableCommands.Add(cmdPart[0]);
                        }
                    }
                }
                else
                {
                    foreach (string command in chatHandler.GetMultipleCommandText())
                    {
                        if (command.StartsWith(message))
                        {
                            string[] cmdPart = command.Replace(message, string.Empty).Trim().Split(new[] { ' ' });

                            if (!availableCommands.Contains(cmdPart[0]))
                            {
                                availableCommands.Add(cmdPart[0]);
                            }
                        }
                    }
                }
            }

            if (availableCommands.Any())
            {
                ChatUtil.SendPrivateChat(remoteUserId, string.Format("Available subcommands for '{0}' command: {1}", message, string.Join(", ", availableCommands.ToArray())));
            }
        }
        public override bool HandleCommand(ulong userId, string[] words)
        {
            MyObjectBuilder_Faction currentfaction;

            currentfaction = Faction.getFaction(Faction.getFactionID(userId));
            foreach (MyObjectBuilder_FactionMember currentmember in currentfaction.Members)
            {
                if (currentmember.IsLeader == true)//currentmember.isleader(currentfaction)
                {
                    if (Factionpointtransaction.transferFP(userId, words[0], Convert.ToInt32(words[1])) == true)
                    {
                        ChatUtil.SendPrivateChat(userId, "Transfer was Sucessful.");
                        return(true);
                    }
                    else
                    {
                        ChatUtil.SendPrivateChat(userId, "Transfer was Unsucessful.");
                        return(false);
                    }
                }
            }
            return(false);
        }
示例#7
0
        public static int getitemidfromitemname(string itemname, ulong userID, ShopItem item)
        {
            var temp = new MyObjectBuilder_PhysicalObject();

            if (item != null)
            {
                if (item.ItemName == itemname)
                {
                    temp = new MyObjectBuilder_Ingot()
                    {
                        SubtypeName = itemname
                    };
                    ChatUtil.SendPrivateChat(userID, Convert.ToString(temp.GetHashCode()));
                    return(temp.GetHashCode());
                }
                else
                {
                    ChatUtil.SendPrivateChat(userID, "Please enter a valid item name.");
                }
            }


            return(0);
        }
示例#8
0
        public static bool buyItem(string itemname, long buyamount, ulong userID)
        {
            ShopItems = getshoppinglist(ShopItems);
            DynShopPrices.DynPrices(ShopItems, Faction.getFactionID(userID));
            //ChatUtil.SendPrivateChat(userID, "Buying Item.");
            long   amount           = -1;
            string itemnamelowerend = itemname.ToLower().Substring(1);
            string itemnamecapital  = itemname.ToUpper().Substring(0, 1);

            itemname = itemnamecapital + itemnamelowerend;
            if (buyamount < 0)
            {
                ChatUtil.SendPrivateChat(userID, "Please enter a positive value.");
                return(false);
            }
            foreach (ShopItem item in ShopItems)
            {
                if (item.ItemName == itemname)
                {
                    amount = item.ItemPrice * buyamount;
                }
            }
            if (amount == -1)
            {
                ChatUtil.SendPrivateChat(userID, "Item does not exist.");
                return(false);
            }
            long facID     = Faction.getFactionID(userID);
            int  intAmount = Convert.ToInt32(amount);

            if (ChatUtil.CheckPlayerIsInWorld(userID))
            {
                if (!FactionPoints.RemoveFP(Convert.ToUInt64(facID), intAmount))
                {
                    ChatUtil.SendPrivateChat(userID, "You do not have sufficient points to complete your purchase.");
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            Boolean component = false;

            switch (itemname)
            {
            case ("UpgradedConstruction"):
            case ("AdvancedConstruction"):
            case ("QuantumConstruction"):
            {
                component = true;
                break;
            }

            default:
                break;
            }

            if (component)
            {
                ChatUtil.AddComp(userID, itemname, Convert.ToInt32(buyamount));
                return(true);
            }
            else
            {
                ChatUtil.AddIngot(userID, itemname, Convert.ToInt32(buyamount));
                return(true);
            }
        }
示例#9
0
        /// <summary>
        /// This function displays available help for all the functionality of this plugin
        /// </summary>
        /// <param name="remoteUserId"></param>
        /// <param name="commandParts"></param>
        private void HandleHelpCommand(ulong remoteUserId, IReadOnlyCollection <string> commandParts)
        {
            if (commandParts.Count == 1)
            {
                List <string> commands = new List <string>();
                foreach (ChatHandlerBase handler in _chatHandlers)
                {
                    // We should replace this to just have the handler return a string[] of base commands
                    if (handler.GetMultipleCommandText().Length < 1)
                    {
                        string commandBase = handler.GetCommandText().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).First();
                        if (!commands.Contains(commandBase) && (!handler.IsClientOnly()) && (!handler.IsAdminCommand() || (handler.IsAdminCommand() && (PlayerManager.Instance.IsUserAdmin(remoteUserId) || remoteUserId == 0))))
                        {
                            commands.Add(commandBase);
                        }
                    }
                    else
                    {
                        foreach (string cmd in handler.GetMultipleCommandText())
                        {
                            string commandBase = cmd.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).First();
                            if (!commands.Contains(commandBase) && (!handler.IsClientOnly()) && (!handler.IsAdminCommand() || (handler.IsAdminCommand() && (PlayerManager.Instance.IsUserAdmin(remoteUserId) || remoteUserId == 0))))
                            {
                                commands.Add(commandBase);
                            }
                        }
                    }
                }

                string commandList = string.Join(", ", commands);
                string info        = string.Format("Conquest Plugin v{0}.  Available Commands: {1}", Version, commandList);
                ChatUtil.SendPrivateChat(remoteUserId, info);
            }
            else
            {
                string helpTarget = string.Join(" ", commandParts.Skip(1).ToArray());
                bool   found      = false;
                foreach (ChatHandlerBase handler in _chatHandlers)
                {
                    // Again, we should get handler to just return string[] of command Text
                    if (handler.GetMultipleCommandText().Length < 1)
                    {
                        if (String.Equals(handler.GetCommandText(), helpTarget, StringComparison.CurrentCultureIgnoreCase))
                        {
                            ChatUtil.SendPrivateChat(remoteUserId, handler.GetHelp());
                            found = true;
                        }
                    }
                    else
                    {
                        foreach (string cmd in handler.GetMultipleCommandText())
                        {
                            if (String.Equals(cmd, helpTarget, StringComparison.CurrentCultureIgnoreCase))
                            {
                                ChatUtil.SendPrivateChat(remoteUserId, handler.GetHelp());
                                found = true;
                            }
                        }
                    }
                }

                if (!found)
                {
                    List <string> helpTopics = new List <string>();

                    foreach (ChatHandlerBase handler in _chatHandlers)
                    {
                        // Again, cleanup to one function
                        string[] multipleCommandText = handler.GetMultipleCommandText();
                        if (multipleCommandText.Length == 0)
                        {
                            if (handler.GetCommandText().ToLower().StartsWith(helpTarget.ToLower()) && ((!handler.IsAdminCommand()) || (handler.IsAdminCommand() && (PlayerManager.Instance.IsUserAdmin(remoteUserId) || remoteUserId == 0))))
                            {
                                helpTopics.Add(handler.GetCommandText().ToLower().Replace(helpTarget.ToLower(), string.Empty));
                            }
                        }
                        else
                        {
                            foreach (string cmd in multipleCommandText)
                            {
                                if (cmd.ToLower().StartsWith(helpTarget.ToLower()) && ((!handler.IsAdminCommand()) || (handler.IsAdminCommand() && (PlayerManager.Instance.IsUserAdmin(remoteUserId) || remoteUserId == 0))))
                                {
                                    helpTopics.Add(cmd.ToLower().Replace(helpTarget.ToLower(), string.Empty));
                                }
                            }
                        }
                    }

                    if (helpTopics.Any())
                    {
                        ChatUtil.SendPrivateChat(remoteUserId, string.Format("Help topics for command '{0}': {1}", helpTarget.ToLower(), string.Join(",", helpTopics.ToArray())));
                        found = true;
                    }
                }

                if (!found)
                {
                    ChatUtil.SendPrivateChat(remoteUserId, "Unknown command");
                }
            }
        }