diff --git a/CuffedFrenemies/CuffedFrenemies.cs b/CuffedFrenemies/CuffedFrenemies.cs new file mode 100644 index 0000000..f25eb9d --- /dev/null +++ b/CuffedFrenemies/CuffedFrenemies.cs @@ -0,0 +1,66 @@ +using LabApi.Events.Arguments.PlayerEvents; +using LabApi.Events.Handlers; +using LabApi.Features; +using LabApi.Features.Console; +using LabApi.Features.Wrappers; +using LabApi.Loader.Features.Plugins; +using Mirror; +using PlayerRoles; + +namespace CuffedFrenemies; + +public class CuffedFrenemies : Plugin +{ + public override string Name => "GamblingCoin"; + public override string Author => "Code002Lover"; + public override Version Version { get; } = new(1, 0, 0); + public override string Description => "Gamble your life away"; + public override Version RequiredApiVersion { get; } = new (LabApiProperties.CompiledVersion); + + public override void Enable() + { + Logger.Debug("Loading"); + PlayerEvents.Cuffed += OnCuff; + } + + public override void Disable() + { + PlayerEvents.Cuffed -= OnCuff; + } + + private static void OnCuff(PlayerCuffedEventArgs ev) + { + Logger.Debug($"Team: {ev.Target.Team}"); + if (ev.Target.Team is Team.ClassD or Team.Scientists) + { + return; + } + + if (ev.Target.Team == ev.Player.Team) + { + Logger.Debug("Same team, not changing role"); + return; + } + + var newRole = ev.Target.Team == Team.ChaosInsurgency ? RoleTypeId.NtfPrivate : RoleTypeId.ChaosConscript; + Logger.Debug($"Setting role to {newRole}"); + var newItems = new List(); + ev.Target.Items.CopyTo(newItems); + newItems.Reverse(); + + var newPos = ev.Target.Position; + + ev.Target.Inventory.UserInventory.Items.Clear(); + + ev.Target.SetRole(newRole); + ev.Target.ClearItems(); + + foreach (var newItem in newItems) + { + ev.Target.Inventory.UserInventory.Items.Add(newItem.Serial,newItem.Base); + } + + ev.Target.Position = newPos; + + } +} \ No newline at end of file diff --git a/CuffedFrenemies/CuffedFrenemies.csproj b/CuffedFrenemies/CuffedFrenemies.csproj new file mode 100644 index 0000000..56e256b --- /dev/null +++ b/CuffedFrenemies/CuffedFrenemies.csproj @@ -0,0 +1,37 @@ + + + + net48 + enable + disable + 10 + + + + true + true + full + + + + true + false + none + + + + + ..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll + + + ..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll + + + ..\..\.local\share\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll + + + + + + + diff --git a/SecretPluginLaboratories.sln b/SecretPluginLaboratories.sln index 3db4dbd..5964e99 100644 --- a/SecretPluginLaboratories.sln +++ b/SecretPluginLaboratories.sln @@ -16,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RangeBan", "RangeBan\RangeB EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RangeBan.Tests", "RangeBan.Tests\RangeBan.Tests.csproj", "{AA495D0E-0122-4C26-8D26-C728B65BFF12}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CuffedFrenemies", "CuffedFrenemies\CuffedFrenemies.csproj", "{C3FEEC52-B7C0-4DB6-A0CA-54BE175072D8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -54,5 +56,9 @@ Global {AA495D0E-0122-4C26-8D26-C728B65BFF12}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA495D0E-0122-4C26-8D26-C728B65BFF12}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA495D0E-0122-4C26-8D26-C728B65BFF12}.Release|Any CPU.Build.0 = Release|Any CPU + {C3FEEC52-B7C0-4DB6-A0CA-54BE175072D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3FEEC52-B7C0-4DB6-A0CA-54BE175072D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3FEEC52-B7C0-4DB6-A0CA-54BE175072D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3FEEC52-B7C0-4DB6-A0CA-54BE175072D8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal