├── ScpProximityChat
├── packages.config
├── PluginConfig.cs
├── Patches
│ ├── NoClipTogglePatch.cs
│ └── VoiceChatPatch.cs
├── Properties
│ └── AssemblyInfo.cs
├── ScpProximityChatModule.cs
├── Features
│ └── ScpProximityChatHandler.cs
└── ScpProximityChat.csproj
├── ScpProximityChatExiled
├── packages.config
├── ScpProximityChatModule.cs
├── PluginConfig.cs
├── Properties
│ └── AssemblyInfo.cs
├── Features
│ └── ScpProximityChatHandler.cs
└── ScpProximityChatExiled.csproj
├── .github
└── README.md
├── ScpChatExtension.sln
└── .gitignore
/ScpProximityChat/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ScpProximityChatExiled/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.github/README.md:
--------------------------------------------------------------------------------
1 |
ScpProximityChat
2 | Also known as ScpChatExtension, works for both Exiled and NWAPI
3 |
4 |
5 |
6 | []()
7 | []()
8 | [](https://github.com/Jesus-QC/CursedMod/issues)
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
How to use?
18 | To switch between chats you gotta use the left ALT key, the NOCLIP one.
19 |
20 |
--------------------------------------------------------------------------------
/ScpProximityChatExiled/ScpProximityChatModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Exiled.API.Features;
3 | using ScpProximityChatExiled.Features;
4 |
5 | namespace ScpProximityChatExiled;
6 |
7 | public class ScpProximityChatModule : Plugin
8 | {
9 | public const string PluginVersion = "2.0.0.0";
10 |
11 | public override string Author { get; } = "Jesus-QC";
12 | public override string Name { get; } = "ScpProximityChat";
13 | public override string Prefix { get; } = "ScpProximityChat";
14 | public override Version Version { get; } = new (PluginVersion);
15 | public override Version RequiredExiledVersion { get; } = new (8, 7, 0);
16 | public override bool IgnoreRequiredVersionCheck { get; } = true;
17 |
18 | public static PluginConfig PluginConfig;
19 |
20 | public override void OnEnabled()
21 | {
22 | PluginConfig = Config;
23 | ScpProximityChatHandler.RegisterEvents();
24 | base.OnEnabled();
25 | }
26 |
27 | public override void OnDisabled()
28 | {
29 | ScpProximityChatHandler.UnregisterEvents();
30 | base.OnDisabled();
31 | }
32 | }
--------------------------------------------------------------------------------
/ScpProximityChat/PluginConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using PlayerRoles;
3 |
4 | namespace ScpProximityChat;
5 |
6 | public class PluginConfig
7 | {
8 | public bool IsEnabled { get; set; } = true;
9 |
10 | public bool ToggleChat { get; set; } = true;
11 |
12 | public string ProximityChatEnabledMessage { get; set; } = "proximity chat enabled";
13 | public string ProximityChatDisabledMessage { get; set; } = "proximity chat disabled";
14 |
15 | public float MaxProximityDistance { get; set; } = 7f;
16 |
17 | public HashSet AllowedRoles { get; set; } =
18 | [
19 | RoleTypeId.Scp049,
20 | RoleTypeId.Scp096,
21 | RoleTypeId.Scp106,
22 | RoleTypeId.Scp173,
23 | RoleTypeId.Scp0492,
24 | RoleTypeId.Scp939
25 | ];
26 |
27 | public bool SendBroadcastOnRoleChange { get; set; } = false;
28 | public ushort BroadcastDuration { get; set; } = 5;
29 | public string BroadcastMessage { get; set; } = "Proximity Chat can be toggled with the [ALT] key.";
30 | }
--------------------------------------------------------------------------------
/ScpProximityChatExiled/PluginConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Exiled.API.Interfaces;
3 | using PlayerRoles;
4 |
5 | namespace ScpProximityChatExiled;
6 |
7 | public class PluginConfig : IConfig
8 | {
9 | public bool IsEnabled { get; set; } = true;
10 |
11 | public bool Debug { get; set; } = false;
12 |
13 | public bool ToggleChat { get; set; } = true;
14 |
15 | public string ProximityChatEnabledMessage { get; set; } = "proximity chat enabled";
16 | public string ProximityChatDisabledMessage { get; set; } = "proximity chat disabled";
17 |
18 | public float MaxProximityDistance { get; set; } = 7f;
19 |
20 | public HashSet AllowedRoles { get; set; } =
21 | [
22 | RoleTypeId.Scp049,
23 | RoleTypeId.Scp096,
24 | RoleTypeId.Scp106,
25 | RoleTypeId.Scp173,
26 | RoleTypeId.Scp0492,
27 | RoleTypeId.Scp939
28 | ];
29 |
30 | public bool SendBroadcastOnRoleChange { get; set; } = false;
31 | public ushort BroadcastDuration { get; set; } = 5;
32 | public string BroadcastMessage { get; set; } = "Proximity Chat can be toggled with the [ALT] key.";
33 | }
--------------------------------------------------------------------------------
/ScpChatExtension.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScpProximityChat", "ScpProximityChat\ScpProximityChat.csproj", "{444B9DD9-EF85-4EFA-8A0A-BA70ECE95E07}"
4 | EndProject
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScpProximityChatExiled", "ScpProximityChatExiled\ScpProximityChatExiled.csproj", "{731158F7-C918-4290-ADFB-44C27452EF58}"
6 | EndProject
7 | Global
8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
9 | Debug|Any CPU = Debug|Any CPU
10 | Release|Any CPU = Release|Any CPU
11 | EndGlobalSection
12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
13 | {444B9DD9-EF85-4EFA-8A0A-BA70ECE95E07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14 | {444B9DD9-EF85-4EFA-8A0A-BA70ECE95E07}.Debug|Any CPU.Build.0 = Debug|Any CPU
15 | {444B9DD9-EF85-4EFA-8A0A-BA70ECE95E07}.Release|Any CPU.ActiveCfg = Release|Any CPU
16 | {444B9DD9-EF85-4EFA-8A0A-BA70ECE95E07}.Release|Any CPU.Build.0 = Release|Any CPU
17 | {731158F7-C918-4290-ADFB-44C27452EF58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18 | {731158F7-C918-4290-ADFB-44C27452EF58}.Debug|Any CPU.Build.0 = Debug|Any CPU
19 | {731158F7-C918-4290-ADFB-44C27452EF58}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 | {731158F7-C918-4290-ADFB-44C27452EF58}.Release|Any CPU.Build.0 = Release|Any CPU
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/ScpProximityChat/Patches/NoClipTogglePatch.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Reflection.Emit;
3 | using HarmonyLib;
4 | using NorthwoodLib.Pools;
5 | using PlayerRoles.FirstPersonControl.NetworkMessages;
6 | using ScpProximityChat.Features;
7 |
8 | namespace ScpProximityChat.Patches;
9 |
10 | [HarmonyPatch(typeof(FpcNoclipToggleMessage), nameof(FpcNoclipToggleMessage.ProcessMessage))]
11 | public class NoClipTogglePatch
12 | {
13 | private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
14 | {
15 | List newInstructions = ListPool.Shared.Rent(instructions);
16 |
17 | Label ret = generator.DefineLabel();
18 |
19 | newInstructions[newInstructions.Count - 1].labels.Add(ret);
20 |
21 | int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Ret) + 1;
22 |
23 | newInstructions.InsertRange(index, new CodeInstruction[]
24 | {
25 | new CodeInstruction(OpCodes.Ldloc_0).MoveLabelsFrom(newInstructions[index]),
26 | new (OpCodes.Call, AccessTools.Method(typeof(ScpProximityChatHandler), nameof(ScpProximityChatHandler.OnPlayerTogglingNoClip))),
27 | new (OpCodes.Brfalse, ret),
28 | });
29 |
30 | foreach (CodeInstruction instruction in newInstructions)
31 | yield return instruction;
32 |
33 | ListPool.Shared.Return(newInstructions);
34 | }
35 | }
--------------------------------------------------------------------------------
/ScpProximityChat/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using ScpProximityChat;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ScpProximityChat")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ScpProximityChat")]
13 | [assembly: AssemblyCopyright("Copyright © 2024")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("444B9DD9-EF85-4EFA-8A0A-BA70ECE95E07")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion(ScpProximityChatModule.Version)]
36 | [assembly: AssemblyFileVersion(ScpProximityChatModule.Version)]
--------------------------------------------------------------------------------
/ScpProximityChatExiled/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using ScpProximityChatExiled;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ScpProximityChatExiled")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ScpProximityChatExiled")]
13 | [assembly: AssemblyCopyright("Copyright © 2024")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("731158F7-C918-4290-ADFB-44C27452EF58")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion(ScpProximityChatModule.PluginVersion)]
36 | [assembly: AssemblyFileVersion(ScpProximityChatModule.PluginVersion)]
--------------------------------------------------------------------------------
/ScpProximityChat/ScpProximityChatModule.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 | using PlayerRoles;
3 | using PluginAPI.Core;
4 | using PluginAPI.Core.Attributes;
5 | using PluginAPI.Enums;
6 | using PluginAPI.Events;
7 | using ScpProximityChat.Features;
8 | using PluginConfig = ScpProximityChat.PluginConfig;
9 |
10 | namespace ScpProximityChat;
11 |
12 | public class ScpProximityChatModule
13 | {
14 | public const string Version = "2.0.0.0";
15 |
16 | private static readonly Harmony HarmonyPatcher = new("scpproximitymodule.jesusqc.com");
17 |
18 | [PluginAPI.Core.Attributes.PluginConfig] public static PluginConfig Config;
19 |
20 | [PluginEntryPoint("ScpProximityChat", Version, "Makes SCPs able to talk inside the proximity chat.", "Jesus-QC")]
21 | private void Init()
22 | {
23 | if (!Config.IsEnabled)
24 | return;
25 |
26 | Log.Raw($"Loading ScpChatExtension {Version} by Jesus-QC");
27 |
28 | HarmonyPatcher.PatchAll();
29 |
30 | EventManager.RegisterEvents(this);
31 | }
32 |
33 | [PluginEvent(ServerEventType.RoundRestart)]
34 | public void OnRoundRestarted()
35 | {
36 | ScpProximityChatHandler.ToggledPlayers.Clear();
37 | }
38 |
39 | [PluginEvent(ServerEventType.PlayerChangeRole)]
40 | public void OnPlayerChangingRole(Player plr, PlayerRoleBase oldRole, RoleTypeId newRole, RoleChangeReason reason)
41 | {
42 | if (!Config.SendBroadcastOnRoleChange)
43 | return;
44 |
45 | if (!Config.AllowedRoles.Contains(newRole))
46 | return;
47 |
48 | plr.SendBroadcast(Config.BroadcastMessage, Config.BroadcastDuration);
49 | }
50 | }
--------------------------------------------------------------------------------
/ScpProximityChat/Patches/VoiceChatPatch.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Reflection;
3 | using System.Reflection.Emit;
4 | using HarmonyLib;
5 | using Mirror;
6 | using NorthwoodLib.Pools;
7 | using ScpProximityChat.Features;
8 | using VoiceChat.Networking;
9 |
10 | namespace ScpProximityChat.Patches;
11 |
12 | [HarmonyPatch(typeof(VoiceTransceiver), nameof(VoiceTransceiver.ServerReceiveMessage))]
13 | public class VoiceChatPatch
14 | {
15 | private static MethodInfo GetSendMethod()
16 | {
17 | foreach (MethodInfo method in typeof(NetworkConnection).GetMethods())
18 | {
19 | if (method.Name is nameof(NetworkConnection.Send) && method.GetGenericArguments().Length != 0)
20 | return method.MakeGenericMethod(typeof(VoiceMessage));
21 | }
22 |
23 | return null;
24 | }
25 |
26 | private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
27 | {
28 | List newInstructions = ListPool.Shared.Rent(instructions);
29 |
30 | Label ret = generator.DefineLabel();
31 |
32 | newInstructions[newInstructions.Count - 1].labels.Add(ret);
33 |
34 | int index = newInstructions.FindLastIndex(x => x.opcode == OpCodes.Ldloc_0);
35 |
36 | newInstructions.InsertRange(index, new[]
37 | {
38 | new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
39 | new (OpCodes.Ldarg_1),
40 | new (OpCodes.Call, AccessTools.Method(typeof(ScpProximityChatHandler), nameof(ScpProximityChatHandler.OnPlayerUsingVoiceChat))),
41 | new (OpCodes.Brfalse_S, ret),
42 | });
43 |
44 | foreach (CodeInstruction instruction in newInstructions)
45 | yield return instruction;
46 |
47 | ListPool.Shared.Return(newInstructions);
48 | }
49 | }
--------------------------------------------------------------------------------
/ScpProximityChat/Features/ScpProximityChatHandler.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Hints;
3 | using Mirror;
4 | using PlayerRoles.FirstPersonControl;
5 | using PlayerRoles.Spectating;
6 | using PlayerRoles.Voice;
7 | using UnityEngine;
8 | using VoiceChat;
9 | using VoiceChat.Networking;
10 |
11 | namespace ScpProximityChat.Features;
12 |
13 | public static class ScpProximityChatHandler
14 | {
15 | public static readonly HashSet ToggledPlayers = [];
16 |
17 | public static bool OnPlayerTogglingNoClip(ReferenceHub player)
18 | {
19 | if (FpcNoclip.IsPermitted(player))
20 | return true;
21 |
22 | if (!ScpProximityChatModule.Config.AllowedRoles.Contains(player.roleManager.CurrentRole.RoleTypeId))
23 | return true;
24 |
25 | if (!ToggledPlayers.Add(player))
26 | {
27 | ToggledPlayers.Remove(player);
28 | player.hints.Show(new TextHint(ScpProximityChatModule.Config.ProximityChatDisabledMessage, [new StringHintParameter(string.Empty)], null ,4));
29 | return false;
30 | }
31 |
32 | player.hints.Show(new TextHint(ScpProximityChatModule.Config.ProximityChatEnabledMessage, [new StringHintParameter(string.Empty)], null ,4));
33 | return false;
34 | }
35 |
36 | public static bool OnPlayerUsingVoiceChat(NetworkConnection connection, VoiceMessage message)
37 | {
38 | if (message.Channel != VoiceChatChannel.ScpChat)
39 | return true;
40 |
41 | if (!ReferenceHub.TryGetHubNetID(connection.identity.netId, out ReferenceHub player))
42 | return true;
43 |
44 | if (!ScpProximityChatModule.Config.AllowedRoles.Contains(player.roleManager.CurrentRole.RoleTypeId) || (ScpProximityChatModule.Config.ToggleChat && !ToggledPlayers.Contains(player)))
45 | return true;
46 |
47 | SendProximityMessage(message);
48 | return !ScpProximityChatModule.Config.ToggleChat;
49 | }
50 |
51 | private static void SendProximityMessage(VoiceMessage msg)
52 | {
53 | foreach (ReferenceHub referenceHub in ReferenceHub.AllHubs)
54 | {
55 | if (referenceHub.roleManager.CurrentRole is SpectatorRole && !msg.Speaker.IsSpectatedBy(referenceHub))
56 | continue;
57 |
58 | if (referenceHub.roleManager.CurrentRole is not IVoiceRole voiceRole2)
59 | continue;
60 |
61 | if (Vector3.Distance(msg.Speaker.transform.position, referenceHub.transform.position) >= ScpProximityChatModule.Config.MaxProximityDistance)
62 | continue;
63 |
64 | if (voiceRole2.VoiceModule.ValidateReceive(msg.Speaker, VoiceChatChannel.Proximity) is VoiceChatChannel.None)
65 | continue;
66 |
67 | msg.Channel = VoiceChatChannel.Proximity;
68 | referenceHub.connectionToClient.Send(msg);
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/ScpProximityChat/ScpProximityChat.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | Debug
7 | AnyCPU
8 | {444B9DD9-EF85-4EFA-8A0A-BA70ECE95E07}
9 | Library
10 | Properties
11 | ScpProximityChat
12 | ScpProximityChat
13 | v4.8
14 | 512
15 | latest
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | true
36 |
37 |
38 |
39 | ..\packages\Lib.Harmony.2.2.2\lib\net48\0Harmony.dll
40 |
41 |
42 | D:\_Coding\SCPSL\Dependencies\Assembly-CSharp-Publicized.dll
43 |
44 |
45 | D:\_Coding\SCPSL\Dependencies\Assembly-CSharp-firstpass.dll
46 |
47 |
48 | D:\_Coding\SCPSL\Dependencies\Mirror-Publicized.dll
49 |
50 |
51 | D:\_Coding\SCPSL\Dependencies\NorthwoodLib.dll
52 |
53 |
54 | D:\_Coding\SCPSL\Dependencies\PluginAPI-Publicized.dll
55 |
56 |
57 |
58 |
59 |
60 |
61 | D:\_Coding\SCPSL\Dependencies\UnityEngine.CoreModule.dll
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/ScpProximityChatExiled/Features/ScpProximityChatHandler.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Exiled.API.Features;
3 | using Exiled.Events.EventArgs.Player;
4 | using PlayerRoles.FirstPersonControl;
5 | using PlayerRoles.Spectating;
6 | using PlayerRoles.Voice;
7 | using UnityEngine;
8 | using VoiceChat;
9 | using VoiceChat.Networking;
10 |
11 | namespace ScpProximityChatExiled.Features;
12 |
13 | public static class ScpProximityChatHandler
14 | {
15 | public static void RegisterEvents()
16 | {
17 | Exiled.Events.Handlers.Player.VoiceChatting += OnPlayerUsingVoiceChat;
18 | Exiled.Events.Handlers.Server.RestartingRound += OnRoundRestarted;
19 |
20 | if (ScpProximityChatModule.PluginConfig.ToggleChat)
21 | Exiled.Events.Handlers.Player.TogglingNoClip += OnPlayerTogglingNoClip;
22 |
23 | if (!ScpProximityChatModule.PluginConfig.SendBroadcastOnRoleChange)
24 | return;
25 |
26 | Exiled.Events.Handlers.Player.ChangingRole += OnPlayerChangingRole;
27 | }
28 |
29 | public static void UnregisterEvents()
30 | {
31 | Exiled.Events.Handlers.Player.VoiceChatting -= OnPlayerUsingVoiceChat;
32 | Exiled.Events.Handlers.Server.RestartingRound -= OnRoundRestarted;
33 |
34 | if (ScpProximityChatModule.PluginConfig.ToggleChat)
35 | Exiled.Events.Handlers.Player.TogglingNoClip -= OnPlayerTogglingNoClip;
36 |
37 | if (!ScpProximityChatModule.PluginConfig.SendBroadcastOnRoleChange)
38 | return;
39 |
40 | Exiled.Events.Handlers.Player.ChangingRole -= OnPlayerChangingRole;
41 | }
42 |
43 |
44 | private static readonly HashSet ToggledPlayers = [];
45 |
46 | private static void OnRoundRestarted()
47 | {
48 | ToggledPlayers.Clear();
49 | }
50 |
51 | private static void OnPlayerChangingRole(ChangingRoleEventArgs args)
52 | {
53 | if (!ScpProximityChatModule.PluginConfig.AllowedRoles.Contains(args.NewRole))
54 | return;
55 |
56 | args.Player.Broadcast(ScpProximityChatModule.PluginConfig.BroadcastDuration, ScpProximityChatModule.PluginConfig.BroadcastMessage);
57 | }
58 |
59 | public static void OnPlayerTogglingNoClip(TogglingNoClipEventArgs args)
60 | {
61 | if (FpcNoclip.IsPermitted(args.Player.ReferenceHub))
62 | return;
63 |
64 | if (!ScpProximityChatModule.PluginConfig.AllowedRoles.Contains(args.Player.Role.Type))
65 | return;
66 |
67 | if (!ToggledPlayers.Add(args.Player))
68 | {
69 | ToggledPlayers.Remove(args.Player);
70 | args.Player.ShowHint(ScpProximityChatModule.PluginConfig.ProximityChatDisabledMessage, 4f);
71 | args.IsAllowed = false;
72 | return;
73 | }
74 |
75 | args.Player.ShowHint(ScpProximityChatModule.PluginConfig.ProximityChatEnabledMessage, 4f);
76 | args.IsAllowed = false;
77 | }
78 |
79 | public static void OnPlayerUsingVoiceChat(VoiceChattingEventArgs args)
80 | {
81 | if (args.VoiceMessage.Channel != VoiceChatChannel.ScpChat)
82 | return;
83 |
84 | if (!ScpProximityChatModule.PluginConfig.AllowedRoles.Contains(args.Player.Role.Type) || (ScpProximityChatModule.PluginConfig.ToggleChat && !ToggledPlayers.Contains(args.Player)))
85 | return;
86 |
87 | SendProximityMessage(args.VoiceMessage);
88 |
89 | if (!ScpProximityChatModule.PluginConfig.ToggleChat)
90 | return;
91 |
92 | args.IsAllowed = false;
93 | }
94 |
95 | private static void SendProximityMessage(VoiceMessage msg)
96 | {
97 | foreach (ReferenceHub referenceHub in ReferenceHub.AllHubs)
98 | {
99 | if (referenceHub.roleManager.CurrentRole is SpectatorRole && !msg.Speaker.IsSpectatedBy(referenceHub))
100 | continue;
101 |
102 | if (referenceHub.roleManager.CurrentRole is not IVoiceRole voiceRole2)
103 | continue;
104 |
105 | if (Vector3.Distance(msg.Speaker.transform.position, referenceHub.transform.position) >= ScpProximityChatModule.PluginConfig.MaxProximityDistance)
106 | continue;
107 |
108 | if (voiceRole2.VoiceModule.ValidateReceive(msg.Speaker, VoiceChatChannel.Proximity) is VoiceChatChannel.None)
109 | continue;
110 |
111 | msg.Channel = VoiceChatChannel.Proximity;
112 | referenceHub.connectionToClient.Send(msg);
113 | }
114 | }
115 | }
--------------------------------------------------------------------------------
/ScpProximityChatExiled/ScpProximityChatExiled.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | Debug
7 | AnyCPU
8 | {731158F7-C918-4290-ADFB-44C27452EF58}
9 | Library
10 | Properties
11 | ScpProximityChatExiled
12 | ScpProximityChatExiled
13 | v4.8
14 | 512
15 | latest
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | true
36 |
37 |
38 |
39 | D:\_Coding\SCPSL\Dependencies\Assembly-CSharp-Publicized.dll
40 |
41 |
42 | ..\packages\EXILED.8.4.3\lib\net48\Assembly-CSharp-Publicized.dll
43 |
44 |
45 | D:\_Coding\SCPSL\Dependencies\Assembly-CSharp-firstpass.dll
46 |
47 |
48 | ..\packages\EXILED.8.4.3\lib\net48\CommandSystem.Core.dll
49 |
50 |
51 | ..\packages\EXILED.8.4.3\lib\net48\Exiled.API.dll
52 |
53 |
54 | ..\packages\EXILED.8.4.3\lib\net48\Exiled.CreditTags.dll
55 |
56 |
57 | ..\packages\EXILED.8.4.3\lib\net48\Exiled.CustomItems.dll
58 |
59 |
60 | ..\packages\EXILED.8.4.3\lib\net48\Exiled.CustomRoles.dll
61 |
62 |
63 | ..\packages\EXILED.8.4.3\lib\net48\Exiled.Events.dll
64 |
65 |
66 | ..\packages\EXILED.8.4.3\lib\net48\Exiled.Loader.dll
67 |
68 |
69 | ..\packages\EXILED.8.4.3\lib\net48\Exiled.Permissions.dll
70 |
71 |
72 | D:\_Coding\SCPSL\Dependencies\Mirror-Publicized.dll
73 |
74 |
75 | ..\packages\EXILED.8.4.3\lib\net48\NorthwoodLib.dll
76 |
77 |
78 | ..\packages\EXILED.8.4.3\lib\net48\PluginAPI.dll
79 |
80 |
81 |
82 |
83 |
84 |
85 | D:\_Coding\SCPSL\Dependencies\UnityEngine.CoreModule.dll
86 |
87 |
88 | ..\packages\EXILED.8.4.3\lib\net48\YamlDotNet.dll
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.)
298 | *.vbp
299 |
300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
301 | *.dsw
302 | *.dsp
303 |
304 | # Visual Studio 6 technical files
305 | *.ncb
306 | *.aps
307 |
308 | # Visual Studio LightSwitch build output
309 | **/*.HTMLClient/GeneratedArtifacts
310 | **/*.DesktopClient/GeneratedArtifacts
311 | **/*.DesktopClient/ModelManifest.xml
312 | **/*.Server/GeneratedArtifacts
313 | **/*.Server/ModelManifest.xml
314 | _Pvt_Extensions
315 |
316 | # Paket dependency manager
317 | .paket/paket.exe
318 | paket-files/
319 |
320 | # FAKE - F# Make
321 | .fake/
322 |
323 | # CodeRush personal settings
324 | .cr/personal
325 |
326 | # Python Tools for Visual Studio (PTVS)
327 | __pycache__/
328 | *.pyc
329 |
330 | # Cake - Uncomment if you are using it
331 | # tools/**
332 | # !tools/packages.config
333 |
334 | # Tabs Studio
335 | *.tss
336 |
337 | # Telerik's JustMock configuration file
338 | *.jmconfig
339 |
340 | # BizTalk build output
341 | *.btp.cs
342 | *.btm.cs
343 | *.odx.cs
344 | *.xsd.cs
345 |
346 | # OpenCover UI analysis results
347 | OpenCover/
348 |
349 | # Azure Stream Analytics local run output
350 | ASALocalRun/
351 |
352 | # MSBuild Binary and Structured Log
353 | *.binlog
354 |
355 | # NVidia Nsight GPU debugger configuration file
356 | *.nvuser
357 |
358 | # MFractors (Xamarin productivity tool) working folder
359 | .mfractor/
360 |
361 | # Local History for Visual Studio
362 | .localhistory/
363 |
364 | # Visual Studio History (VSHistory) files
365 | .vshistory/
366 |
367 | # BeatPulse healthcheck temp database
368 | healthchecksdb
369 |
370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
371 | MigrationBackup/
372 |
373 | # Ionide (cross platform F# VS Code tools) working folder
374 | .ionide/
375 |
376 | # Fody - auto-generated XML schema
377 | FodyWeavers.xsd
378 |
379 | # VS Code files for those working on multiple tools
380 | .vscode/*
381 | !.vscode/settings.json
382 | !.vscode/tasks.json
383 | !.vscode/launch.json
384 | !.vscode/extensions.json
385 | *.code-workspace
386 |
387 | # Local History for Visual Studio Code
388 | .history/
389 |
390 | # Windows Installer files from build outputs
391 | *.cab
392 | *.msi
393 | *.msix
394 | *.msm
395 | *.msp
396 |
397 | # JetBrains Rider
398 | *.sln.iml
399 |
--------------------------------------------------------------------------------