-
Notifications
You must be signed in to change notification settings - Fork 0
/
block_rocketjump.sp
149 lines (136 loc) · 3.69 KB
/
block_rocketjump.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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#define PLUGIN_VERSION "1.5"
#define MAXENTITY 2048
#define DEBUG 0
#define DEBUG_TAG "Block_RocketJump"
bool g_bRocketJumpExploit[MAXENTITY + 1];
bool g_bStepOnEntity[MAXPLAYERS + 1];
bool g_bL4D2Version;
public Plugin myinfo =
{
name = "Block Rocket Jump Exploit",
author = "DJ_WEST, HarryPotter",
description = "Block rocket jump exploit (with grenade launcher/vomitjar/pipebomb/molotov/common/spit/rock)",
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/showthread.php?t=122371"
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
EngineVersion test = GetEngineVersion();
if (test == Engine_Left4Dead)
{
g_bL4D2Version = false;
}
else if (test == Engine_Left4Dead2)
{
g_bL4D2Version = true;
}
else
{
strcopy(error, err_max, "Plugin only supports Left 4 Dead 1 & 2.");
return APLRes_SilentFailure;
}
return APLRes_Success;
}
public void OnPluginStart()
{
CreateConVar("block_rocketjump_version", PLUGIN_VERSION, "Block Rocket Jump Exploit version", FCVAR_NOTIFY|FCVAR_DONTRECORD);
}
public void OnEntityCreated(int entity, const char[] classname)
{
if (!IsValidEntityIndex(entity))
{
return;
}
switch (classname[0])
{
case 'i', // infected
'm', // molotov_projectile
'p', // pipe_bomb_projectile
't', // tank_rock
'v', // vomitjar_projectile
'g', // grenade_launcher_projectile
's', // spitter_projectile
'w': // witch
{
if (strcmp(classname, "infected") == 0 ||
strcmp(classname, "molotov_projectile") == 0 ||
strcmp(classname, "pipe_bomb_projectile") == 0 ||
strcmp(classname, "tank_rock") == 0 ||
strcmp(classname, "witch") == 0 ||
(g_bL4D2Version && (strcmp(classname, "vomitjar_projectile") == 0 ||
strcmp(classname, "grenade_launcher_projectile") == 0 ||
strcmp(classname, "spitter_projectile") == 0)) )
{
g_bRocketJumpExploit[entity] = true;
}
}
}
}
public void OnEntityDestroyed(int entity)
{
if (!IsValidEntityIndex(entity))
{
return;
}
g_bRocketJumpExploit[entity] = false;
}
bool IsValidEntityIndex(int entity)
{
return (MaxClients + 1 <= entity <= GetMaxEntities());
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
{
if (IsClientInGame(client) && GetClientTeam(client) != 1 && IsPlayerAlive(client))
{
if (IsFakeClient(client))
{
return Plugin_Continue;
}
int entity = GetEntPropEnt(client, Prop_Data, "m_hGroundEntity");
if (entity > MaxClients && g_bRocketJumpExploit[entity])
{
#if DEBUG
Debug_PrintText("%N step on entity - %d", client, entity);
#endif
g_bStepOnEntity[client] = true;
return Plugin_Continue;
}
if (g_bStepOnEntity[client])
{
float flVel[3];
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", flVel);
#if DEBUG
Debug_PrintText("%N m_vecAbsVelocity - %.2f %.2f %.2f", client, flVel[0], flVel[1], flVel[2]);
#endif
flVel[2] = 0.0;
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, flVel);
}
}
g_bStepOnEntity[client] = false;
return Plugin_Continue;
}
#if DEBUG
void Debug_PrintText(const char[] format, any ...)
{
char buffer[256];
VFormat(buffer, sizeof(buffer), format, 2);
LogMessage("%s", buffer);
AdminId adminId;
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client) && !IsFakeClient(client))
{
adminId = GetUserAdmin(client);
if (adminId != INVALID_ADMIN_ID && GetAdminFlag(adminId, Admin_Generic))
{
PrintToChat(client, "[%s] %s", DEBUG_TAG, buffer);
}
}
}
}
#endif