public void CreateCommandHotlist(ulong sender, string param = null) { List <CommandStruct> commands = new List <CommandStruct>(Commands); if (!string.IsNullOrEmpty(param)) { commands = new List <CommandStruct>( Commands.Where(c => c.Name.IndexOf(param, StringComparison.InvariantCultureIgnoreCase) >= 0)); if (commands.Count == 0) { MessageClientTextMessage.SendMessage(sender, "Server", string.Format("No command matching with {0} could be found.", param)); return; } } if (!_commandCache.ContainsKey(sender)) { _commandCache.Add(sender, commands); } else { _commandCache[sender] = commands; } var message = new MessageCommandPermission() { Commands = commands, CommandAction = CommandActions.List }; ConnectionHelper.SendMessageToPlayer(sender, message); }
public void ProcessCommandPermission(ulong steamId, string[] args) { var commandMessage = new MessageCommandPermission(); switch (args[1].ToLowerInvariant()) { case "setlevel": if (args.Length < 4) { MyAPIGateway.Utilities.ShowMessage("Permissions", "Not enough arguments."); MyAPIGateway.Utilities.ShowMessage("Command setlevel", "/perm command setlevel <commandName> <level>"); return; } uint level; if (uint.TryParse(args[3], out level)) { commandMessage.Commands = new List <CommandStruct>(); commandMessage.CommandAction = CommandActions.Level; commandMessage.Commands.Add(new CommandStruct() { Name = args[2], NeededLevel = level }); } else if (string.Equals(args[3], "none", StringComparison.InvariantCultureIgnoreCase)) { commandMessage.Commands = new List <CommandStruct>(); commandMessage.CommandAction = CommandActions.Level; commandMessage.Commands.Add(new CommandStruct() { Name = args[2], NeededLevel = uint.MaxValue }); } else { MyAPIGateway.Utilities.ShowMessage("Permissions", string.Format("{0} is no valid level. It must be an integer and can't be below 0.", args[3])); return; } break; case "list": commandMessage.CommandAction = CommandActions.List; if (args.Length > 2) { commandMessage.ListParameter = args[2]; } break; default: MyAPIGateway.Utilities.ShowMessage("Permissions", string.Format("There is no action named {0}. Available actions: setlevel, list.", args[1])); return; } ConnectionHelper.SendMessageToServer(commandMessage); }
private void SendPermissionChange(ulong steamId, CommandStruct commandStruct) { var message = new MessageCommandPermission() { Commands = new List <CommandStruct>(), CommandAction = CommandActions.Level }; message.Commands.Add(commandStruct); ConnectionHelper.SendMessageToPlayer(steamId, message); }