public override void OnUnregisteredCommand(MatchCommand mtcCommand) { if (String.Compare(mtcCommand.Command, "help", true) != 0) { this.SetupHelpCommands(); } }
private void ImportMatchDialogForm_Load(object sender, EventArgs e) { if (Properties.Settings.Default.ImportMatch_Location.X > 0 && Properties.Settings.Default.ImportMatch_Location.Y > 0) { this.Location = Properties.Settings.Default.ImportMatch_Location; } if (MatchCommand.ToLower().Equals("update")) { UpdateButton.Focus(); } else if (MatchCommand.ToLower().Equals("updateall")) { UpdateAllButton.Focus(); } else if (MatchCommand.ToLower().Equals("skip")) { SkipButton.Focus(); } else if (MatchCommand.ToLower().Equals("skipall")) { SkipAllButton.Focus(); } else { SkipButton.Focus(); } }
public void UnregisterCommand(MatchCommand mtcCommand) { if (_unregisterCommandDelegate != null) { _unregisterCommandDelegate(mtcCommand); } }
protected void AddCommandParser(int opCode, Func <RTData, MatchCommand> singleCommandParser) { _parsers.Add(opCode, singleCommandParser); MatchCommand shallowCommand = singleCommandParser(null); _opCodesByCommands.Add(shallowCommand, opCode); }
private void UnregisterAllCommands() { MatchCommand confirmationCommand = new MatchCommand(this.Listify <string>("@", "!", "#", "/"), this.m_strConfirmCommand, this.Listify <MatchArgumentFormat>()); this.UnregisterCommand( new MatchCommand( "CPlayerMuter", "OnCommandPlayerMute", this.Listify <string>("@", "!", "#", "/"), this.m_strPlayerMute, this.Listify <MatchArgumentFormat>( new MatchArgumentFormat( "playername", new List <string>(this.m_dicPlayerInfo.Keys))), new ExecutionRequirements(ExecutionScope.Account, 1, confirmationCommand, "You do not have the required permissions for this command."), "Player can never chat")); this.UnregisterCommand(new MatchCommand("CPlayerMuter", "OnCommandPlayerNormal", this.Listify <string>("@", "!", "#", "/"), this.m_strPlayerNormal, this.Listify <MatchArgumentFormat>(new MatchArgumentFormat("playername", new List <string>(this.m_dicPlayerInfo.Keys))), new ExecutionRequirements(ExecutionScope.Account, 1, confirmationCommand, "You do not have the required permissions for this command."), "Player can chat when moderation is Free")); this.UnregisterCommand(new MatchCommand("CPlayerMuter", "OnCommandPlayerVoice", this.Listify <string>("@", "!", "#", "/"), this.m_strPlayerVoice, this.Listify <MatchArgumentFormat>(new MatchArgumentFormat("playername", new List <string>(this.m_dicPlayerInfo.Keys))), new ExecutionRequirements(ExecutionScope.Privileges, Privileges.CanShutdownServer, 1, confirmationCommand, "You do not have the required permissions for this command."), "Player can chat when moderation is Free/Moderated")); this.UnregisterCommand(new MatchCommand("CPlayerMuter", "OnCommandPlayerAdmin", this.Listify <string>("@", "!", "#", "/"), this.m_strPlayerAdmin, this.Listify <MatchArgumentFormat>(new MatchArgumentFormat("playername", new List <string>(this.m_dicPlayerInfo.Keys))), new ExecutionRequirements(ExecutionScope.Privileges, Privileges.CanShutdownServer, 1, confirmationCommand, "You do not have the required permissions for this command."), "Player can always chat")); this.UnregisterCommand(new MatchCommand("CPlayerMuter", "OnCommandSetFreeMode", this.Listify <string>("@", "!", "#", "/"), this.m_strServerFreeMode, this.Listify <MatchArgumentFormat>(), new ExecutionRequirements(ExecutionScope.Privileges, Privileges.CanShutdownServer, 1, confirmationCommand, "You do not have the required permissions for this command."), "Normal, Voice, and Admins players can chat")); this.UnregisterCommand(new MatchCommand("CPlayerMuter", "OnCommandSetModeratedMode", this.Listify <string>("@", "!", "#", "/"), this.m_strServerModeratedMode, this.Listify <MatchArgumentFormat>(), new ExecutionRequirements(ExecutionScope.Privileges, Privileges.CanShutdownServer, 1, confirmationCommand, "You do not have the required permissions for this command."), "Voice, and Admin players can chat")); this.UnregisterCommand(new MatchCommand("CPlayerMuter", "OnCommandSetAdminMode", this.Listify <string>("@", "!", "#", "/"), this.m_strServerMutedMode, this.Listify <MatchArgumentFormat>(), new ExecutionRequirements(ExecutionScope.Privileges, Privileges.CanShutdownServer, 1, confirmationCommand, "You do not have the required permissions for this command."), "Only Admin players can chat")); }
public void UnregisterCommand(MatchCommand mtcCommand) { if (this.m_delUnregisterCommand != null) { this.m_delUnregisterCommand(mtcCommand); } }
public ConfirmationEntry(string speaker, string message, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subset) { this.Speaker = speaker; this.Message = message; this.MatchedCommand = mtcCommand; this.ConfirmationDetails = capCommand; this.MessageScope = subset; }
public void OnCommandPingPlayer(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { if (this.dicPingPlayer.ContainsKey(capCommand.MatchedArguments[0].Argument)) { if (!this.dicPingPlayer[capCommand.MatchedArguments[0].Argument].PingFails) { PingReply reply = this.PingPlayer(this.dicPingPlayer[capCommand.MatchedArguments[0].Argument].Name); if (this.dicPingPlayer[capCommand.MatchedArguments[0].Argument].Results.Count > this.iPingStorageLength) { this.dicPingPlayer[capCommand.MatchedArguments[0].Argument].Results.Clear(); } this.dicPingPlayer[capCommand.MatchedArguments[0].Argument].Results.Add(reply); if (reply.Status != IPStatus.Success) { this.dicPingPlayer[capCommand.MatchedArguments[0].Argument].PingFails = true; } if (!this.dicPingPlayer[capCommand.MatchedArguments[0].Argument].PingFails) { lock (this.dicPlayerInfo) { this.IngameSaySquad(strSpeaker + ": '" + capCommand.MatchedArguments[0].Argument + "'s Ping is " + reply.RoundtripTime + "ms.", this.dicPlayerInfo[strSpeaker].TeamID, this.dicPlayerInfo[strSpeaker].SquadID); } } else { lock (this.dicPlayerInfo) { this.IngameSaySquad(strSpeaker + ": Pinging '" + capCommand.MatchedArguments[0].Argument + "' fails!", this.dicPlayerInfo[strSpeaker].TeamID, this.dicPlayerInfo[strSpeaker].SquadID); } } } else { lock (this.dicPlayerInfo) { this.IngameSaySquad(strSpeaker + ": Pinging '" + capCommand.MatchedArguments[0].Argument + "' fails!", this.dicPlayerInfo[strSpeaker].TeamID, this.dicPlayerInfo[strSpeaker].SquadID); } } } else { if (this.lstWhiteList.Contains(capCommand.MatchedArguments[0].Argument)) { lock (this.dicPlayerInfo) { this.IngameSaySquad(strSpeaker + ": '" + capCommand.MatchedArguments[0].Argument + "' is on the whitelist and thus not monitored!", this.dicPlayerInfo[strSpeaker].TeamID, this.dicPlayerInfo[strSpeaker].SquadID); } } else { lock (this.dicPlayerInfo) { this.IngameSaySquad(strSpeaker + ": '" + capCommand.MatchedArguments[0].Argument + "'s information is not contained in the dictionary...", this.dicPlayerInfo[strSpeaker].TeamID, this.dicPlayerInfo[strSpeaker].SquadID); } } } }
public void OnCommandHelp(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { this.ExecuteCommand("procon.protected.send", "admin.say", String.Format("Type \"{0}help [command]\" for more information about a command:", capCommand.ResposeScope), "player", strSpeaker); foreach (string strCommandOutput in this.WordWrap(String.Join(", ", this.GetExcludedCommandStrings(strSpeaker).ToArray()), 100)) { this.ExecuteCommand("procon.protected.send", "admin.say", strCommandOutput, "player", strSpeaker); } }
/// <summary> /// Data that other side really sent. /// </summary> /// <param name="opCode">Op code.</param> /// <param name="data">Data.</param> private void OnReliableDataReceived(int opCode, RTData data) { MatchCommand command = _commandsParser.ParseCommand(opCode, data); // Debug.Log("Received command " + command.ToString()); if (OnCommandReceived != null) { OnCommandReceived(command); } }
public IActionResult Match([FromBody] MatchCommand command) { var commandResult = _mediator.Send(command); if (commandResult.IsFaulted) { return(BadRequest(commandResult.Exception.InnerException.Message)); } return(Ok(new { message = "Matched" })); }
public void OnCommandMyGUIDFull(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { if (base.PunkbusterPlayerInfoList.ContainsKey(strSpeaker) == true && base.PunkbusterPlayerInfoList[strSpeaker].GUID.Length == 32) { this.ExecuteCommand("procon.protected.send", "admin.say", "Your GUID " + base.PunkbusterPlayerInfoList[strSpeaker].GUID, "player", strSpeaker); } else { this.ExecuteCommand("procon.protected.send", "admin.say", "No pb info yet, try again =(", "player", strSpeaker); } }
public void SendDataReliable(MatchCommand command) { int opCode = _commandsParser.GetOpCode(command.GetType()); if (opCode == -1) { Debug.LogError("opcode not found for command " + command.ToString()); return; } // Debug.Log ("Sent command " + command.ToString()); SendDataReliable(opCode, command.Data); }
private static void OnCommandReceived(MatchCommand command) { if (!(command is CommandAllPlayersReady)) { return; } GameController.Instance.Lobby.OnAllPlayersReady(); if (!MatchController.Instance.IsPlaying) { MatchController.Instance.StartMatch(true); } }
public void OnCommandMyTimes(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { if (base.FrostbitePlayerInfoList.ContainsKey(strSpeaker) == true && base.FrostbitePlayerInfoList[strSpeaker].SessionTime != 0) { string strOutTime = this.SecondsToText((UInt32)base.FrostbitePlayerInfoList[strSpeaker].SessionTime, this.m_astrTimeDescription, true); this.ExecuteCommand("procon.protected.send", "admin.say", "Your current playTime: " + strOutTime, "player", strSpeaker); } else { this.ExecuteCommand("procon.protected.send", "admin.say", "Sorry, you've just joined =(", "player", strSpeaker); } }
public MatchCommand ParseCommand(int opCode, RTData data) { Func <RTData, MatchCommand> parser = null; if (!_parsers.TryGetValue(opCode, out parser)) { Debug.LogError("Unrecognised command received, opCode = " + opCode.ToString()); return(null); } MatchCommand command = parser(data); return(command); }
public void OnCommandPlayerAdmin(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { if (this.m_dicPbInfo.ContainsKey(capCommand.MatchedArguments[0].Argument) == true) { this.ExecuteCommand("procon.protected.send", "textChatModerationList.addPlayer", "admin", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName); this.ExecuteCommand("procon.protected.send", "admin.say", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName + " now has admin chat privileges.", "player", strSpeaker); this.ExecuteCommand("procon.protected.send", "admin.say", "You have been granted admin chat privleges", "player", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName); this.ExecuteCommand("procon.protected.send", "textChatModerationList.save"); } else { this.ExecuteCommand("procon.protected.send", "admin.say", "Player not found", "player", strSpeaker); } }
private static void OnCommandReceived(MatchCommand currCommand) { SyncResponseCommand sync = currCommand as SyncResponseCommand; if (sync == null) { return; } Synced = true; long currTime = GetTimeStamp(); long roundLag = currTime - sync.SendingTimestamp; Lag = roundLag / 2; }
public void OnCommandPlayerLocation(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { if (this.m_enAllowPlayersToGetOthersCountry == enumBoolYesNo.Yes) { if (base.PunkbusterPlayerInfoList.ContainsKey(capCommand.MatchedArguments[0].Argument) == true) { this.ExecuteCommand("procon.protected.send", "admin.say", base.PunkbusterPlayerInfoList[capCommand.MatchedArguments[0].Argument].SoldierName + "'s location: " + base.PunkbusterPlayerInfoList[capCommand.MatchedArguments[0].Argument].PlayerCountry, "player", strSpeaker); } else { this.ExecuteCommand("procon.protected.send", "admin.say", "Player not found", "player", strSpeaker); } } }
public void OnCommandPlayerGUID(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { if (this.m_enAllowPlayersToGuidOthers == enumBoolYesNo.Yes) { if (base.PunkbusterPlayerInfoList.ContainsKey(capCommand.MatchedArguments[0].Argument) == true && base.PunkbusterPlayerInfoList[capCommand.MatchedArguments[0].Argument].GUID.Length == 32) { this.ExecuteCommand("procon.protected.send", "admin.say", base.PunkbusterPlayerInfoList[capCommand.MatchedArguments[0].Argument].SoldierName + "'s P/GUID: " + base.PunkbusterPlayerInfoList[capCommand.MatchedArguments[0].Argument].GUID.Substring(24, 8), "player", strSpeaker); } else { this.ExecuteCommand("procon.protected.send", "admin.say", "Player not found", "player", strSpeaker); } } }
public void OnCommandPlayerTimes(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { if (this.m_enAllowPlayersToTimeOthers == enumBoolYesNo.Yes) { if (base.FrostbitePlayerInfoList.ContainsKey(capCommand.MatchedArguments[0].Argument) == true && base.FrostbitePlayerInfoList[capCommand.MatchedArguments[0].Argument].SessionTime != 0) { string strOutTime = this.SecondsToText((UInt32)base.FrostbitePlayerInfoList[capCommand.MatchedArguments[0].Argument].SessionTime, this.m_astrTimeDescription, true); this.ExecuteCommand("procon.protected.send", "admin.say", base.FrostbitePlayerInfoList[capCommand.MatchedArguments[0].Argument].SoldierName + "'s playTime: " + strOutTime, "player", strSpeaker); } else { this.ExecuteCommand("procon.protected.send", "admin.say", "Player not found / or just joined", "player", strSpeaker); } } }
public void OnCommandHelpSpecific(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { List <MatchCommand> lstCommands = this.GetRegisteredCommands(); CPrivileges privileges = this.GetAccountPrivileges(strSpeaker); foreach (MatchCommand mtcLoopedCommand in lstCommands) { if (String.Compare(mtcLoopedCommand.Command, capCommand.MatchedArguments[0].Argument, true) == 0 && mtcLoopedCommand.Requirements.HasValidPermissions(privileges) == true) { foreach (string strLine in this.WordWrap(String.Format("> {0}; {1}", mtcLoopedCommand.ToString(), mtcLoopedCommand.Description), 100)) { this.ExecuteCommand("procon.protected.send", "admin.say", strLine, "player", strSpeaker); } } } }
public void OnCommandSwapTeam(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { ExecuteCommand("procon.protected.events.write", "Plugins", "PluginAction", String.Format("Initiated a swap team"), strSpeaker); List <int> teamIds = FrostbitePlayerInfoList.Values.Select(_ => _.TeamID).Distinct().ToList(); Output.Information("TeamIds:" + string.Join(",", teamIds)); for (int i = 0; i < FrostbitePlayerInfoList.Count; i++) { var player = FrostbitePlayerInfoList.ElementAt(i).Value; var name = player.SoldierName; var dstTeamId = teamIds[((teamIds.IndexOf(player.TeamID) + 1) < teamIds.Count) ? (teamIds.IndexOf(player.TeamID) + 1) : 0]; var dstSquadId = player.SquadID; ExecuteCommand("procon.protected.tasks.add", ClassName + strSpeaker, 10.ToString(), "1", "1", "procon.protected.send", "admin.movePlayer", name, dstTeamId.ToString(), dstSquadId.ToString(), true.ToString()); Output.Information("{0} {1} {2} {3} {4}", "admin.movePlayer", name, dstTeamId.ToString(), dstSquadId.ToString(), true.ToString()); } }
public void OnCommandPlayerMute(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { if (this.m_dicPbInfo.ContainsKey(capCommand.MatchedArguments[0].Argument) == true) { int myInt; this.ExecuteCommand("procon.protected.send", "textChatModerationList.addPlayer", "muted", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName); if (capCommand.ExtraArguments.Length > 0) { try { myInt = Int32.Parse(capCommand.ExtraArguments); this.ExecuteCommand("procon.protected.send", "admin.say", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName + " now is muted for " + myInt.ToString() + " minutes", "player", strSpeaker); this.ExecuteCommand("procon.protected.send", "admin.say", "You have been muted for " + myInt.ToString() + " minutes", "player", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName); myInt = myInt * 60; this.ExecuteCommand("procon.protected.tasks.add", "CPlayerMuterUnMute", myInt.ToString(), "1", "1", "procon.protected.plugins.call", "CPlayerMuter", "RemoveMute", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName); } catch { this.ExecuteCommand("procon.protected.send", "admin.say", "Invalid mute time, player not muted", "player", strSpeaker); } } else { this.ExecuteCommand("procon.protected.send", "admin.say", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName + " has been muted.", "player", strSpeaker); this.ExecuteCommand("procon.protected.send", "admin.say", "You have been muted", "player", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName); if (this.m_removeMuteAfter.CompareTo("Time limit") == 0) { this.ExecuteCommand("procon.protected.tasks.add", "CPlayerMuterUnMute", this.m_strMuteTime.ToString(), "1", "1", "procon.protected.plugins.call", "CPlayerMuter", "RemoveMute", this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName); } else { this.m_dicPlayerMutes.Add(this.m_dicPbInfo[capCommand.MatchedArguments[0].Argument].SoldierName, this.m_removeMuteAfter); } } this.ExecuteCommand("procon.protected.send", "textChatModerationList.save"); } else { this.ExecuteCommand("procon.protected.send", "admin.say", "Player not found", "player", strSpeaker); } }
static void OnSyncReceived(MatchCommand currCommand) { CommandSyncData command = currCommand as CommandSyncData; if (command == null) { return; } /*StringBuilder sb = new StringBuilder ("sync received at "); * sb.Append (Timer.Time); * sb.Append (", lag = "); * sb.Append (command.Lag); * foreach (var change in command.Changes) { * sb.Append ("; (type="); * sb.Append (change.After.GetType ()); * sb.Append (", data="); * sb.Append (change.After.ToString ()); * sb.Append (")"); * } * Debug.Log (sb.ToString ());*/ //LogCharPos ("Before sync"); float commandDelay = (command.Lag + LagController.Lag) * 0.001f; TimeMachiene.GoToPast(commandDelay); //LogCharPos ("In past"); foreach (var change in command.Changes) { SaveBeforeState(change); } foreach (var change in command.Changes) { ApplyChange(change); } //LogCharPos ("after sync in past"); TimeMachiene.SaveReceivedCommands(command.Changes); TimeMachiene.GoForward(commandDelay); //LogCharPos ("after sync in curr time"); }
private void RegisterAllCommands() { if (!m_isPluginEnabled) { return; } List <string> emptyList = new List <string>(); List <string> scopes = Listify <string>(m_strPrivatePrefix, m_strAdminsPrefix, m_strPublicPrefix); MatchCommand confirmationCommand = new MatchCommand(scopes, m_strConfirmCommand, Listify <MatchArgumentFormat>()); RegisterCommand( new MatchCommand( ClassName, "OnCommandSwapTeam", scopes, m_strSwapCommand, new List <MatchArgumentFormat>(), new ExecutionRequirements(ExecutionScope.Privileges, Privileges.CanMovePlayers | Privileges.CanKillPlayers, 2, confirmationCommand, "You do not have enough privileges to swap team"), "Swap team" ) ); }
/// <summary> /// Fires whenever a command is unregisted from procon from any plugin. /// </summary> /// <param name="command"></param> public virtual void OnUnregisteredCommand(MatchCommand command) { }
/// <summary> /// Fires when any registered command has been matched against a players text in game. /// This method is called regardless of it being registered to your classname. /// Called *after* a confirmation. If this method is called you can assume the /// speaker has met the required privliege and has confirmed the command as correct. /// </summary> /// <param name="speaker">The player that issued the command</param> /// <param name="text">The text that was matched to the MatchCommand object</param> /// <param name="matchedCommand">The registered command object</param> /// <param name="capturedCommand">The captured command details</param> /// <param name="matchedScope">The scope the message was sent by the player (squad chat, team chat etc)</param> /// Note: This method was not included, instead you delegate a method when creating a MatchCommand object. public virtual void OnAnyMatchRegisteredCommand(string speaker, string text, MatchCommand matchedCommand, CapturedCommand capturedCommand, CPlayerSubset matchedScope) { }
public void OnCommandSetAdminMode(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { this.ExecuteCommand("procon.protected.send", "vars.textChatModerationMode", "muted"); this.ExecuteCommand("procon.protected.send", "admin.say", "Admin only chat mode has been activated", "all"); }
public void UnregisterCommand_Callback(MatchCommand mtcCommand) { this.m_delUnregisterCommand(mtcCommand); }
public void UnregisterCommand(MatchCommand mtcCommand) { lock (this.m_objMatchedInGameCommandsLocker) { if (this.MatchedInGameCommands.ContainsKey(mtcCommand.ToString()) == true) { this.MatchedInGameCommands.Remove(mtcCommand.ToString()); this.InvokeOnAllEnabled("OnUnregisteredCommand", mtcCommand); } } }
// TO DO: Move to seperate command control class with events captured by PluginManager. public void RegisterCommand(MatchCommand mtcCommand) { lock (this.m_objMatchedInGameCommandsLocker) { if (mtcCommand.RegisteredClassname.Length > 0 && mtcCommand.RegisteredMethodName.Length > 0 && mtcCommand.Command.Length > 0) { if (this.MatchedInGameCommands.ContainsKey(mtcCommand.ToString()) == true) { if (String.Compare(this.MatchedInGameCommands[mtcCommand.ToString()].RegisteredClassname, mtcCommand.RegisteredClassname) != 0) { this.WritePluginConsole("^1^bIdentical command registration on class {0} overwriting class {1} command {2}", mtcCommand.RegisteredClassname, this.MatchedInGameCommands[mtcCommand.ToString()].RegisteredClassname, this.MatchedInGameCommands[mtcCommand.ToString()].ToString()); } this.MatchedInGameCommands[mtcCommand.ToString()] = mtcCommand; } else { this.MatchedInGameCommands.Add(mtcCommand.ToString(), mtcCommand); this.InvokeOnAllEnabled("OnRegisteredCommand", mtcCommand); } } } }
private void DispatchMatchedCommand(string playerName, string message, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subset) { bool isConfirmationRequired = false; if (capCommand.IsConfirmed == false) { foreach (MatchArgument mtcArgument in capCommand.MatchedArguments) { if (mtcArgument.MatchScore > mtcCommand.Requirements.MinimumMatchSimilarity) { isConfirmationRequired = true; capCommand.IsConfirmed = false; break; } } } if (isConfirmationRequired == true && capCommand.IsConfirmed == false) { if (this.CommandsNeedingConfirmation.Contains(playerName) == true) { this.CommandsNeedingConfirmation.Remove(playerName); } this.CommandsNeedingConfirmation.Add(new ConfirmationEntry(playerName, message, mtcCommand, capCommand, subset)); this.m_client.Game.SendAdminSayPacket(String.Format("Did you mean {0}?", capCommand.ToString()), new CPlayerSubset(CPlayerSubset.PlayerSubsetType.Player, playerName)); } else { this.InvokeOnEnabled(mtcCommand.RegisteredClassname, mtcCommand.RegisteredMethodName, playerName, message, mtcCommand, capCommand, new CPlayerSubset(CPlayerSubset.PlayerSubsetType.All)); this.InvokeOnAllEnabled("OnAnyMatchRegisteredCommand", playerName, message, mtcCommand, capCommand, new CPlayerSubset(CPlayerSubset.PlayerSubsetType.All)); } }
/// <summary> /// This will check from the dictionary of registered commands to see if some text is matched /// against a registered command. The return is prioritized for whatever command matches more /// arguments. /// </summary> /// <param name="playerName">Who executed the command</param> /// <param name="message">The message they sent</param> private bool CheckInGameCommands(string playerName, string message, out MatchCommand mtcMatchedCommand, out CapturedCommand capReturnCommand) { bool isMatch = false; capReturnCommand = null; mtcMatchedCommand = null; lock (this.m_objMatchedInGameCommandsLocker) { CapturedCommand capMatched = null; // If this player has a command stored that requires confirmation. if (this.CommandsNeedingConfirmation.Contains(playerName) == true) { if ((capMatched = this.CommandsNeedingConfirmation[playerName].MatchedCommand.Requirements.ConfirmationCommand.Matches(message)) != null) { //capReturnCommand = capMatched; capReturnCommand = this.CommandsNeedingConfirmation[playerName].ConfirmationDetails; mtcMatchedCommand = this.CommandsNeedingConfirmation[playerName].MatchedCommand; capReturnCommand.IsConfirmed = true; isMatch = true; } } // If it was not a confirmation to a previously matched command. if (isMatch == false) { foreach (KeyValuePair<string, MatchCommand> kvpCommand in this.MatchedInGameCommands) { // Only care if the plugin is enabled. if (this.Plugins.IsEnabled(kvpCommand.Value.RegisteredClassname) == true) { capMatched = kvpCommand.Value.Matches(message); if (capMatched != null) { if (kvpCommand.Value.Requirements.HasValidPermissions(this.m_client.GetAccountPrivileges(playerName)) == true) { // if (this.ValidateRequirements(playerName, kvpCommand.Value.Requirements) == true) { // If it's the first match we've found if (capReturnCommand == null) { capReturnCommand = capMatched; mtcMatchedCommand = kvpCommand.Value; isMatch = true; } else if (capReturnCommand != null && capMatched.CompareTo(capReturnCommand) > 0) { // We've found a command with that is a closer match to its arguments capReturnCommand = capMatched; mtcMatchedCommand = kvpCommand.Value; isMatch = true; } /* // If we've found a better match than before (more arguments matched) else if (capReturnCommand != null && capMatched.MatchedArguments.Count > capReturnCommand.MatchedArguments.Count) { capReturnCommand = capMatched; mtcMatchedCommand = kvpCommand.Value; isMatch = true; } // If we've found another match, check if this one is "matchier" (has a lower score) else if (capReturnCommand != null && capMatched.MatchedArguments.Count == capReturnCommand.MatchedArguments.Count && capMatched.AggregateMatchScore < capReturnCommand.AggregateMatchScore) { // We've found a command with the same amount of matched data but the new command is closer to it's own dictionary. capReturnCommand = capMatched; mtcMatchedCommand = kvpCommand.Value; isMatch = true; }*/ } else { this.m_client.Game.SendAdminSayPacket(kvpCommand.Value.Requirements.FailedRequirementsMessage, new CPlayerSubset(CPlayerSubset.PlayerSubsetType.Player, playerName)); // this.m_prcClient.SendRequest(new List<string>() { "admin.say", kvpCommand.Value.Requirements.FailedRequirementsMessage, "player", playerName }); } } } } } } return isMatch; }
public void OnCommandVersion(string strSpeaker, string strText, MatchCommand mtcCommand, CapturedCommand capCommand, CPlayerSubset subMatchedScope) { this.ExecuteCommand("procon.protected.send", "admin.say", String.Format("IP: {0}, Location: {1}, Rcon: PRoCon {2}", this.m_strHostName, this.GetVariable <string>("SERVER_COUNTRY", ""), this.m_strPRoConVersion), "player", strSpeaker); }
/// <summary> /// Fires when any registered command has been matched against a players text in game. /// This method is called regardless of it being registered to your classname. /// Called *after* a confirmation. If this method is called you can assume the /// speaker has met the required privliege and has confirmed the command as correct. /// </summary> /// <param name="speaker">The player that issued the command</param> /// <param name="strText">The text that was matched to the MatchCommand object</param> /// <param name="mtcCommand">The registered command object</param> /// <param name="capCommand">The captured command details</param> /// <param name="subMatchedScope">The scope the message was sent by the player (squad chat, team chat etc)</param> /// Note: This method was not included, instead you delegate a method when creating a MatchCommand object. public virtual void OnAnyMatchRegisteredCommand(string speaker, string text, MatchCommand matchedCommand, CapturedCommand capturedCommand, CPlayerSubset matchedScope) { }
/// <summary> /// Fires whenever a command is unregisted from procon from any plugin. /// </summary> /// <param name="mtcCommand"></param> public virtual void OnUnregisteredCommand(MatchCommand command) { }