-
Notifications
You must be signed in to change notification settings - Fork 0
/
breakstuff.sp
88 lines (71 loc) · 2.03 KB
/
breakstuff.sp
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
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
bool g_bGameInProgress;
public Plugin myinfo =
{
name = "Break Stuff",
author = "FAILdows",
description = "Commands to break glass and graves",
version = "1.0",
url = "https://github.com/ericwong3/l4d2-plugins"
};
public void OnPluginStart()
{
RegConsoleCmd("sm_breakglass", Command_BreakGlass, "Breaks all glasses");
RegConsoleCmd("sm_breakgraves", Command_BreakGraves, "Breaks all graves");
HookEvent("survival_round_start", Event_OnSurvivalStart);
HookEvent("round_start", Event_OnRoundStart);
HookEvent("round_end", Event_OnRoundEnd);
g_bGameInProgress = false;
}
public Action Command_BreakGlass(int client, int args)
{
if (g_bGameInProgress)
{
ReplyToCommand(client, "[SM] Not allowed to use while round in progress.");
return Plugin_Handled;
}
int ent = -1;
while ((ent = FindEntityByClassname(ent, "func_breakable")) != -1)
{
if (IsValidEntity(ent)) {
int iMaterial = GetEntProp(ent, Prop_Data, "m_Material");
if (iMaterial == 0) { // Glass. Ref: https://twhl.info/wiki/page/func_breakable
AcceptEntityInput(ent, "Break");
}
}
}
return Plugin_Handled;
}
public Action Command_BreakGraves(int client, int args)
{
if (g_bGameInProgress)
{
ReplyToCommand(client, "[SM] Not allowed to use while round in progress.");
return Plugin_Handled;
}
int ent = -1;
while ((ent = FindEntityByClassname(ent, "prop_physics")) != -1)
{
char sModel[PLATFORM_MAX_PATH];
GetEntPropString(ent, Prop_Data, "m_ModelName", sModel, sizeof(sModel));
if (StrContains(sModel, "/grave_") != -1) {
AcceptEntityInput(ent, "Break");
}
}
return Plugin_Handled;
}
public void Event_OnSurvivalStart(Event event, const char[] name, bool dontBroadcast)
{
g_bGameInProgress = true;
}
public void Event_OnRoundStart(Event event, const char[] name, bool dontBroadcast)
{
g_bGameInProgress = false;
}
public void Event_OnRoundEnd(Event event, const char[] name, bool dontBroadcast)
{
g_bGameInProgress = false;
}