-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
58 lines (45 loc) · 1.58 KB
/
Plugin.cs
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
using PluginAPI.Core;
using PluginAPI.Core.Attributes;
using PluginAPI.Core.Interfaces;
using PluginAPI.Enums;
using PluginAPI.Events;
using PlayerRoles;
using System;
using System.Collections;
namespace SCPSelector
{
public class Plugin
{
[PluginConfig]
public Config Config;
public static Plugin Instance { get; private set; }
public SelectionData Data { get; private set; }
[PluginEntryPoint("SCP Selector", "1.0", "Allows player chosen as the scp to select their scp", "Luis T. Sanchez")]
void OnEntryPoint()
{
if (!Config.Enabled) return;
Instance = this;
Data = new SelectionData();
EventManager.RegisterEvents(this);
}
[PluginReload]
void OnReload()
{
Data.Reset();
}
[PluginEvent(ServerEventType.PlayerSpawn)]
void OnPlayerSpawn(Player player, RoleTypeId role)
{
if (player == null) return;
if (!player.IsSCP || Round.Duration.TotalSeconds >= Config.SelectionTimer) return;
int timeRemaining = Config.SelectionTimer - (int)Round.Duration.TotalSeconds;
Data.RegisterSCPPlayer(player, role);
player.SendBroadcast($"<color=yellow><b>You have {timeRemaining} seconds to change scp. Type .scpselect (scp number) to change scp.</b></color>", (ushort)timeRemaining, Broadcast.BroadcastFlags.Normal, true);
}
[PluginEvent(ServerEventType.RoundStart)]
void OnRoundStart()
{
Data.Reset();
}
}
}