示例#1
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);
                    }
                }
            }
        }