示例#1
0
        public static string[] GetCommandList(ePrivLevel plvl, bool addDesc)
        {
            IDictionaryEnumerator enumerator = m_cmds.GetEnumerator();
            ArrayList             list       = new ArrayList();

            while (enumerator.MoveNext())
            {
                GameCommand command = enumerator.Value as GameCommand;
                string      key     = enumerator.Key as string;
                if ((command != null) && (key != null))
                {
                    if (key[0] == '&')
                    {
                        key = '/' + key.Remove(0, 1);
                    }
                    if (plvl >= command.m_lvl)
                    {
                        if (addDesc)
                        {
                            list.Add(key + " - " + command.m_desc);
                        }
                        else
                        {
                            list.Add(command.m_cmd);
                        }
                    }
                }
            }
            return((string[])list.ToArray(typeof(string)));
        }
示例#2
0
        public static string[] GetCommandList(ePrivLevel plvl, bool addDesc)
        {
            IDictionaryEnumerator iter = m_cmds.GetEnumerator();

            ArrayList list = new ArrayList();

            while (iter.MoveNext())
            {
                GameCommand cmd = iter.Value as GameCommand;
                string cmdString = iter.Key as string;

                if (cmd == null || cmdString == null)
                {
                    continue;
                }

                if (cmdString[0] == '&')
                    cmdString = '/' + cmdString.Remove(0, 1);
                if ((uint)plvl >= cmd.m_lvl)
                {
                    if (addDesc)
                    {
                        list.Add(cmdString + " - " + cmd.m_desc);
                    }
                    else
                    {
                        list.Add(cmd.m_cmd);
                    }
                }
            }

            return (string[])list.ToArray(typeof(string));
        }
示例#3
0
        public static string[] GetCommandList(ePrivLevel plvl, bool addDesc)
        {
            IDictionaryEnumerator enumerator = CommandMgr.m_cmds.GetEnumerator();
            ArrayList             arrayList  = new ArrayList();

            while (enumerator.MoveNext())
            {
                GameCommand gameCommand = enumerator.Value as GameCommand;
                string      text        = enumerator.Key as string;
                if (gameCommand != null && text != null)
                {
                    if (text[0] == '&')
                    {
                        text = '/' + text.Remove(0, 1);
                    }
                    if (plvl >= (ePrivLevel)gameCommand.m_lvl)
                    {
                        if (addDesc)
                        {
                            arrayList.Add(text + " - " + gameCommand.m_desc);
                        }
                        else
                        {
                            arrayList.Add(gameCommand.m_cmd);
                        }
                    }
                }
            }
            return((string[])arrayList.ToArray(typeof(string)));
        }
示例#4
0
        /// <summary>
        /// Returns an array of all the available commands with the specified plvl and their descriptions
        /// </summary>
        /// <param name="plvl">plvl of the commands to get</param>
        /// <param name="addDesc"></param>
        /// <returns></returns>
        public static string[] GetCommandList(ePrivLevel plvl, bool addDesc)
        {
            IDictionaryEnumerator iter = m_gameCommands.GetEnumerator();

            ArrayList list = new ArrayList();

            while (iter.MoveNext())
            {
                GameCommand cmd       = iter.Value as GameCommand;
                string      cmdString = iter.Key as string;

                if (cmd == null || cmdString == null)
                {
                    continue;
                }

                if (cmdString[0] == '&')
                {
                    cmdString = '/' + cmdString.Remove(0, 1);
                }
                if ((uint)plvl >= cmd.m_lvl)
                {
                    if (addDesc)
                    {
                        list.Add(cmdString + " - " + cmd.m_desc);
                    }
                    else
                    {
                        list.Add(cmd.m_cmd);
                    }
                }
            }

            return((string[])list.ToArray(typeof(string)));
        }
示例#5
0
 public CmdAttribute(string cmd, string[] alias, ePrivLevel lvl, string desc, params string[] usage)
 {
     this.m_cmd         = cmd;
     this.m_cmdAliases  = alias;
     this.m_lvl         = (uint)lvl;
     this.m_description = desc;
     this.m_usage       = usage;
 }
示例#6
0
 public CmdAttribute(string cmd, string[] alias, ePrivLevel lvl, string desc, params string[] usage)
 {
     m_cmd = cmd;
     m_cmdAliases = alias;
     m_lvl = (uint)lvl;
     m_description = desc;
     m_usage = usage;
 }
