private void ChatMessage(int playerId, String playerName, String message) { if (!message.StartsWith("/")) { return; } API.CancelEvent(); List <String> args = new List <String>(); String[] splitMessage = message.Replace("/", "").Split(null); String command = splitMessage[0]; if (splitMessage.Length > 1) { for (int i = 1; i < splitMessage.Length; i++) { args.Add(splitMessage[i]); } } if (!Core.GetInstance().HasCommand(command)) { TriggerClientEvent("chatMessage", "", Color.Error, "[System] Unknown command: ^0/" + command); return; } Assembly assembly = Assembly.GetAssembly(this.GetType()); Type commandType = assembly.GetType("Server.Commands." + command.Substring(0, 1).ToUpper() + command.Substring(1, (command.Length - 1))); CommandBase commandObject = (CommandBase)Core.GetInstance().GetCommand(command); CommandHandlerBase commandHandler = commandObject.GetHandler(); commandHandler.SetExecutor(playerId, playerName); commandHandler.SetArgs(args); commandObject.GetHandler().Process(); }
private void LoadModules() { Core.GetInstance().LoadModules(this.GetType()); }