Пример #1
0
        private void ExecuteCommand(Character caller, string[] split, Command command)
        {
            if (caller.Account.AccountData.Admin == 0)
            {
                if (GameConstants.BlockedFromCommands(caller))
                {
                    caller.Action.SystemMessage("[Command] You are blocked from using commands.");
                    return;
                }
            }

            if (command.IsDisabled)
            {
                caller.Action.SystemMessage("[Command] Disabled command.");
                return;
            }

            if (command.IsRestricted && caller.Account.AccountData.Admin == 0) //TODO: GM Levels
            {
                caller.Action.SystemMessage("[Command] Restricted command.");
                return;
            }

            try
            {
                var ctx = new CommandCtx(caller, split);
                command.Execute(ctx);
            }
            catch (Exception ex)
            {
                Log.WarnFormat("CommandException: {0}", ex);

                if (caller.Account.AccountData.Admin > 0)
                {
                    caller.SendMessage($"[Command] Error: " + ex.Message);
                }

                caller.Action.SystemMessage("[Command] An error occurred. Syntax: @{0} {1}", command.Name, command.Parameters);
            }
        }