public static string Append(Player p, string ai, string cmd, string[] args) { using (StreamWriter w = new StreamWriter("bots/" + ai, true)) { if (cmd.Length == 0) { cmd = "walk"; } if (cmd.CaselessEq("tp")) { cmd = "teleport"; } BotInstruction ins = BotInstruction.Find(cmd); if (ins == null) { p.Message("Could not find instruction \"" + cmd + "\""); return(null); } CommandExtraPerms killPerms = CommandExtraPerms.Find("BotSet", 1); if (ins.Name.CaselessEq("kill") && !killPerms.UsableBy(p.Rank)) { killPerms.MessageCannotUse(p); return(null); } try { ins.Output(p, args, w); } catch { p.Message("Invalid arguments given for instruction " + ins.Name); return(null); } return(ins.Name); } }
public static void Append(Player p, string ai, string action, string[] args) { using (StreamWriter w = new StreamWriter("bots/" + ai, true)) { if (action.Length == 0) { action = "walk"; } if (action.CaselessEq("tp")) { action = "teleport"; } BotInstruction ins = BotInstruction.Find(action); if (ins == null) { Player.Message(p, "Could not find instruction \"" + action + "\""); return; } LevelPermission killPerm = CommandExtraPerms.MinPerm("botset"); if (ins.Name.CaselessEq("kill") && p.Rank < killPerm) { Formatter.MessageNeedMinPerm(p, "+ can toggle a bot's killer instinct.", killPerm); return; } ins.Output(p, args, w); } }