diff --git a/SCPDiscordPlugin/AsyncTask.cs b/SCPDiscordPlugin/AsyncTask.cs index a2b54cef..39c9ea30 100644 --- a/SCPDiscordPlugin/AsyncTask.cs +++ b/SCPDiscordPlugin/AsyncTask.cs @@ -51,7 +51,9 @@ public SendDiscordMessage(SCPDiscordPlugin plugin, string channelID, string mess channelID = "000000000000000000"; } - if(variables != null) + message = message.Replace("\\n", "\n"); + + if (variables != null) { // Variable insertion foreach (KeyValuePair variable in variables) diff --git a/SCPDiscordPlugin/EventListeners/PlayerEventListener.cs b/SCPDiscordPlugin/EventListeners/PlayerEventListener.cs index b7be72bf..d9d7a55a 100644 --- a/SCPDiscordPlugin/EventListeners/PlayerEventListener.cs +++ b/SCPDiscordPlugin/EventListeners/PlayerEventListener.cs @@ -9,7 +9,8 @@ namespace SCPDiscord class PlayerEventListener : IEventHandlerPlayerJoin, IEventHandlerPlayerDie, IEventHandlerSpawn, IEventHandlerPlayerHurt, IEventHandlerPlayerPickupItem, IEventHandlerPlayerDropItem, IEventHandlerNicknameSet, IEventHandlerInitialAssignTeam, IEventHandlerSetRole, IEventHandlerCheckEscape, IEventHandlerDoorAccess, IEventHandlerIntercom, IEventHandlerIntercomCooldownCheck, IEventHandlerPocketDimensionExit, IEventHandlerPocketDimensionEnter, IEventHandlerPocketDimensionDie, - IEventHandlerThrowGrenade, IEventHandlerInfected, IEventHandlerSpawnRagdoll, IEventHandlerLure, IEventHandlerContain106 + IEventHandlerThrowGrenade, IEventHandlerInfected, IEventHandlerSpawnRagdoll, IEventHandlerLure, IEventHandlerContain106, IEventHandlerMedkitUse, IEventHandlerShoot, + IEventHandler106CreatePortal, IEventHandler106Teleport, IEventHandlerElevatorUse { private SCPDiscordPlugin plugin; // First dimension is target player second dimension is attacking player @@ -26,6 +27,18 @@ public PlayerEventListener(SCPDiscordPlugin plugin) this.plugin = plugin; } + private bool IsTeamDamage(int attackerTeam, int targetTeam) + { + foreach (KeyValuePair team in teamKillingMatrix) + { + if (attackerTeam == team.Value && targetTeam == team.Key) + { + return true; + } + } + return false; + } + public void OnPlayerHurt(PlayerHurtEvent ev) { /// @@ -39,27 +52,6 @@ public void OnPlayerHurt(PlayerHurtEvent ev) return; } - if (plugin.GetConfigBool("discord_verbose")) - { - plugin.Info("Damage: " + ev.Damage ); - plugin.Info("DamageType: " + ev.DamageType ); - plugin.Info("Attacker: " + ev.Attacker ); - plugin.Info("Attacker IP: " + ev.Attacker.IpAddress ); - plugin.Info("Attacker Name: " + ev.Attacker.Name ); - plugin.Info("Attacker PlayerID: " + ev.Attacker.PlayerId ); - plugin.Info("Attacker SteamID: " + ev.Attacker.SteamId ); - plugin.Info("Attacker TeamRole: " + ev.Attacker.TeamRole ); - plugin.Info("Attacker Role: " + ev.Attacker.TeamRole.Role ); - plugin.Info("Attacker Team: " + ev.Attacker.TeamRole.Team ); - plugin.Info("Player: " + ev.Player ); - plugin.Info("Player IP: " + ev.Player.IpAddress ); - plugin.Info("Player Name: " + ev.Player.Name ); - plugin.Info("Player PlayerID: " + ev.Player.PlayerId ); - plugin.Info("Player SteamID: " + ev.Player.SteamId ); - plugin.Info("Player Role: " + ev.Player.TeamRole.Role ); - plugin.Info("Player Team: " + ev.Player.TeamRole.Team ); - } - if (ev.Attacker == null) { Dictionary noAttackerVar = new Dictionary @@ -95,16 +87,10 @@ public void OnPlayerHurt(PlayerHurtEvent ev) { "playerteam", ev.Player.TeamRole.Team.ToString() } }; - if (ev.Player.SteamId != ev.Attacker.SteamId) + if (ev.Player.SteamId != ev.Attacker.SteamId && IsTeamDamage((int)ev.Attacker.TeamRole.Team, (int)ev.Player.TeamRole.Team)) { - foreach (KeyValuePair team in teamKillingMatrix) - { - if ((int)ev.Attacker.TeamRole.Team == team.Value && (int)ev.Player.TeamRole.Team == team.Key) - { - plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onplayerhurt"), "player.onplayerhurt.friendlyfire", variables); - return; - } - } + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onplayerhurt"), "player.onplayerhurt.friendlyfire", variables); + return; } plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onplayerhurt"), "player.onplayerhurt", variables); @@ -122,25 +108,6 @@ public void OnPlayerDie(PlayerDeathEvent ev) return; } - if (plugin.GetConfigBool("discord_verbose")) - { - plugin.Info("Attacker: " + ev.Killer ); - plugin.Info("Attacker IP: " + ev.Killer.IpAddress ); - plugin.Info("Attacker Name: " + ev.Killer.Name ); - plugin.Info("Attacker PlayerID: " + ev.Killer.PlayerId ); - plugin.Info("Attacker SteamID: " + ev.Killer.SteamId ); - plugin.Info("Attacker TeamRole: " + ev.Killer.TeamRole ); - plugin.Info("Attacker Role: " + ev.Killer.TeamRole.Role ); - plugin.Info("Attacker Team: " + ev.Killer.TeamRole.Team ); - plugin.Info("Player: " + ev.Player ); - plugin.Info("Player IP: " + ev.Player.IpAddress ); - plugin.Info("Player Name: " + ev.Player.Name ); - plugin.Info("Player PlayerID: " + ev.Player.PlayerId ); - plugin.Info("Player SteamID: " + ev.Player.SteamId ); - plugin.Info("Player Role: " + ev.Player.TeamRole.Role ); - plugin.Info("Player Team: " + ev.Player.TeamRole.Team ); - } - if (ev.Killer == null) { Dictionary noKillerVar = new Dictionary @@ -174,16 +141,10 @@ public void OnPlayerDie(PlayerDeathEvent ev) { "playerteam", ev.Player.TeamRole.Team.ToString() } }; - if (ev.Player.SteamId != ev.Killer.SteamId) + if (ev.Player.SteamId != ev.Killer.SteamId && IsTeamDamage((int)ev.Killer.TeamRole.Team, (int)ev.Player.TeamRole.Team)) { - foreach (KeyValuePair team in teamKillingMatrix) - { - if ((int)ev.Killer.TeamRole.Team == team.Value && (int)ev.Player.TeamRole.Team == team.Key) - { - plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onplayerdie"), "player.onplayerdie.friendlyfire", variables); - return; - } - } + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onplayerdie"), "player.onplayerdie.friendlyfire", variables); + return; } plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onplayerdie"), "player.onplayerdie", variables); } @@ -345,6 +306,8 @@ public void OnDoorAccess(PlayerDoorAccessEvent ev) /// Dictionary variables = new Dictionary { + { "doorname", ev.Door.Name }, + { "permission", ev.Door.Permission }, { "locked", ev.Door.Locked.ToString() }, { "lockcooldown", ev.Door.LockCooldown.ToString() }, { "open", ev.Door.Open.ToString() }, @@ -355,7 +318,6 @@ public void OnDoorAccess(PlayerDoorAccessEvent ev) { "class", ev.Player.TeamRole.Role.ToString() }, { "team", ev.Player.TeamRole.Team.ToString() } }; - if (ev.Allow) { plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_ondooraccess"), "player.ondooraccess", variables); @@ -553,5 +515,128 @@ public void OnContain106(PlayerContain106Event ev) }; plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_oncontain106"), "player.oncontain106", variables); } + + public void OnMedkitUse(PlayerMedkitUseEvent ev) + { + /// + /// Called when a player uses Medkit + /// + + Dictionary variables = new Dictionary + { + { "recoveredhealth", ev.RecoverHealth.ToString() }, + { "ipaddress", ev.Player.IpAddress }, + { "name", ev.Player.Name }, + { "playerid", ev.Player.PlayerId.ToString() }, + { "steamid", ev.Player.SteamId }, + { "class", ev.Player.TeamRole.Role.ToString() }, + { "team", ev.Player.TeamRole.Team.ToString() } + }; + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onmedkituse"), "player.onmedkituse", variables); + } + + public void OnShoot(PlayerShootEvent ev) + { + /// + /// Called when a player shoots + /// + + if (ev.Player == null) + { + return; + } + + if(ev.Target == null) + { + Dictionary noTargetVars = new Dictionary + { + { "weapon", ev.Weapon.ToString() }, + { "attackeripaddress", ev.Player.IpAddress }, + { "attackername", ev.Player.Name }, + { "attackerplayerid", ev.Player.PlayerId.ToString() }, + { "attackersteamid", ev.Player.SteamId }, + { "attackerclass", ev.Player.TeamRole.Role.ToString() }, + { "attackerteam", ev.Player.TeamRole.Team.ToString() } + }; + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onshoot"), "player.onshoot.notarget", noTargetVars); + return; + } + + Dictionary variables = new Dictionary + { + { "weapon", ev.Weapon.ToString() }, + { "attackeripaddress", ev.Player.IpAddress }, + { "attackername", ev.Player.Name }, + { "attackerplayerid", ev.Player.PlayerId.ToString() }, + { "attackersteamid", ev.Player.SteamId }, + { "attackerclass", ev.Player.TeamRole.Role.ToString() }, + { "attackerteam", ev.Player.TeamRole.Team.ToString() }, + { "playeripaddress", ev.Target.IpAddress }, + { "playername", ev.Target.Name }, + { "playerplayerid", ev.Target.PlayerId.ToString() }, + { "playersteamid", ev.Target.SteamId }, + { "playerclass", ev.Target.TeamRole.Role.ToString() }, + { "playerteam", ev.Target.TeamRole.Team.ToString() } + }; + + if (ev.Player.SteamId != ev.Player.SteamId && IsTeamDamage((int)ev.Player.TeamRole.Team, (int)ev.Player.TeamRole.Team)) + { + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onshoot"), "player.onshoot.friendlyfire", variables); + } + + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onshoot"), "player.onshoot", variables); + } + + public void On106CreatePortal(Player106CreatePortalEvent ev) + { + /// + /// Called when SCP-106 creates a portal + /// + Dictionary variables = new Dictionary + { + { "ipaddress", ev.Player.IpAddress }, + { "name", ev.Player.Name }, + { "playerid", ev.Player.PlayerId.ToString() }, + { "steamid", ev.Player.SteamId }, + { "class", ev.Player.TeamRole.Role.ToString() }, + { "team", ev.Player.TeamRole.Team.ToString() } + }; + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_on106createportal"), "player.on106createportal", variables); + } + + public void On106Teleport(Player106TeleportEvent ev) + { + /// + /// Called when SCP-106 teleports through portals + /// + + Dictionary variables = new Dictionary + { + { "ipaddress", ev.Player.IpAddress }, + { "name", ev.Player.Name }, + { "playerid", ev.Player.PlayerId.ToString() }, + { "steamid", ev.Player.SteamId }, + { "class", ev.Player.TeamRole.Role.ToString() }, + { "team", ev.Player.TeamRole.Team.ToString() } + }; + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_on106teleport"), "player.on106teleport", variables); + } + + public void OnElevatorUse(PlayerElevatorUseEvent ev) + { + /// + /// Called when a player uses an elevator + /// + Dictionary variables = new Dictionary + { + { "ipaddress", ev.Player.IpAddress }, + { "name", ev.Player.Name }, + { "playerid", ev.Player.PlayerId.ToString() }, + { "steamid", ev.Player.SteamId }, + { "class", ev.Player.TeamRole.Role.ToString() }, + { "team", ev.Player.TeamRole.Team.ToString() } + }; + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onelevatoruse"), "player.onelevatoruse", variables); + } } } diff --git a/SCPDiscordPlugin/EventListeners/RoundEventListener.cs b/SCPDiscordPlugin/EventListeners/RoundEventListener.cs index cb0b625f..9a38bd8e 100644 --- a/SCPDiscordPlugin/EventListeners/RoundEventListener.cs +++ b/SCPDiscordPlugin/EventListeners/RoundEventListener.cs @@ -6,7 +6,8 @@ namespace SCPDiscord { - class RoundEventListener : IEventHandlerRoundStart, IEventHandlerRoundEnd, IEventHandlerConnect, IEventHandlerDisconnect, IEventHandlerWaitingForPlayers, IEventHandlerCheckRoundEnd, IEventHandlerRoundRestart, IEventHandlerSetServerName + class RoundEventListener : IEventHandlerRoundStart, IEventHandlerRoundEnd, IEventHandlerConnect, IEventHandlerDisconnect, IEventHandlerWaitingForPlayers, + IEventHandlerCheckRoundEnd, IEventHandlerRoundRestart, IEventHandlerSetServerName, IEventHandlerSceneChanged { private SCPDiscordPlugin plugin; bool roundHasStarted = false; @@ -118,6 +119,13 @@ public void OnSetServerName(SetServerNameEvent ev) plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onsetservername"), "round.onsetservername", variables); } - + public void OnSceneChanged(SceneChangedEvent ev) + { + Dictionary variables = new Dictionary + { + { "scenename", ev.SceneName } + }; + plugin.SendDiscordMessage(plugin.GetConfigString("discord_channel_onscenechanged"), "round.onscenechanged", variables); + } } } diff --git a/SCPDiscordPlugin/Languages/english.yml b/SCPDiscordPlugin/Languages/english.yml index bf31bc03..42b8aeaf 100644 --- a/SCPDiscordPlugin/Languages/english.yml +++ b/SCPDiscordPlugin/Languages/english.yml @@ -63,7 +63,7 @@ global_regex: [ ] # Executes on the final version of the message, this is the only regex that affects player names -final_regex: ["(?i)nigger":"Edgy boi"] +final_regex: ["''":""] round: onroundstart: @@ -98,15 +98,15 @@ round: # warheaddetonated # zombies message: >+ - **Round ended after minutes.**\n + **Round ended after minutes.** ``` - Escaped D-class: / \n - Rescued Scientists: / \n - Contained SCPs: / \n - Killed by SCP: \n - Warhead switchwas detonated.\n - ```" - regex: ["switchwasTrue":"was","switchwasFalse":"wasn't"] + Escaped D-class: /\n + Rescued Scientists: /\n + Contained SCPs: /\n + Killed by SCP: \n + Warhead switchwas detonated. + ``` + regex: ["switchwasTrue":"was","switchwasFalse":"was not"] onwaitingforplayers: message: "**Server is ready and waiting for players.**" regex: [] @@ -117,6 +117,10 @@ round: # servername message: "**Server name: .**" regex: [] + onscenechanged: + # scenename + message: "**Scene loaded: .**" + regex: [] environment: onscp914activate: @@ -281,6 +285,8 @@ player: message: " () spawned as ." regex: [] ondooraccess: + # doorname + # permission # locked # lockcooldown # open @@ -290,14 +296,13 @@ player: # steamid # class # team - message: " () opened a door." - regex: [] + message: " () isopen: a door () requiring the permission ." + regex: ["isopen:True":"closed", "isopen:False":"opened", " requiring the permission .":""] notallowed: - message: " () tried to isopen: a locked door." - regex: ["isopen:True":"close", "isopen:False":"open"] + message: " () tried to isopen: a locked door () requiring the permission ." + regex: ["isopen:True":"close", "isopen:False":"open"," requiring the permission .":"."] onintercom: # This is not recommended to use outside of debugging - # allowspeech # cooldowntime # speechtime # ipaddress @@ -403,6 +408,65 @@ player: # team message: " () has initiated SCP-106 recall protocol." regex: [] + onmedkituse: + # recoveredamount + # ipaddress + # name + # playerid + # steamid + # class + # team + message: " () used a medkit and healed ." + regex: [] + onshoot: + # weapon + # attackeripaddress + # attackername + # attackerplayerid + # attackersteamid + # attackerclass + # attackerteam + # playeripaddress + # playername + # playerplayerid + # playersteamid + # playerclass + # playerteam + message: " () shot () with ." + regex: [] + notarget: + message: " () shot at nothing in particular with ." + regex: [] + friendlyfire: + message: "** () shot ally () using .**" + regex: [] + on106createportal: + # ipaddress + # name + # playerid + # steamid + # class + # team + message: " () has opened a dimensional portal." + regex: [] + on106teleport: + # ipaddress + # name + # playerid + # steamid + # class + # team + message: " () travelled through their pocket dimension." + regex: [] + onelevatoruse: + # ipaddress + # name + # playerid + # steamid + # class + # team + message: " () used an elevator." + regex: [] admin: onadminquery: diff --git a/SCPDiscordPlugin/SCPDiscord.cs b/SCPDiscordPlugin/SCPDiscord.cs index 6d2057a4..46cef6e9 100644 --- a/SCPDiscordPlugin/SCPDiscord.cs +++ b/SCPDiscordPlugin/SCPDiscord.cs @@ -53,6 +53,7 @@ public override void Register() this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onwaitingforplayers", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onroundrestart", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onsetservername", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); + this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onscenechanged", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); //Environment events this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onscp914activate", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); @@ -83,7 +84,12 @@ public override void Register() this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onspawnragdoll", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onlure", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_oncontain106", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); - + this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onmedkituse", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); + this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onshoot", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); + this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_on106createportal", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); + this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_on106teleport", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); + this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onelevatoruse", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); + //Admin events this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onadminquery", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); this.AddConfig(new Smod2.Config.ConfigSetting("discord_channel_onauthcheck", "off", Smod2.Config.SettingType.STRING, true, "Discord channel to post event messages in.")); diff --git a/SCPDiscordPlugin/lib/Smod2/Assembly-CSharp.dll b/SCPDiscordPlugin/lib/Smod2/Assembly-CSharp.dll index 0c99e7aa..3e2dd80a 100644 Binary files a/SCPDiscordPlugin/lib/Smod2/Assembly-CSharp.dll and b/SCPDiscordPlugin/lib/Smod2/Assembly-CSharp.dll differ