/// <summary> /// Register a new console command. /// </summary> /// <param name="name">Command name.</param> /// <param name="func">Delegate to the console command function to be called when command is invoked.</param> /// <param name="comment">Help string, will be displayed when typing in console "command ?".</param> /// <param name="flags">Bitfield consist of VF_ flags (e.g. VF_CHEAT)</param> public static void Register(string name, ConsoleCommandDelegate func, string comment = "", CVarFlags flags = CVarFlags.None) { if (!commands.ContainsKey(name)) { NativeCVarMethods.RegisterCommand(name, comment, flags); commands.Add(name, func); } }
public ConsoleCommand(ConsoleCommandDelegate cmd, params string[] cmdNames) { if (cmdNames == null || cmdNames.Length < 1) throw new NotSupportedException(); Command = cmd; Names = new List<string>(cmdNames); Arguments = new List<ConsoleCommandArgument>(); }
public ConsoleCommand(ConsoleCommandDelegate cmd, params string[] cmdNames) { if (cmdNames == null || cmdNames.Length < 1) { throw new NotSupportedException(); } this.Command = cmd; this.Names = new List <string>(cmdNames); this.Arguments = new List <ConsoleCommandArgument>(); }
/// <summary> /// Register a new console command. /// </summary> /// <param name="name">Command name.</param> /// <param name="func">Delegate to the console command function to be called when command is invoked.</param> /// <param name="comment">Help string, will be displayed when typing in console "command ?".</param> /// <param name="flags">Bitfield consist of VF_ flags (e.g. VF_CHEAT)</param> public static void Register(string name, ConsoleCommandDelegate func, string comment = "", CVarFlags flags = CVarFlags.None) { if (!commands.ContainsKey(name)) { NativeCVarMethods.RegisterCommand(name, comment, flags); commands.Add(name, func); } else { throw new DuplicateConsoleCommandException(string.Format("The console command {0} was already registered", name)); } }
/// <summary> /// Registers a console command to the console command list. /// </summary> /// <param name="alias"></param> /// <param name="description"></param> /// <param name="callback"></param> /// <returns></returns> public static bool AddCommnd(List<string> alias, string description, ConsoleCommandDelegate callback) { // Validate the parameters.. if (alias.Count == 0 || string.IsNullOrEmpty(description) || callback == null) return false; // Ensure no other command has any alias defined.. if (ConsoleCommands.Commands.Any(c => alias.Any(c.HasAlias))) return false; // Add the new command.. var cmd = new ConsoleCommand(alias, callback) { Description = description }; ConsoleCommands.Commands.Add(cmd); return true; }
/// <summary> /// Register a new console command. /// </summary> /// <param name="name">Command name.</param> /// <param name="func">Delegate to the console command function to be called when command is invoked.</param> /// <param name="comment">Help string, will be displayed when typing in console "command ?".</param> /// <param name="flags">Bitfield consist of VF_ flags (e.g. VF_CHEAT)</param> public static void Register(string name, ConsoleCommandDelegate func, string comment = "", CVarFlags flags = CVarFlags.None, bool overwrite = false) { bool containsKey = Commands.ContainsKey(name); if (containsKey && overwrite) { Unregister(name); containsKey = false; } if (!containsKey) { NativeCVarMethods.RegisterCommand(name, comment, flags); Commands.Add(name, func); } else throw new DuplicateConsoleCommandException(string.Format("The console command {0} was already registered", name)); }
/// <summary> /// Register a new console command. /// </summary> /// <param name="name">Command name.</param> /// <param name="func"> /// Delegate to the console command function to be called when command is invoked. /// </param> /// <param name="comment"> /// Help string, will be displayed when typing in console "command ?". /// </param> /// <param name="flags">Bitfield consist of VF_ flags (e.g. VF_CHEAT)</param> public static void Register(string name, ConsoleCommandDelegate func, string comment = "", CVarFlags flags = CVarFlags.None, bool overwrite = false) { bool containsKey = Commands.ContainsKey(name); if (containsKey && overwrite) { Unregister(name); containsKey = false; } if (!containsKey) { Native.ConsoleInterop.RegisterCommand(name, comment, flags); Commands.Add(name, func); } else { throw new DuplicateConsoleCommandException(string.Format("The console command {0} was already registered", name)); } }
/// <summary> /// Registers a console command to the console command list. /// </summary> /// <param name="alias"></param> /// <param name="description"></param> /// <param name="callback"></param> /// <returns></returns> public static bool AddCommnd(List <string> alias, string description, ConsoleCommandDelegate callback) { // Validate the parameters.. if (alias.Count == 0 || string.IsNullOrEmpty(description) || callback == null) { return(false); } // Ensure no other command has any alias defined.. if (ConsoleCommands.Commands.Any(c => alias.Any(c.HasAlias))) { return(false); } // Add the new command.. var cmd = new ConsoleCommand(alias, callback) { Description = description }; ConsoleCommands.Commands.Add(cmd); return(true); }
internal static extern void CSharpResource_SetMain(IntPtr resourcePointer, MainDelegate mainDelegate, StopDelegate stopDelegate, TickDelegate tickDelegate, ServerEventDelegate serverEventDelegate, CheckpointDelegate checkpointDelegate, ClientEventDelegate clientEventDelegate, PlayerDamageDelegate playerDamageDelegate, PlayerConnectDelegate playerConnectDelegate, PlayerDeathDelegate playerDeathDelegate, PlayerDisconnectDelegate playerDisconnectDelegate, PlayerRemoveDelegate playerRemoveDelegate, VehicleRemoveDelegate vehicleRemoveDelegate, PlayerChangeVehicleSeatDelegate playerChangeVehicleSeatDelegate, PlayerEnterVehicleDelegate playerEnterVehicleDelegate, PlayerLeaveVehicleDelegate playerLeaveVehicleDelegate, CreatePlayerDelegate createPlayerDelegate, RemovePlayerDelegate removePlayerDelegate, CreateVehicleDelegate createVehicleDelegate, RemoveVehicleDelegate removeVehicleDelegate, CreateBlipDelegate createBlipDelegate, RemoveBlipDelegate removeBlipDelegate, CreateCheckpointDelegate createCheckpointDelegate, RemoveCheckpointDelegate removeCheckpointDelegate, CreateVoiceChannelDelegate createVoiceChannelDelegate, RemoveVoiceChannelDelegate removeVoiceChannelDelegate, ConsoleCommandDelegate consoleCommandDelegate, MetaDataChange metaDataChange, MetaDataChange syncedMetaDataChange, CreateColShapeDelegate createColShapeDelegate, RemoveColShapeDelegate removeColShapeDelegate, ColShapeDelegate colShapeDelegate );
internal static extern void CSharpResourceImpl_SetConsoleCommandDelegate(IntPtr resource, ConsoleCommandDelegate @delegate);
public ConsoleCommand(string name, ConsoleCommandDelegate command) { Name = name; Command = command; }
/// <summary> /// Binds a command to a command handler. A command cannot contain spaces. When the handler /// is executed the first parameter is the command, the following parameters were parsed /// by splitting on the space. /// </summary> /// <param name="commandName">Name of the command. Spaces are not permitted. Case sensitive</param> /// <param name="description">Description of the command.</param> /// <param name="handler">Handler for the command.</param> /// <returns>A command binding instance.</returns> public CommandBinding Bind(string commandName, string description, ConsoleCommandDelegate handler) { var binding = Bind(commandName, description); binding.CommandHandlers += handler; return binding; }
public void AddConsoleCommand(string Command, ConsoleCommandDelegate MethodToBindTo) { BindConsoleCommand(Command, MethodToBindTo); }
public void AddConsoleCommand(string Command, ConsoleCommandDelegate MethodToBindTo) { BindConsoleCommand(Command, MethodToBindTo); }