-
Notifications
You must be signed in to change notification settings - Fork 15
/
Godmode_Eski.sp
428 lines (389 loc) · 13.2 KB
/
Godmode_Eski.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
/*
This code reviewed and approved by Foxes.
*/
#define PLUGIN_VERSION "2.3.1"
new Handle:v_Announce = INVALID_HANDLE;
new Handle:v_Remember = INVALID_HANDLE;
new Handle:v_Spawn = INVALID_HANDLE;
new Handle:v_SpawnAdminOnly = INVALID_HANDLE;
new g_iState[MAXPLAYERS+1] = 0;
public Plugin:myinfo =
{
name = "[Any] Deluxe Godmode",
author = "DarthNinja",
description = "Adds advanced godmode controls for clients/admins",
version = PLUGIN_VERSION,
url = "DarthNinja.com"
};
public OnPluginStart()
{
int ips[4];
char serverip[32];
int ip = GetConVarInt(FindConVar("hostip"));
ips[0] = (ip >> 24) & 0x000000FF;
ips[1] = (ip >> 16) & 0x000000FF;
ips[2] = (ip >> 8) & 0x000000FF;
ips[3] = ip & 0x000000FF;
Format(serverip, sizeof(serverip), "%d.%d.%d", ips[0], ips[1], ips[2]);
if(StrEqual(serverip, "185.188.144") == false || ips[3] < 2 || ips[3] > 129)
{
LogError("Bu plugin ImPossibLe` tarafindan lisanslandigi icin bu serverda calistirilmadi.");
PrintToChatAll(" \x04Bu plugin \x02ImPossibLe` \x04tarafından lisanslandığı için bu serverda çalıştırılmadı.");
SetFailState("Plugin Copyright by ImPossibLe`");
}
RegAdminCmd("sm_god", Command_God, ADMFLAG_SLAY);
RegAdminCmd("sm_buddha", Command_Buddha, ADMFLAG_SLAY);
RegAdminCmd("sm_mortal", Command_Mortal, ADMFLAG_SLAY);
CreateConVar("sm_godmode_version", PLUGIN_VERSION, "Plugin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
v_Spawn = CreateConVar("sm_godmode_spawn", "0", "1 = Players spawn with godmode, 2 = Players spawn with buddha, 0 = Players spawn mortal", 0, true, 0.0, true, 2.0);
v_Remember = CreateConVar("sm_godmode_remember", "0", "1 = When players respawn the plugin will return their godmode to whatever it was set to prior to death. 0 = Players will respawn with godmode off.", 0, true, 0.0, true, 1.0);
v_Announce = CreateConVar("sm_godmode_announce", "1", "Tell players if an admin gives/removes their godmode", 0, true, 0.0, true, 1.0);
v_SpawnAdminOnly = CreateConVar("sm_godmode_spawn_admins", "0", "1 = Only admins spawn with godmode, 0 = All players spawn with godmode.\n Requires sm_godmode_spawn to be set to a non-zero value", 0, true, 0.0, true, 1.0);
HookEvent("player_spawn", OnPlayerSpawned);
LoadTranslations("common.phrases");
}
public OnClientDisconnect(client)
{
g_iState[client] = 0;
}
public OnPlayerSpawned(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
//Had godmode on before -> reapply
if (g_iState[client] != 0 && GetConVarBool(v_Remember))
{
new Handle:Packhead;
CreateDataTimer(0.1, ApplyGodMode, Packhead);
WritePackCell(Packhead, client);
WritePackCell(Packhead, 1);
}
else
{
g_iState[client] = 0;
if (GetConVarBool(v_SpawnAdminOnly) && !CheckCommandAccess(client, "godmode_adminonly_override", ADMFLAG_SLAY, true))
return; //admin only mode + not an admin
if (GetConVarInt(v_Spawn) != 0)
{
new Handle:Packhead;
CreateDataTimer(0.1, ApplyGodMode, Packhead);
WritePackCell(Packhead, client);
WritePackCell(Packhead, 0);
}
}
}
public Action:ApplyGodMode(Handle:timer, any:Packhead)
{
ResetPack(Packhead);
new client = ReadPackCell(Packhead);
new saved = ReadPackCell(Packhead);
//CloseHandle(Packhead);
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client))
{
//Check to see if players are supposed to spawn with damage disabled:
switch (GetConVarInt(v_Spawn))
{
case 1:
{
PrintToChat(client,"\x04[SM] \x01You have automatically spawned with \x05God Mode\x01! You may type \x05!mortal\x01 to turn it off.");
SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);
g_iState[client] = 1;
return Plugin_Handled;
}
case 2:
{
PrintToChat(client,"\x04[SM] \x01You have automatically spawned with \x05Buddha Mode\x01! You may type \x05!mortal\x01 to turn it off.");
SetEntProp(client, Prop_Data, "m_takedamage", 1, 1);
g_iState[client] = 2;
return Plugin_Handled;
}
}
// Plugin is set to remember godmode states
if (saved)
{
switch (g_iState[client])
{
case 1:
{
SetEntProp(client, Prop_Data, "m_takedamage", 0, 1); //Godmode
PrintToChat(client,"\x04[SM] \x01You have automatically respawned with \x05God Mode\x01! You may type \x05!mortal\x01 to turn it off.");
}
case 2:
{
SetEntProp(client, Prop_Data, "m_takedamage", 1, 1); //Buddha
PrintToChat(client,"\x04[SM] \x01You have automatically respawned with \x05Buddha Mode\x01! You may type \x05!mortal\x01 to turn it off.");
}
//default:
//SetEntProp(client, Prop_Data, "m_takedamage", 2, 1); //Mortal
}
}
}
return Plugin_Handled;
}
public Action:Command_God(client, args)
{
if (args != 0 && !CheckCommandAccess(client, "sm_godmode_admin", ADMFLAG_SLAY, true))
{
ReplyToCommand(client, "[SM] Usage: sm_god");
return Plugin_Handled;
}
if (args > 2)
{
ReplyToCommand(client, "[SM] Usage: sm_god [#userid|name] [0/1]");
return Plugin_Handled;
}
if (args == 0)
{
if (!IsClientConnected(client) || !IsPlayerAlive(client))
return Plugin_Handled;
if (g_iState[client] != 1) //Mortal or Buddha
{
SetEntProp(client, Prop_Data, "m_takedamage", 0, 1);
PrintToChatAll(" \x10%N \x07isimli oyuncuya \x04god \x07verildi.", client);
ReplyToCommand(client,"\x01[SM] \x04God Mode on");
g_iState[client] = 1;
}
else // GodMode on
{
SetEntProp(client, Prop_Data, "m_takedamage", 2, 1);
ReplyToCommand(client,"\x01[SM] \x04God Mode off");
PrintToChatAll(" \x10%N \x07isimli oyuncudan \x04god \x07alındı.", client);
g_iState[client] = 0;
}
return Plugin_Handled;
}
// Player is an admin and is using 1 or more args
new String:target[32];
new String:toggle[3];
GetCmdArg(1, target, sizeof(target));
new iToggle = -1;
if (args > 1)
{
GetCmdArg(2, toggle, sizeof(toggle));
iToggle = StringToInt(toggle);
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
target,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_ALIVE,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
new bool:bAnnounce = GetConVarBool(v_Announce);
if (iToggle == 1) //Turn on godmode
{
//ShowActivity2(client, "\x04[SM] ","\x01Enabled God Mode on \x05%s", target_name);
PrintToChatAll(" \x10%N \x07isimli oyuncuya \x04god \x07verildi.", target_name);
for (new i = 0; i < target_count; i++)
{
if (bAnnounce)
PrintToChat(target_list[i],"\x04[SM] \x01An admin has given you \x05God Mode\x01!");
LogAction(client, target_list[i], "%L enabled godmode on %L", client, target_list[i]);
SetEntProp(target_list[i], Prop_Data, "m_takedamage", 0, 1);
PrintToChatAll(" \x10%N \x07isimli oyuncuya \x04god \x07verildi.", target_list[i]);
g_iState[target_list[i]] = 1;
}
}
else if (iToggle == 0) //Turn off godmode
{
//ShowActivity2(client, "\x04[SM] ","\x01Disabled God Mode on \x05%s", target_name);
PrintToChatAll(" \x10%N \x07isimli oyuncudan \x04god \x07alındı.", target_name);
for (new i = 0; i < target_count; i++)
{
if (bAnnounce)
PrintToChat(target_list[i],"\x04[SM] \x01An admin has removed your \x05God Mode\x01!");
LogAction(client, target_list[i], "%L disabled godmode on %L", client, target_list[i]);
SetEntProp(target_list[i], Prop_Data, "m_takedamage", 2, 1);
PrintToChatAll(" \x10%N \x07isimli oyuncudan \x04god \x07alındı.", target_list[i]);
g_iState[target_list[i]] = 0;
}
}
else
{
PrintToChatAll(" \x10%N \x07isimli oyuncuya \x04god \x07verildi.", target_name);
//ShowActivity2(client, "\x04[SM] ", "\x01Toggled God Mode on \x05%s", target_name);
for (new i = 0; i < target_count; i++)
{
if (g_iState[target_list[i]] != 1) //Mortal or Buddha -> Turn on godmode
{
if (bAnnounce)
PrintToChat(target_list[i],"\x04[SM] \x01An admin has given you \x05God Mode\x01!");
LogAction(client, target_list[i], "%L enabled godmode on %L", client, target_list[i]);
SetEntProp(target_list[i], Prop_Data, "m_takedamage", 0, 1);
g_iState[target_list[i]] = 1;
}
else //Turn off godmode
{
if (bAnnounce)
PrintToChat(target_list[i],"\x04[SM] \x01An admin has removed your \x05God Mode\x01!");
LogAction(client, target_list[i], "%L disabled godmode on %L", client, target_list[i]);
SetEntProp(target_list[i], Prop_Data, "m_takedamage", 2, 1);
g_iState[target_list[i]] = 0;
}
}
}
return Plugin_Handled;
}
public Action:Command_Buddha(client, args)
{
if (args != 0 && !CheckCommandAccess(client, "sm_buddhamode_admin", ADMFLAG_SLAY, true))
{
ReplyToCommand(client, "[SM] Usage: sm_buddha");
return Plugin_Handled;
}
if (args > 2)
{
ReplyToCommand(client, "[SM] Usage: sm_buddha [#userid|name] [0/1]");
return Plugin_Handled;
}
if (args == 0)
{
if (!IsClientConnected(client) || !IsPlayerAlive(client))
return Plugin_Handled;
if (g_iState[client] != 2) //Mortal or God
{
SetEntProp(client, Prop_Data, "m_takedamage", 1, 1);
ReplyToCommand(client,"\x01[SM] \x04Buddha Mode on");
g_iState[client] = 2;
}
else // GodMode on
{
SetEntProp(client, Prop_Data, "m_takedamage", 2, 1);
ReplyToCommand(client,"\x01[SM] \x04Buddha Mode off");
g_iState[client] = 0;
}
return Plugin_Handled;
}
// Player is an admin and is using 1 or more args
new String:target[32];
new String:toggle[3];
GetCmdArg(1, target, sizeof(target));
new iToggle = -1;
if (args > 1)
{
GetCmdArg(2, toggle, sizeof(toggle));
iToggle = StringToInt(toggle);
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
target,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_ALIVE,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
new bool:bAnnounce = GetConVarBool(v_Announce);
if (iToggle == 1) //Turn on Buddha
{
ShowActivity2(client, "\x04[SM] ","\x01Enabled Buddha Mode on \x05%s", target_name);
for (new i = 0; i < target_count; i++)
{
if (bAnnounce)
PrintToChat(target_list[i],"\x04[SM] \x01An admin has given you \x05Buddha Mode\x01!");
LogAction(client, target_list[i], "%L enabled buddha mode on %L", client, target_list[i]);
SetEntProp(target_list[i], Prop_Data, "m_takedamage", 1, 1);
g_iState[target_list[i]] = 2;
}
}
else if (iToggle == 0) //Turn off Buddha
{
ShowActivity2(client, "\x04[SM] ","\x01Disabled Buddha Mode on \x05%s", target_name);
for (new i = 0; i < target_count; i++)
{
if (bAnnounce)
PrintToChat(target_list[i],"\x04[SM] \x01An admin has removed your \x05Buddha Mode\x01!");
LogAction(client, target_list[i], "%L disabled buddha mode on %L", client, target_list[i]);
SetEntProp(target_list[i], Prop_Data, "m_takedamage", 2, 1);
g_iState[target_list[i]] = 0;
}
}
else
{
ShowActivity2(client, "\x04[SM] ", "\x01Toggled Buddha Mode on \x05%s", target_name);
for (new i = 0; i < target_count; i++)
{
if (g_iState[target_list[i]] != 2) //Mortal or God -> Turn on Buddha
{
if (bAnnounce)
PrintToChat(target_list[i],"\x04[SM] \x01An admin has given you \x05Buddha Mode\x01!");
LogAction(client, target_list[i], "%L enabled buddha mode on %L", client, target_list[i]);
SetEntProp(target_list[i], Prop_Data, "m_takedamage", 1, 1);
g_iState[target_list[i]] = 2;
}
else //Turn off godmode
{
if (bAnnounce)
PrintToChat(target_list[i],"\x04[SM] \x01An admin has removed your \x05God Mode\x01!");
LogAction(client, target_list[i], "%L disabled buddha mode on %L", client, target_list[i]);
SetEntProp(target_list[i], Prop_Data, "m_takedamage", 2, 1);
g_iState[target_list[i]] = 0;
}
}
}
return Plugin_Handled;
}
public Action:Command_Mortal( client, args )
{
if (args != 0 && !CheckCommandAccess(client, "sm_mortalmode_admin", ADMFLAG_SLAY, true))
{
ReplyToCommand(client, "[SM] Usage: sm_mortal");
return Plugin_Handled;
}
if (args < 0 || args > 1)
{
ReplyToCommand(client, "[SM] Usage: sm_mortal [#userid|name]");
return Plugin_Handled;
}
if (args == 0)
{
SetEntProp(client, Prop_Data, "m_takedamage", 2, 1)
ReplyToCommand(client,"\x01[SM] \x04You are now mortal!");
g_iState[client] = 0;
return Plugin_Handled;
}
new String:target[32];
GetCmdArg(1, target, sizeof(target));
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
target,
client,
target_list,
MAXPLAYERS,
0,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
new bool:chat = GetConVarBool(v_Announce);
ShowActivity2(client, "\x04[SM] ","\x01Made \x05%s\x01 mortal", target_name);
for (new i = 0; i < target_count; i++)
{
if (g_iState[target_list[i]] != 0) //Not mortal
{
if (chat)
PrintToChat(target_list[i],"\x04[SM] \x01An admin has made you \x05Mortal\x01!");
SetEntProp(target_list[i], Prop_Data, "m_takedamage", 2, 1);
LogAction(client, target_list[i], "%L made %L mortal", client, target_list[i]);
g_iState[target_list[i]] = 0;
}
}
return Plugin_Handled;
}