Ejemplo n.º 1
0
        public static void resetChat()
        {
            String[] texts = new String[4];
            texts[0] = getNetworkChatFieldByNum(13);
            texts[1] = getNetworkChatFieldByNum(20);
            texts[2] = getNetworkChatFieldByNum(27);
            texts[3] = getNetworkChatFieldByNum(34);

            for (int i = 0; i < 4; i++)
            {
                if (texts[i].StartsWith("/"))
                {
                    texts[i] = "";
                }
            }

            NetworkPlayer[] players     = new NetworkPlayer[4];
            bool[]          isServerMsg = new bool[4];
            String[]        names       = new String[4];

            names[0] = getNetworkChatFieldByNum(10);
            names[1] = getNetworkChatFieldByNum(17);
            names[2] = getNetworkChatFieldByNum(24);
            names[3] = getNetworkChatFieldByNum(31);


            for (int i = 0; i < 4; i++)
            {
                BetterNetworkUser temp1 = UserList.getUserFromName(names[i]);
                NetworkPlayer     temp;
                if (temp1 == null)
                {
                    temp = Network.player;
                }
                else
                {
                    temp = temp1.networkPlayer;
                }

                if (temp != null)
                {
                    players[i] = temp;
                }
                else
                {
                    players[i] = Network.player;
                }

                if (names[i] != null)
                {
                    if (names[i].StartsWith("Server"))
                    {
                        isServerMsg[i] = true;
                    }
                }
            }


            if (!isServerMsg[3])
            {
                getNetworkChat().askChat(texts[3], 0, players[3]);
            }
            else
            {
                NetworkChat.sendAlert(texts[3]);
            }

            for (int i = 0; i < 4; i++)
            {
                if (!isServerMsg[3 - i])
                {
                    getNetworkChat().askChat(texts[3 - i], 0, players[3 - i]);
                }
                else
                {
                    NetworkChat.sendAlert(texts[3 - i]);
                }
            }
        }
Ejemplo n.º 2
0
        public static bool ExecuteCommand(BetterNetworkUser sender, string commandString, List <String> parms)
        {
            string cmdText = commandString.ToLower();

            if (cmdText == "unload")
            {
                if (UserList.getPermission(sender.steamid) == 10)
                {
                    removeMods(sender.networkPlayer);
                    return(true);
                }
            }

            if (cmdText == "load")
            {
                if (UserList.getPermission(sender.steamid) == 10)
                {
                    removeMods(sender.networkPlayer);
                    loadMods(sender.networkPlayer);
                    return(true);
                }
            }

            foreach (Command command in CommandList.commands)
            {
                if (command.HasAlias(cmdText))
                {
                    if (command.permission > UserList.getPermission(sender.steamid))
                    {
                        if (command.permission == 1)
                        {
                            Reference.Tell(sender.networkPlayer, "You should be VIP/Donator to use this command.");
                        }
                        else
                        {
                            Reference.Tell(sender.networkPlayer, "You are not allowed to use that command. (Need lv." + command.permission + "/" + UserList.getPermission(sender.steamid) + ")");
                        }
                        return(false);
                    }
                    if (!usingHiddenChat)
                    {
                        Reference.resetChat();
                    }
                    try
                    {
                        command.CommandDelegate(new CommandArgs(cmdText, sender, parms));
                    }
                    catch (Exception e)
                    {
                        Reference.Tell(sender.networkPlayer, "Something went wrong while executing your command;");
                        Reference.Tell(sender.networkPlayer, e.Message);
                    }
                    return(true);
                }
            }
            Reference.Tell(sender.networkPlayer, "Command \"/" + commandString + "\" was not found");
            return(false);
        }