generated from ClaudiuHKS/AdvancedQuakeSounds
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
suicide_game_score.sp
310 lines (239 loc) · 9.13 KB
/
suicide_game_score.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/**
* MAIN REQUIREMENTS
*/
#include <sourcemod>
#include <sdktools>
/**
* CUSTOM DEFINITIONS TO BE EDITED
*/
#define _SUICIDE_SCORE_ (0) // contributionscore_suicide
#define _SUICIDE_PENALTY_ (0) // mp_suicide_penalty
/**
* CUSTOM DEFINITIONS
*/
#define _PREP_OFFS_(%0,%1,%2) if (%1 < 1) %1 = _Get_Offs_(%0, %2)
/**
* CUSTOM INFORMATION
*/
public Plugin myinfo =
{
name = "Suicide Game Score",
author = "CARAMEL® HACK",
description = "Alters The Score Of The Players Committing Suicide",
version = __DATE__,
url = "https://hattrick.go.ro/",
};
/**
* GLOBAL VARIABLES
*/
static Handle g_hSuicideScore = INVALID_HANDLE;
static Handle g_hSuicidePenalty = INVALID_HANDLE;
static bool g_bPlayerDeathHooked = false;
static bool g_bSScoreConVarChangeHooked = false;
static bool g_bSPenConVarChangeHooked = false;
/**
* CUSTOM PRIVATE FUNCTIONS
*/
static int _Get_Offs_(int nEntity, const char[] szProp)
{
static const char szTables[][] =
{
"CBaseEntity", "CBaseCSEntity",
"CBasePlayer", "CBaseCSPlayer",
"CBaseGrenade", "CBaseCSGrenade",
"CBaseGrenadeProjectile", "CBaseCSGrenadeProjectile",
"CBasePlayerResource", "CBaseCSPlayerResource",
"CBaseViewModel", "CBaseCSViewModel",
"CBaseC4", "CBaseCSC4",
"CBaseAnimating", "CBaseCSAnimating",
"CBaseCombatCharacter", "CBaseCSCombatCharacter",
"CBaseCombatWeapon", "CBaseCSCombatWeapon",
"CBaseWeaponWorldModel", "CBaseCSWeaponWorldModel",
"CBaseRagdoll", "CBaseCSRagdoll",
"CEntity", "CSEntity", "CCSEntity",
"CPlayer", "CSPlayer", "CCSPlayer",
"CGrenade", "CSGrenade", "CCSGrenade",
"CGrenadeProjectile", "CSGrenadeProjectile", "CCSGrenadeProjectile",
"CPlayerResource", "CSPlayerResource", "CCSPlayerResource",
"CViewModel", "CSViewModel", "CCSViewModel",
"CC4", "CSC4", "CCSC4",
"CAnimating", "CSAnimating", "CCSAnimating",
"CCombatCharacter", "CSCombatCharacter", "CCSCombatCharacter",
"CCombatWeapon", "CSCombatWeapon", "CCSCombatWeapon",
"CWeaponWorldModel", "CSWeaponWorldModel", "CCSWeaponWorldModel",
"CRagdoll", "CSRagdoll", "CCSRagdoll",
};
static int nOffs = 0, nTable = 0;
if ((nOffs = FindDataMapInfo(nEntity, szProp)) > 0)
{
return nOffs;
}
for (nTable = 0; nTable < sizeof (szTables); nTable++)
{
if ((nOffs = FindSendPropInfo(szTables[nTable], szProp)) > 0)
{
return nOffs;
}
}
return nOffs;
}
/**
* CUSTOM PUBLIC FORWARDS
*/
public void OnPluginStart()
{
OnMapStart();
}
public void OnMapStart()
{
static char szBuffer[PLATFORM_MAX_PATH] = { 0, ... };
if (!g_bPlayerDeathHooked)
{
HookEventEx("player_death", _Player_Death_, EventHookMode_Post);
g_bPlayerDeathHooked = true;
}
if (g_hSuicideScore == INVALID_HANDLE)
{
g_hSuicideScore = FindConVar("contributionscore_suicide");
}
if (g_hSuicidePenalty == INVALID_HANDLE)
{
g_hSuicidePenalty = FindConVar("mp_suicide_penalty");
}
if (g_hSuicideScore != INVALID_HANDLE)
{
if (GetConVarInt(g_hSuicideScore) != _SUICIDE_SCORE_)
{
IntToString(_SUICIDE_SCORE_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSuicideScore, szBuffer, true, true);
}
if (!g_bSScoreConVarChangeHooked)
{
HookConVarChange(g_hSuicideScore, _Con_Var_Change_);
g_bSScoreConVarChangeHooked = true;
}
if (GetConVarInt(g_hSuicideScore) != _SUICIDE_SCORE_)
{
IntToString(_SUICIDE_SCORE_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSuicideScore, szBuffer, true, true);
}
}
if (g_hSuicidePenalty != INVALID_HANDLE)
{
if (GetConVarInt(g_hSuicidePenalty) != _SUICIDE_PENALTY_)
{
IntToString(_SUICIDE_PENALTY_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSuicidePenalty, szBuffer, true, true);
}
if (!g_bSPenConVarChangeHooked)
{
HookConVarChange(g_hSuicidePenalty, _Con_Var_Change_);
g_bSPenConVarChangeHooked = true;
}
if (GetConVarInt(g_hSuicidePenalty) != _SUICIDE_PENALTY_)
{
IntToString(_SUICIDE_PENALTY_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSuicidePenalty, szBuffer, true, true);
}
}
}
public void OnMapEnd()
{
if (g_bPlayerDeathHooked)
{
UnhookEvent("player_death", _Player_Death_, EventHookMode_Post);
g_bPlayerDeathHooked = false;
}
if (g_hSuicideScore != INVALID_HANDLE)
{
if (g_bSScoreConVarChangeHooked)
{
UnhookConVarChange(g_hSuicideScore, _Con_Var_Change_);
g_bSScoreConVarChangeHooked = false;
}
}
if (g_hSuicidePenalty != INVALID_HANDLE)
{
if (g_bSPenConVarChangeHooked)
{
UnhookConVarChange(g_hSuicidePenalty, _Con_Var_Change_);
g_bSPenConVarChangeHooked = false;
}
}
}
public void OnPluginEnd()
{
OnMapEnd();
}
/**
* CUSTOM PUBLIC HANDLERS
*/
public void _Player_Death_(Event hEv, const char[] szName, bool bNoBC)
{
static int nVictimUserId = 0, nKillerUserId = 0, nVictim = 0, nPlayer = 0, m_bIsControllingBot = 0, m_iControlledBotEntIndex = 0;
nVictimUserId = hEv.GetInt("userid", 0);
if (nVictimUserId > 0)
{
nVictim = GetClientOfUserId(nVictimUserId);
if (nVictim > 0)
{
if (IsClientConnected(nVictim) && IsClientInGame(nVictim))
{
if (!IsPlayerAlive(nVictim))
{
nKillerUserId = hEv.GetInt("attacker", 0);
if (nVictimUserId == nKillerUserId || nKillerUserId < 1)
{
_PREP_OFFS_(nVictim, m_bIsControllingBot, "m_bIsControllingBot");
if (GetEntData(nVictim, m_bIsControllingBot, 1) > 0)
{
_PREP_OFFS_(nVictim, m_iControlledBotEntIndex, "m_iControlledBotEntIndex");
if ((nPlayer = GetEntData(nVictim, m_iControlledBotEntIndex)) > 0 && IsClientConnected(nPlayer) && IsClientInGame(nPlayer))
{
CreateTimer(0.000001, _Timer_Decrease_Deaths_, GetClientUserId(nPlayer), TIMER_FLAG_NO_MAPCHANGE);
}
}
else
{
CreateTimer(0.000001, _Timer_Decrease_Deaths_, nVictimUserId, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
}
}
}
}
public Action _Timer_Decrease_Deaths_(Handle hTimer, any nId)
{
static int m_iDeaths = 0, nEntity = 0, nDeaths = 0;
if ((nEntity = GetClientOfUserId(nId)) > 0 && IsClientConnected(nEntity) && IsClientInGame(nEntity))
{
_PREP_OFFS_(nEntity, m_iDeaths, "m_iDeaths");
nDeaths = GetEntData(nEntity, m_iDeaths);
if (nDeaths > 0)
{
SetEntData(nEntity, m_iDeaths, nDeaths - 1);
}
}
return Plugin_Continue;
}
public void _Con_Var_Change_(Handle hConVar, const char[] szOld, const char[] szNew)
{
static char szBuffer[PLATFORM_MAX_PATH] = { 0, ... };
if (hConVar == g_hSuicideScore)
{
if (StringToInt(szNew) != _SUICIDE_SCORE_)
{
IntToString(_SUICIDE_SCORE_, szBuffer, sizeof (szBuffer));
SetConVarString(hConVar, szBuffer, true, true);
}
}
else if (hConVar == g_hSuicidePenalty)
{
if (StringToInt(szNew) != _SUICIDE_PENALTY_)
{
IntToString(_SUICIDE_PENALTY_, szBuffer, sizeof (szBuffer));
SetConVarString(hConVar, szBuffer, true, true);
}
}
}