-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSsss.cs
More file actions
68 lines (59 loc) · 2.4 KB
/
Ssss.cs
File metadata and controls
68 lines (59 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Exiled.API.Features;
using Exiled.API.Features.Core.UserSettings;
using ExtendedItems.Items;
using UnityEngine;
using UserSettings.ServerSpecific;
namespace ExtendedItems
{
public class Ssss
{
// ReSharper disable once InconsistentNaming
private static IEnumerable<SettingBase>? _settings;
public static void Register()
{
Log.Info("Keybind Registered");
ServerSpecificSettingsSync.ServerOnSettingValueReceived += Keybind;
_settings =
[
new HeaderSetting(10, "Example Header", "Example Header Description", true),
new KeybindSetting(24, "Example Keybind", KeyCode.Delete, hintDescription: "Example"),
];
SettingBase.Register(_settings);
}
public static void Unregister()
{
ServerSpecificSettingsSync.ServerOnSettingValueReceived -= Keybind;
}
private static void Keybind(ReferenceHub referenceHub, ServerSpecificSettingBase settingBase)
{
if (settingBase is not SSKeybindSetting { SettingId: 24, SyncIsPressed: true } keybindSetting)
return;
if (!Player.TryGet(referenceHub, out var player))
return;
Log.Info("Keybind used by " + player.Nickname);
if (keybindSetting.SettingId == 24)
{
var i = 0;
foreach (var charge in Plastic.PlacedCharges.ToList())
{
var posy = charge.Key.Position.y;
if (charge.Value != player) continue;
if (player.Position.y >= posy - 100 && player.Position.y <= posy + 100)
{
Plastic.Instance.Handler(charge.Key, Plastic.C4RemoveMethod.Detonate, player);
i++;
}
else
{
player.SendConsoleMessage(
"One of your charges is out of range. You need to get within the zone that it was placed",
"yellow");
}
player.ShowHint(i == 1
? $"\n<color=green>{i} C4 charge has been detonated!</color>"
: $"\n<color=green>{i} C4 charges have been detonated!</color>");
}
}
}
}
}