/// <summary> /// </summary> /// <param name="commandName"> /// </param> /// <param name="client"> /// </param> /// <param name="target"> /// </param> /// <param name="commandArguments"> /// </param> public void CallChatCommand(string commandName, ZoneClient client, Identity target, string[] commandArguments) { Assembly assembly = Assembly.GetExecutingAssembly(); if (commandName.ToUpperInvariant() != "LISTCOMMANDS") { foreach (KeyValuePair<string, Type> kv in this.chatCommands) { if (kv.Key.Substring(kv.Key.IndexOf(":", StringComparison.Ordinal) + 1).ToUpperInvariant() == commandName.ToUpperInvariant()) { AOChatCommand aoc = (AOChatCommand) assembly.CreateInstance( kv.Key.Substring(0, kv.Key.IndexOf(":", StringComparison.Ordinal))); if (aoc != null) { // Check GM Level bitwise if ((client.Character.Stats[StatIds.gmlevel].Value < aoc.GMLevelNeeded()) && (aoc.GMLevelNeeded() > 0)) { client.Character.Playfield.Publish( ChatText.CreateIM( client.Character, "You are not authorized to use this command!. This incident will be recorded.")); // It is not yet :) return; } // Check if only one argument has been passed for "help" if (commandArguments.Length == 2) { if (commandArguments[1].ToUpperInvariant() == "HELP") { aoc.CommandHelp(client.Character); return; } } // Execute the command with the given command arguments, if CheckCommandArguments is true else print command help if (aoc.CheckCommandArguments(commandArguments)) { aoc.ExecuteCommand(client.Character, target, commandArguments); } else { aoc.CommandHelp(client.Character); } } } } } else { client.Character.Playfield.Publish(ChatText.CreateIM(client.Character, "Available Commands:")); string[] scriptNames = this.chatCommands.Keys.ToArray(); for (int i = 0; i < scriptNames.Length; i++) { scriptNames[i] = scriptNames[i].Substring(scriptNames[i].IndexOf(":", StringComparison.Ordinal) + 1) + ":" + scriptNames[i].Substring( 0, scriptNames[i].IndexOf(":", StringComparison.Ordinal)); } Array.Sort(scriptNames); foreach (string scriptName in scriptNames) { string typename = scriptName.Substring(scriptName.IndexOf(":", StringComparison.Ordinal) + 1); AOChatCommand aoc = (AOChatCommand)assembly.CreateInstance(typename); if (aoc != null) { if (client.Character.Stats[StatIds.gmlevel].Value >= aoc.GMLevelNeeded()) { client.Character.Playfield.Publish( ChatText.CreateIM( client.Character, scriptName.Substring(0, scriptName.IndexOf(":", StringComparison.Ordinal)))); } } } } }
/// <summary> /// </summary> /// <param name="server"> /// </param> /// <returns> /// </returns> public ZoneClient Create(ZoneServer server) { ZoneClient zc = new ZoneClient(server, this.messageSerializer, this.bus); zc.zoneBus = server.zoneBus; return new ZoneClient(server, this.messageSerializer, this.bus); }