public override void Use(Player p, string message) { string[] args = message.Split(' '); if (message == "" || args.Length == 1) { Help(p); return; } Command cmd = Command.all.Find(args[0]); if (cmd == null) { Player.SendMessage(p, "Could not find command entered"); return; } if (p != null && !p.group.CanExecute(cmd)) { Player.SendMessage(p, "Your rank cannot use this command."); return; } LevelPermission perm = Level.PermissionFromName(args[1]); if (perm == LevelPermission.Null) { Player.SendMessage(p, "Could not find rank specified"); return; } if (p != null && perm > p.group.Permission) { Player.SendMessage(p, "Cannot set permissions to a rank higher than yours."); return; } int otherPermIndex = 0; string permName = "permission"; if (args.Length == 2) { GrpCommands.allowedCommands.Find(rA => rA.commandName == cmd.name).lowestRank = perm; GrpCommands.Save(GrpCommands.allowedCommands); GrpCommands.fillRanks(); } else if (!int.TryParse(args[2], out otherPermIndex)) { Player.SendMessage(p, "\"" + args[2] + "\" is not an integer."); } else { CommandOtherPerms.OtherPerms perms = CommandOtherPerms.Find(cmd, otherPermIndex); if (perms == null) { Player.SendMessage(p, "This command has no additional permission with that number."); return; } perms.Permission = (int)perm; CommandOtherPerms.Save(); permName = "additional permission " + otherPermIndex; } Player.GlobalMessage("&d" + cmd.name + "%S's " + permName + " was set to " + Level.PermissionToName(perm)); Player.SendMessage(p, cmd.name + "'s " + permName + " was set to " + Level.PermissionToName(perm)); }
static void UpdatePermissions(Command cmd, Player p, string message) { GrpCommands.Save(GrpCommands.allowedCommands); GrpCommands.fillRanks(); Chat.MessageAll("&d{0}%S{1}", cmd.name, message); if (Player.IsSuper(p)) { Player.Message(p, cmd.name + message); } }
public override void Use(Player p, string message) { if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; } string foundBlah = Command.all.FindShort(message.Split(' ')[0]); Command foundCmd; if (foundBlah == "") { foundCmd = Command.all.Find(message.Split(' ')[0]); } else { foundCmd = Command.all.Find(foundBlah); } if (foundCmd == null) { Player.SendMessage(p, "Could not find command entered"); return; } if (p != null && !p.group.CanExecute(foundCmd)) { Player.SendMessage(p, "This command is higher than your rank."); return; } LevelPermission newPerm = Level.PermissionFromName(message.Split(' ')[1]); if (newPerm == LevelPermission.Null) { Player.SendMessage(p, "Could not find rank specified"); return; } if (p != null && newPerm > p.group.Permission) { Player.SendMessage(p, "Cannot set to a rank higher than yourself."); return; } GrpCommands.rankAllowance newCmd = GrpCommands.allowedCommands.Find(rA => rA.commandName == foundCmd.name); newCmd.lowestRank = newPerm; GrpCommands.allowedCommands[GrpCommands.allowedCommands.FindIndex(rA => rA.commandName == foundCmd.name)] = newCmd; GrpCommands.Save(GrpCommands.allowedCommands); GrpCommands.fillRanks(); Player.GlobalMessage("&d" + foundCmd.name + Server.DefaultColor + "'s permission was changed to " + Level.PermissionToName(newPerm)); //if (p == null) ; // this is useless? //{ Player.SendMessage(p, foundCmd.name + "'s permission was changed to " + Level.PermissionToName(newPerm)); return; //} }
public void SaveCommands() { GrpCommands.Save(storedCommands); GrpCommands.fillRanks(); LoadCommands(); }