This repository has been archived by the owner on Dec 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
124 lines (109 loc) · 2.59 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using Smod2;
using Smod2.API;
using Smod2.EventHandlers;
using Smod2.Events;
using System.Collections.Generic;
using Smod2.Attributes;
namespace SCP_372
{
[PluginDetails(
author = "ShingekiNoRex",
name = "SCP-372",
description = "Player is invisible while standing still and not shooting.",
id = "shingekinorex.scp372",
version = "4.0.0",
SmodMajor = 3,
SmodMinor = 10,
SmodRevision = 6
)]
class SCP372Plugin : Plugin
{
public override void OnDisable()
{
}
public override void OnEnable()
{
}
public override void Register()
{
AddEventHandlers(new EventHandler(this), Priority.NORMAL);
}
}
class EventHandler : IEventHandlerSetRole, IEventHandlerShoot, IEventHandlerFixedUpdate, IEventHandlerRoundStart
{
private Plugin plugin;
public EventHandler(Plugin plugin)
{
this.plugin = plugin;
}
public class ShowGhost
{
public int playerId;
public float remainingTime;
}
public List<ShowGhost> ghostList = new List<ShowGhost>();
public void OnRoundStart(RoundStartEvent ev)
{
List<Player> PlayerList = new List<Player>();
foreach (Player player in ev.Server.GetPlayers())
{
if (player.PlayerRole.Team == TeamType.D_CLASS)
{
PlayerList.Add(player);
}
}
if (PlayerList.Count > 2)
{
PlayerList[new System.Random().Next(PlayerList.Count)].ChangeRole(RoleType.TUTORIAL);
}
}
public void OnSetRole(PlayerSetRoleEvent ev)
{
if (ev.RoleType == RoleType.TUTORIAL)
{
ev.Player.SetGhostMode(true);
}
else if (ev.Player.GetGhostMode())
{
ev.Player.SetGhostMode(false);
}
}
public void OnShoot(PlayerShootEvent ev)
{
//plugin.Logger.Warn("SCP-372", "ONSHOOT " + ev.Weapon.ItemType + " " + ev.HitType);
if (ev.Player.PlayerRole.Team == TeamType.TUTORIAL)
{
foreach(ShowGhost ghost in ghostList)
{
if (ghost.playerId == ev.Player.PlayerID)
{
ghost.remainingTime = 3f;
ev.Player.SetGhostMode(false);
return;
}
}
ghostList.Add(new ShowGhost { playerId = ev.Player.PlayerID, remainingTime = 3f });
ev.Player.SetGhostMode(false);
}
}
public void OnFixedUpdate(FixedUpdateEvent ev)
{
for (int i = 0; i < ghostList.Count; i++)
{
ghostList[i].remainingTime -= 0.02f;
if (ghostList[i].remainingTime <= 0)
{
foreach(Player player in plugin.PluginManager.Server.GetPlayers())
{
if (player.PlayerID == ghostList[i].playerId && player.PlayerRole.Team == TeamType.TUTORIAL)
{
player.SetGhostMode(true);
}
}
ghostList.RemoveAt(i);
return;
}
}
}
}
}