示例#7
0
        public void OnCommand(GameClient client, string[] args)
        {
            if (IsSpammingCommand(client.Player, "cmdhelp"))
            {
                return;
            }

            ePrivLevel privilegeLevel = (ePrivLevel)client.Account.PrivLevel;
            bool       isCommand      = true;

            if (args.Length > 1)
            {
                try
                {
                    privilegeLevel = (ePrivLevel)Convert.ToUInt32(args[1]);
                }
                catch (Exception)
                {
                    isCommand = false;
                }
            }

            if (isCommand)
            {
                string[] commandList = GetCommandList(privilegeLevel);
                DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Cmdhelp.PlvlCommands", privilegeLevel.ToString()));

                foreach (string command in commandList)
                {
                    DisplayMessage(client, command);
                }
            }
            else
            {
                string command = args[1];

                if (command[0] != '&')
                {
                    command = "&" + command;
                }

                ScriptMgr.GameCommand gameCommand = ScriptMgr.GetCommand(command);

                if (gameCommand == null)
                {
                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Cmdhelp.NoCommand", command));
                }
                else
                {
                    DisplayMessage(client, LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Players.Cmdhelp.Usage", command));

                    foreach (string usage in gameCommand.Usage)
                    {
                        DisplayMessage(client, usage);
                    }
                }
            }
        }
示例#8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="cmd">Command to handle</param>
 /// <param name="alias">Other names the command goes by</param>
 /// <param name="lvl">Minimum required plvl for this command</param>
 /// <param name="desc">Description of the command</param>
 /// <param name="usage">How to use the command</param>
 public CmdAttribute(string cmd, string[] alias, ePrivLevel lvl, string desc, params string[] usage)
 {
     m_cmd         = cmd;
     m_cmdAliases  = alias;
     m_lvl         = (uint)lvl;
     m_description = desc;
     //m_usage = new string[1];
     m_usage = usage;
 }
示例#9
0
        private string[] GetCommandList(ePrivLevel privilegeLevel)
        {
            lock (m_syncObject)
            {
                if (!m_commandLists.Keys.Contains(privilegeLevel))
                {
                    string[] commandList = ScriptMgr.GetCommandList(privilegeLevel, true);
                    Array.Sort(commandList);
                    m_commandLists.Add(privilegeLevel, commandList);
                }

                return(m_commandLists[privilegeLevel]);
            }
        }
示例#10
0
 protected virtual void OnConnect()
 {
     try
     {
         if (((IPEndPoint)this.Socket.RemoteEndPoint).Address == ((IPEndPoint)this.Socket.LocalEndPoint).Address)
         {
             this.m_privLevel = ePrivLevel.Admin;
         }
         else
         {
             this.m_privLevel = ePrivLevel.Player;
         }
     }
     catch (Exception ex)
     {
         BaseClient.log.Error(ex.Message, ex);
     }
     if (Interlocked.Exchange(ref this.m_isConnected, 1) == 0 && this.Connected != null)
     {
         this.Connected(this);
     }
 }
示例#11
0
 public CmdAttribute(string cmd, ePrivLevel lvl, string desc, params string[] usage) : this(cmd, null, lvl, desc, usage)
 {
 }
示例#12
0
 public CmdAttribute(string cmd, ePrivLevel lvl, string desc, params string[] usage)
     : this(cmd, null, lvl, desc, usage)
 {
 }
示例#13
0
 /// <summary>
 /// Returns an array of all the available commands with the specified plvl and their descriptions
 /// </summary>
 /// <param name="plvl">plvl of the commands to get</param>
 /// <param name="addDesc"></param>
 /// <returns></returns>
 public static string[] GetCommandList(ePrivLevel plvl, bool addDesc)
 {
     return(m_gameCommands.Where(kv => kv.Value != null && kv.Key != null && (uint)plvl > kv.Value.m_lvl)
            .Select(kv => string.Format("/{0}{2}{1}", kv.Key.Remove(0, 1), addDesc ? kv.Value.m_desc : string.Empty, addDesc ? " - " : string.Empty))
            .ToArray());
 }
示例#14
0
        private String[] GetCommandList(ePrivLevel privilegeLevel)
        {
            lock (m_syncObject)
            {
                if (!m_commandLists.Keys.Contains(privilegeLevel))
                {
                    String[] commandList = ScriptMgr.GetCommandList(privilegeLevel, true);
                    Array.Sort(commandList);
                    m_commandLists.Add(privilegeLevel, commandList);
                }

                return m_commandLists[privilegeLevel];
            }
        }