好东西,向来只有源码

5秒内连续开关安全门,安全门会被限制操作

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
#include <sourcemod>
#include <sdktools>

new pressedE[MAXPLAYERS+1];


public Plugin:myinfo=
{
name = "阻止频繁操作终点安全门",
author = "笨蛋海绵",
description = "阻止频繁操作终点安全门",
version = "5.0.0",
url = "QQ群:133102253"
}

public OnPluginStart()
{
HookEvent("player_use", player_use);
HookEvent("round_start", Event_RoundStart);
}

public Action:Event_RoundStart( Handle:event, const String:name[], bool:dontBroadcast )
{
for (new i=1; i<=MaxClients; i++)
{
if (IsClientInGame(i))
{
pressedE[i] = 0;
}
}
}

public Action:player_use(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new targetid = GetEventInt(event, "targetid");
if(client>0)
{
new String:entname[64];
if(GetEdictClassname(targetid, entname, sizeof(entname)))
{
if(StrEqual(entname, "prop_door_rotating_checkpoint") && IsLeftStartAreaArea())
{
pressedE[client]++;
if (pressedE[client] > 8)
{
AcceptEntityInput(targetid, "Lock");
SetEntProp(targetid, Prop_Data, "m_hasUnlockSequence", 1);
CreateTimer(5.0, Allow, client);
PrintHintText(client, "\x03小伙子门可不是随便玩的,5秒后再试试?");
} else {
AcceptEntityInput(targetid, "Unlock");
SetEntProp(targetid, Prop_Data, "m_hasUnlockSequence", 0);
}
}

}
}
return Plugin_Handled;
}

public Action:Allow(Handle:Timer, any:client)
{
pressedE[client] = 0;
PrintHintText(client, "\x03小伙子门可以操作了,手勿贱!");
}

bool:IsLeftStartAreaArea()
{
new ent = -1, maxents = GetMaxEntities();
for (new i = MaxClients+1; i <= maxents; i++)
{
if (IsValidEntity(i))
{
decl String:netclass[64];
GetEntityNetClass(i, netclass, sizeof(netclass));

if (StrEqual(netclass, "CTerrorPlayerResource"))
{
ent = i;
break;
}
}
}

if (ent > -1)
{
new offset = FindSendPropInfo("CTerrorPlayerResource", "m_hasAnySurvivorLeftSafeArea");
if (offset > 0)
{
if (GetEntData(ent, offset))
{
if (GetEntData(ent, offset) == 1) return true;
}
}
}
return false;
}