-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnadeking_video.sp
More file actions
2048 lines (1639 loc) · 60.7 KB
/
nadeking_video.sp
File metadata and controls
2048 lines (1639 loc) · 60.7 KB
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
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <cstrike>
#include <sdkhooks>
#include <sdktools>
#include <smlib>
#include <devzones>
#include <overlays>
char g_szFirstChallengeZoneNames[][] = {"t_spawn", "a_bombsite"};
char g_szKZRaceZoneNames[][] = {"kz_start", "kz_end"};
int g_iLaserSprite;
// NOTES
// KZ RACE Checkpoints
// Easier map
// == GUNS ==
// mp_items_prohibited
// Ban certain guns
// Accurate timer
// Timer
// == RACE CHALLENGE == [DONE]
// After x seconds, freeze players and show distance
// == STICKER CHALLENGE ==
// Prices: cents, 50+, 500+. Bold gaps
// == BOT SOUND TEST ==
// Grab from github
// == MOLOTOV DAMAGE TEST ==
// Throw molotov, take as much HP as possible
// dead = out
public Plugin myinfo = {
name = "[NadeKing] Last To Leave (Pros)",
author = "zwolof",
description = "Plugin for NadeKing",
version = "1.0.0",
url = "https://steamcommunity.com/profiles/76561198062332030"
};
#define NADEKING_STEAMID "76561197994023214"
#define ZWOLOF_STEAMID "76561198062332030"
#define STICKER_MDL "models/inventory_items/sticker_inspect_chall_zwolof_fix.mdl"
bool g_bBot1;
bool g_bBot2;
int g_iBot1;
int g_iBot2;
float flBot1Pos[3];
float flBot2Pos[3];
bool g_iBotShoot1 = false;
bool g_iBotShoot2 = false;
bool g_bBotsShouldShoot = false;
int g_iStartTime = -1;
int g_iTimeToCompleteChallenge[MAXPLAYERS+1] = {-1, ...};
int g_iLastToReachSite = -1;
int g_iKZRaceStartTime[MAXPLAYERS+1] = {-1, ...};
int g_iTimeToCompleteKZRace[MAXPLAYERS+1] = {-1, ...};
int g_iLastToFinishKZMap = -1;
int g_i90SecondCountDown = 90;
int g_iStickerEnts[MAXPLAYERS+1] = { INVALID_ENT_REFERENCE, ... };
bool g_bDidFinishKZCourse[MAXPLAYERS+1] = {false, ...};
bool g_bDidReachASite[MAXPLAYERS+1] = {false, ...};
bool g_bHasPurchasedWeapon[MAXPLAYERS+1] = {false, ...};
bool g_bStickerBlock = true;
bool g_bIsEveryoneFrozen = false;
bool g_bHasStartedKZRace[MAXPLAYERS+1] = {false, ...};
bool g_bDidFinishCourse[MAXPLAYERS+1] = {false, ...};
bool g_bCanShoot = false;
Handle g_HudSyncRaceTimer = INVALID_HANDLE;
Handle g_hRaceTimer = INVALID_HANDLE;
float g_fUnitsAwayFromBombsite[MAXPLAYERS+1] = {0.0, ...};
int g_iGunTossDroppedEntity[MAXPLAYERS+1] = {-1, ...};
float g_fGunTossDroppedOrigin[MAXPLAYERS+1][3];
float g_fGunTossJumpPosition[MAXPLAYERS+1][3];
bool g_bDidGunTossJump[MAXPLAYERS+1] = {false, ...};
bool g_bGunHasLanded[MAXPLAYERS+1] = {false, ...};
enum struct IBombSurvivor_t {
int clientIdx;
int damage;
}
enum ChallengeZones_t {
ChallengeZones_TSPAWN = 0,
ChallengeZones_ASITE
}
// g_szKZRaceZoneNames, KZRaceZones_t
enum KZRaceZones_t {
KZRaceZones_Start = 0,
KZRaceZones_End
}
char g_szChallenges[][] = {
"No Challenge",
"Dust2 Blindfold Race",
"Empty Guns",
"Bot Sound Test",
"Bomb Challenge",
"Sticker Challenge",
"KZ Race",
"1 vs 1",
"Molotov Damage",
"Gun Toss",
};
enum Challenge_t {
Challenge_NONE = 0,
Challenge_TSPAWNRACE,
Challenge_EMPTY_GUNS,
Challenge_BOTSOUND,
Challenge_BOMB_DAMAGE,
Challenge_STICKERS,
Challenge_KZRACE,
Challenge_1VS1,
Challenge_MOLOTOV_DAMAGE,
Challenge_GUNTOSS,
MAX_CHALLENGES
}
enum DuelChallenges_t {
DuelChallenges_NONE = 0,
DuelChallenges_GRAVITY,
DuelChallenges_THIRDPERSON,
DuelChallenges_FOV,
DuelChallenges_FASTAFBOII,
DuelChallenges_AUTOBHOP,
DuelChallenges_KNIFE,
DuelChallenges_NORMAL1,
DuelChallenges_VAMPIRE,
DuelChallenges_ONE_HP_GRENADE,
DuelChallenges_BACKWARDS,
DuelChallenges_NORMAL2,
DuelChallenges_ZEUS,
DuelChallenges_GRENADEWARS,
DuelChallenges_HEADSHOT_ONLY,
MAX_DUEL_CHALLENGES
}
char g_szDuelChallenges[][] = {
"No Challenge",
"Low Gravity",
"Thirdperson",
"High FOV",
"Sonic Speed",
"Auto Bhop",
"Knife Duel",
"Normal Round",
"Vampire Round",
"5 HP Grenade Battle",
"Backwards Round",
"Normal Round",
"1 HP Zeus Round",
"Grenade Wars",
"Headshot Only Round",
};
Challenge_t g_CurrentChallenge = Challenge_NONE;
DuelChallenges_t g_CurrentDuelChallenge = DuelChallenges_NONE;
bool g_bVampireRound = false;
#define LoopAliveClients() for(int i = 1; i <= MaxClients; i++) if(IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i))
#define LoopDeadClients() for(int i = 1; i <= MaxClients; i++) if(IsClientInGame(i) && !IsPlayerAlive(i) && !IsFakeClient(i))
#define LoopAllClients() for(int i = 1; i <= MaxClients; i++) if(IsClientInGame(i) && !IsFakeClient(i))
public void OnPluginStart() {
RegConsoleCmd("sm_challenges", Command_OpenMenu);
RegConsoleCmd("sm_go", Command_EnableShoot);
// RegConsoleCmd("sm_cp", Command_OpenCheckpointMenu);
RegConsoleCmd("sm_set1v1", Command_Set1v1);
HookEvent("weapon_fire", Event_OnWeaponFire, EventHookMode_Post);
HookEvent("bomb_exploded", Event_OnBombExploded, EventHookMode_Post);
HookEvent("player_spawn", Event_OnPlayerSpawn, EventHookMode_Post);
HookEvent("player_jump", Event_OnPlayerJump, EventHookMode_Post);
HookEvent("round_start", Event_OnRoundStart, EventHookMode_Post);
HookEvent("round_end", Event_OnRoundEnd, EventHookMode_Pre);
HookEvent("player_hurt", Event_OnEventPlayerHurt, EventHookMode_Post);
HookEvent("buytime_ended", Event_OnBuyTimeEnded, EventHookMode_Post);
FindConVar("bot_quota").SetInt(0);
ServerCommand("bot_kick");
g_bCanShoot = false;
g_bVampireRound = false;
g_HudSyncRaceTimer = CreateHudSynchronizer();
}
public void OnPluginEnd() {
g_bCanShoot = false;
g_bVampireRound = false;
delete g_hRaceTimer;
}
public void OnMapStart() {
PrecacheModel(STICKER_MDL);
AddFileToDownloadsTable("models/inventory_items/sticker_inspect_chall_zwolof_fix.vvd");
AddFileToDownloadsTable("models/inventory_items/sticker_inspect_chall_zwolof_fix.mdl");
AddFileToDownloadsTable("models/inventory_items/sticker_inspect_chall_zwolof_fix.dx90.vtx");
AddFileToDownloadsTable("models/inventory_items/sticker_inspect_chall_zwolof_fix.phy");
g_CurrentChallenge = Challenge_NONE;
g_CurrentDuelChallenge = DuelChallenges_NONE;
g_iLaserSprite = PrecacheModel("materials/sprites/laserbeam.vmt");
ServerCommand("bot_kick");
for(int i = 1; i < MaxClients; i++) {
if(IsClientInGame(i)) {
OnClientPutInServer(i);
}
}
}
bool g_bHasTakenMolotovDamage[MAXPLAYERS+1] = {false, ...};
int g_iHealthBeforeMolotovDamage[MAXPLAYERS+1] = {100, ...};
int g_iHealthAfterMolotovDamage[MAXPLAYERS+1] = {100, ...};
int g_iMolotovDamageTaken[MAXPLAYERS+1] = {100, ...};
public void OnClientPutInServer(int client) {
if (IsFakeClient(client)) {
if (g_bBot1) {
g_iBot1 = client;
CS_RespawnPlayer(client);
int weapon = GivePlayerItem(client, "weapon_ak47");
EquipPlayerWeapon(client, weapon);
g_bBot1 = false;
if(IsPlayerAlive(g_bBot1)) {
Entity_SetMaxHealth(g_bBot1, 100000);
Entity_SetHealth(g_bBot1, 100000);
}
}
if (g_bBot2) {
g_iBot2 = client;
CS_RespawnPlayer(client);
int weapon = GivePlayerItem(client, "weapon_m4a1");
EquipPlayerWeapon(client, weapon);
g_bBot2 = false;
if(IsPlayerAlive(g_bBot2)) {
Entity_SetMaxHealth(g_bBot2, 100000);
Entity_SetHealth(g_bBot2, 100000);
}
}
}
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
SDKHook(client, SDKHook_WeaponSwitchPost, OnWeaponSwitchPost);
SDKHook(client, SDKHook_WeaponCanUse, OnWeaponCanUse);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3]) {
char classname[64];
if(!IsValidEntity(inflictor) || !GetEdictClassname(inflictor, classname, sizeof(classname))) {
return Plugin_Continue;
}
if(g_CurrentDuelChallenge == DuelChallenges_ONE_HP_GRENADE) {
char sClassName[128];
GetEntityClassname(inflictor, sClassName, sizeof(sClassName));
PrintToServer("[1v1] Inflictor: %s", sClassName);
if((StrContains(sClassName, "grenade", false) != -1)) {
float fOriginalDamage = damage;
int iHealth = GetEntProp(victim, Prop_Data, "m_iHealth");
if(iHealth <= 1) {
damage = fOriginalDamage;
return Plugin_Changed;
}
damage = 1.0;
// SetEntityHealth(victim, iHealth-1);
return Plugin_Changed;
}
}
if(StrEqual(classname, "inferno", false) && !g_bHasTakenMolotovDamage[victim]) {
CreateTimer(6.0, Timer_OnMolotovDamage, GetClientUserId(victim), TIMER_FLAG_NO_MAPCHANGE);
g_bHasTakenMolotovDamage[victim] = true;
return Plugin_Continue;
}
return Plugin_Continue;
}
public Action Timer_OnMolotovDamage(Handle tmr, any userid) {
int client = GetClientOfUserId(userid);
g_bHasTakenMolotovDamage[client] = false;
g_iMolotovDamageTaken[client] = (100 - GetClientHealth(client));
if(!IsPlayerAlive(client) || g_iMolotovDamageTaken[client] == 0) {
PrintToNadeKing(" \x10%N\x05 died from the molotov, rip.", client);
// CS_RespawnPlayer(client);
return Plugin_Stop;
}
PrintToChatAll(" \x10%N\x05 has taken \x10%d\x05 molotov damage.", client, g_iMolotovDamageTaken[client]);
return Plugin_Stop;
}
public Action Command_Set1v1(int client, int args) {
if(args > 1) {
return Plugin_Handled;
}
char sArg[16];
GetCmdArg(1, sArg, sizeof(sArg));
int count = StringToInt(sArg);
g_CurrentDuelChallenge = count;
PrintToChatAll(" \x10%N\x05 has set the duel challenge to \x10%d\x05.", client, count);
// CreateCheckpointMenu(client);
return Plugin_Handled;
}
public Action Command_OpenCheckpointMenu(int client, int args) {
if(args > 0) {
return Plugin_Handled;
}
// CreateCheckpointMenu(client);
return Plugin_Handled;
}
public Action Event_OnBuyTimeEnded(Event event, const char[] name, bool bDontBroadcast) {
// if(g_CurrentChallenge == Challenge_EMPTY_GUNS && !g_bCanShoot) {
// PrintToNadeKing(" \x05Buytime has ended. The round will begin in \x105\x05 seconds.");
// CreateTimer(5.0, Timer_StartShooting, _, TIMER_FLAG_NO_MAPCHANGE);
// }
}
public Action Timer_StartShooting(Handle tmr) {
g_bCanShoot = true;
PrintToChatAll(" \x10EMPTY YOUR GUNS!!!");
return Plugin_Stop;
}
public Action Event_OnEventPlayerHurt(Event event, const char[] name, bool bDontBroadcast) {
if(g_bVampireRound) {
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if (attacker == 0) {
return Plugin_Continue;
}
int attackerHealth = GetEntProp(attacker, Prop_Send, "m_iHealth");
int damage = GetEventInt(event, "dmg_health");
if(IsClientInGame(attacker) && IsPlayerAlive(attacker) && !IsFakeClient(attacker)) {
int GiveHealth = attackerHealth + damage;
SetEntityHealth(attacker, GiveHealth);
}
}
if(g_CurrentDuelChallenge == DuelChallenges_HEADSHOT_ONLY) {
int victim = GetClientOfUserId(GetEventInt(event, "userid"));
int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
int hitgroup = event.GetInt("hitgroup");
if(hitgroup != 1) {
SetEntityHealth(victim, 100);
}
return Plugin_Continue;
}
return Plugin_Continue;
}
public void Event_OnRoundEnd(Event event, const char[] name, bool bDontBroadcast) {
}
public Action Event_OnRoundStart(Event event, const char[] name, bool bDontBroadcast) {
// if(g_CurrentChallenge == Challenge_1VS1) {
// }
if(g_CurrentChallenge == Challenge_1VS1) {
g_CurrentDuelChallenge++;
FindConVar("mp_ignore_round_win_conditions").SetInt(0);
ResetDuelConVars();
int score_ct = GetTeamScore(CS_TEAM_CT);
int score_tt = GetTeamScore(CS_TEAM_T);
int winningTeam = score_ct > score_tt ? CS_TEAM_CT : CS_TEAM_T;
int teamScoreDiff = (winningTeam == CS_TEAM_CT) ? (score_ct - score_tt) : (score_tt - score_ct);
// PrintToChatAll(" \x05Difference: \x10%d", teamScoreDiff);
// if(teamScoreDiff < 0) {
// teamScoreDiff *= -1;
// }
if(teamScoreDiff > 2) {
LoopAliveClients() {
if(GetClientTeam(i) == winningTeam) {
SetEntityGravity(i, 2.0);
SetEntityHealth(i, 50);
PrintToChatAll(" \x05%N has been given a handicap for being in the lead.", i);
}
}
}
PrintToConsoleAll("============== NADEKING LAST TO LEAVE ==============");
PrintToConsoleAll("%s", g_szDuelChallenges[g_CurrentDuelChallenge]);
PrintToConsoleAll("====================================================");
PrintToChatAll(" \x10%s\x05", g_szDuelChallenges[g_CurrentDuelChallenge]);
switch(g_CurrentDuelChallenge) {
case DuelChallenges_GRAVITY: {
FindConVar("sv_gravity").SetInt(200);
}
case DuelChallenges_THIRDPERSON: {
FindConVar("sv_allow_thirdperson").SetInt(1);
LoopAliveClients() {
ClientCommand(i, "thirdperson");
}
}
case DuelChallenges_FOV: {
LoopAliveClients() {
SetEntProp(i, Prop_Send, "m_iDefaultFOV", 120);
SetEntProp(i, Prop_Send, "m_iFOV", 120);
}
}
case DuelChallenges_FASTAFBOII: {
LoopAliveClients() {
SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 2.0);
}
}
case DuelChallenges_AUTOBHOP: {
FindConVar("sv_enablebunnyhopping").SetInt(1);
FindConVar("sv_autobunnyhopping").SetInt(1);
}
case DuelChallenges_KNIFE: {
FindConVar("mp_weapons_allow_map_placed").SetInt(0);
LoopAliveClients() {
StripSlot(i, CS_SLOT_PRIMARY);
StripSlot(i, CS_SLOT_SECONDARY);
StripSlot(i, CS_SLOT_GRENADE);
int iKnife = GivePlayerItem(i, "weapon_knife");
}
}
// case DuelChallenges_WALLHACK: {
// PrintToChatAll("Wallhack is now enabled.");
// }
case DuelChallenges_VAMPIRE: {
g_bVampireRound = true;
}
case DuelChallenges_ONE_HP_GRENADE: {
FindConVar("sv_infinite_ammo").SetInt(2);
// FindConVar("mp_weapons_allow_map_placed").SetInt(0);
LoopAliveClients() {
StripSlot(i, CS_SLOT_PRIMARY);
StripSlot(i, CS_SLOT_SECONDARY);
StripSlot(i, CS_SLOT_GRENADE);
StripSlot(i, CS_SLOT_KNIFE);
SetEntityHealth(i, 5);
GivePlayerItem(i, "weapon_hegrenade");
}
}
case DuelChallenges_BACKWARDS: {
FindConVar("sv_accelerate").SetFloat(-5.0);
}
case DuelChallenges_ZEUS: {
FindConVar("sv_infinite_ammo").SetInt(1);
LoopAliveClients() {
StripSlot(i, CS_SLOT_PRIMARY);
StripSlot(i, CS_SLOT_SECONDARY);
StripSlot(i, CS_SLOT_GRENADE);
StripSlot(i, CS_SLOT_KNIFE);
SetEntityHealth(i, 1);
int taser = GivePlayerItem(i, "weapon_taser");
Weapon_SetClips(taser, 100, 100);
}
}
case DuelChallenges_GRENADEWARS: {
FindConVar("sv_infinite_ammo").SetInt(2);
LoopAliveClients() {
StripSlot(i, CS_SLOT_PRIMARY);
StripSlot(i, CS_SLOT_SECONDARY);
StripSlot(i, CS_SLOT_GRENADE);
StripSlot(i, CS_SLOT_KNIFE);
SetEntityHealth(i, 100);
GivePlayerItem(i, "weapon_hegrenade");
}
}
}
if(g_CurrentDuelChallenge == DuelChallenges_HEADSHOT_ONLY) {
g_CurrentDuelChallenge = DuelChallenges_NONE;
}
}
else if(g_CurrentChallenge == Challenge_KZRACE) {
float fZonePosition[3];
Zone_GetZonePosition(g_szKZRaceZoneNames[KZRaceZones_Start], false, fZonePosition);
fZonePosition[2] -= 32.0;
float vAng[3];
vAng[0] = 8.267547;
vAng[1] = -83.794586;
vAng[2] = 0.00;
LoopAliveClients() {
TeleportEntity(i, fZonePosition, vAng, NULL_VECTOR);
CreateCheckpointMenu(i);
// PrintToChat(i, " \x10Use \x05/cp\x10 to set checkpoints.");
}
}
return Plugin_Continue;
}
stock void StripSlot(int client, int slot) {
int weapon = -1;
while((weapon = GetPlayerWeaponSlot(client, slot)) != -1) {
RemovePlayerItem(client, weapon);
if(IsValidEntity(weapon)) {
AcceptEntityInput(weapon, "Kill");
}
}
}
public Action OnWeaponCanUse(int client, int weapon) {
char sClassName[128];
GetEdictClassname(weapon, sClassName, sizeof(sClassName));
// if(g_CurrentDuelChallenge == DuelChallenges_ONE_HP_GRENADE && !(StrContains(sClassName, "g", false) != -1)) {
// // PrintToChat(client, " \x10You cannot use this weapon\x08[\x05%s\x08].", sClassName);
// return Plugin_Handled;
// }
return Plugin_Continue;
}
void SetAmmoToOne(int client) {
PrintToChat(client, " \x10Ammo set to 1.");
int iActiveWpn = Client_GetActiveWeapon(client);
Weapon_SetPrimaryClip(iActiveWpn, 1);
Weapon_SetSecondaryClip(iActiveWpn, 1);
Weapon_SetPrimaryAmmoCount(iActiveWpn, 1);
Weapon_SetSecondaryAmmoCount(iActiveWpn, 120);
Weapon_SetClips(iActiveWpn, 1, 120);
Weapon_SetAmmoCounts(iActiveWpn, 1, 120);
}
public Action OnWeaponSwitchPost(int client, int weapon) {
if(g_CurrentChallenge == Challenge_1VS1 && !g_bVampireRound) {
// PrintToChat(client, " \x10You cannot use this weapon\x08[\x05%s\x08].", sClassName);
switch(g_CurrentDuelChallenge) {
case DuelChallenges_HEADSHOT_ONLY: {
SetAmmoToOne(client);
}
case DuelChallenges_ONE_HP_GRENADE: {
char sClassName[128];
GetEdictClassname(weapon, sClassName, sizeof(sClassName));
if(!(StrContains(sClassName, "grenade", false) != -1)) {
// PrintToChat(client, " \x10ONEHPDECOY: You cannot use this weapon.");
RemovePlayerItem(client, weapon);
AcceptEntityInput(weapon, "Kill");
ClientCommand(client, "slot4");
}
}
case DuelChallenges_ZEUS: {
char sClassName[128];
GetEdictClassname(weapon, sClassName, sizeof(sClassName));
PrintToChat(client, " \x10ZEUS: You cannot use %s", sClassName);
if(!(StrContains(sClassName, "taser", false) != -1)) {
RemovePlayerItem(client, weapon);
AcceptEntityInput(weapon, "Kill");
ClientCommand(client, "slot3");
}
}
case DuelChallenges_KNIFE: {
char sClassName[128];
GetEdictClassname(weapon, sClassName, sizeof(sClassName));
if(!IsWeaponKnife(sClassName)) {
// PrintToChat(client, " \x10OKNIFE DUEL: You cannot use this weapon.");
RemovePlayerItem(client, weapon);
AcceptEntityInput(weapon, "Kill");
ClientCommand(client, "slot3");
}
}
}
// PrintToChatAll("Current duelchallenge: \x10%d --> %s", g_CurrentDuelChallenge, g_szDuelChallenges[g_CurrentDuelChallenge]);
}
return Plugin_Continue;
}
bool IsWeaponKnife(const char[] sWeaponName) {
return (StrContains(sWeaponName, "knife", false) != -1 || StrContains(sWeaponName, "bayonet", false) != -1);
}
void ResetDuelConVars() {
g_bVampireRound = false;
FindConVar("sv_gravity").SetInt(800);
FindConVar("sv_allow_thirdperson").SetInt(1);
FindConVar("sv_accelerate").SetFloat(5.5);
FindConVar("sv_enablebunnyhopping").SetInt(0);
FindConVar("sv_autobunnyhopping").SetInt(0);
FindConVar("mp_halftime").SetInt(0);
FindConVar("mp_maxrounds").SetInt(36);
FindConVar("sv_infinite_ammo").SetInt(0);
FindConVar("mp_weapons_allow_map_placed").SetInt(1);
for(int i = 1; i <= MaxClients; i++) {
if(IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i)) {
ClientCommand(i, "firstperson");
SetEntProp(i, Prop_Send, "m_iDefaultFOV", 90);
SetEntProp(i, Prop_Send, "m_iFOV", 90);
SetEntPropFloat(i, Prop_Data, "m_flLaggedMovementValue", 1.0);
SetEntityGravity(i, 1.0);
}
}
}
public Action Event_OnPlayerJump(Event event, const char[] name, bool bDontBroadcast) {
int client = GetClientOfUserId(event.GetInt("userid"));
if(!Helpers_IsConnected(client)) {
return Plugin_Continue;
}
if(g_CurrentChallenge == Challenge_GUNTOSS) {
Entity_GetAbsOrigin(client, g_fGunTossJumpPosition[client]);
g_bDidGunTossJump[client] = true;
g_bGunHasLanded[client] = false;
// PrintToChatAll("%N jumped", client);
}
return Plugin_Continue;
}
public Action CS_OnCSWeaponDrop(int client, int weapon) {
if(IsValidEdict(weapon)) {
char sClassName[128];
GetEntityClassname(weapon, sClassName, sizeof(sClassName));
g_iGunTossDroppedEntity[client] = weapon;
CreateTimer(4.0, Timer_GunTossChecker, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
// PrintToChatAll(" \x10%N\x05 dropped \x10%s", client, sClassName);
}
}
public Action Timer_GunTossChecker(Handle tmr, any userid) {
int client = GetClientOfUserId(userid);
if(!Helpers_IsConnected(client)) {
return Plugin_Stop;
}
if(g_CurrentChallenge == Challenge_GUNTOSS && g_bDidGunTossJump[client]) {
if(IsValidEntity(g_iGunTossDroppedEntity[client])) {
if(!g_bGunHasLanded[client]) {
Entity_GetAbsOrigin(g_iGunTossDroppedEntity[client], g_fGunTossDroppedOrigin[client]);
float fThrowDistance = GetVectorDistance(g_fGunTossJumpPosition[client], g_fGunTossDroppedOrigin[client]);
PrintToChatAll(" \x05%N has tossed their gun! (distance: %.2f)", client, fThrowDistance);
float fNewJumpOrigin[3], fNewWeaponOrigin[3];
CopyVector(g_fGunTossJumpPosition[client], fNewJumpOrigin);
fNewJumpOrigin[2] += 32;
CopyVector(g_fGunTossDroppedOrigin[client], fNewWeaponOrigin);
fNewWeaponOrigin[2] += 32;
// Draw beam where the gun landed
TE_SetupBeamPoints(g_fGunTossDroppedOrigin[client], fNewWeaponOrigin, g_iLaserSprite, 0, 0, 0, 1200.0, 3.0, 3.0, 1, 0.0, view_as<int>({0, 255, 0, 255}), 0);
TE_SendToAll();
float fMiddleOfVector[3];
GetMiddleOfVector(fNewWeaponOrigin, fNewJumpOrigin, fMiddleOfVector);
fMiddleOfVector[2] += 16.0;
char sName[128];
GetClientName(client, sName, sizeof(sName));
int iTextEnt = CreateStickerText(sName);
TeleportEntity(iTextEnt, fMiddleOfVector, Float:{0.0, 0.0, 0.0}, NULL_VECTOR);
// Draw beam from jump position
TE_SetupBeamPoints(g_fGunTossJumpPosition[client], fNewJumpOrigin, g_iLaserSprite, 0, 0, 0, 1200.0, 3.0, 3.0, 1, 0.0, view_as<int>({255, 0, 0, 255}), 0);
TE_SendToAll();
// Draw line from jump position to weapon position
TE_SetupBeamPoints(fNewWeaponOrigin, fNewJumpOrigin, g_iLaserSprite, 0, 0, 0, 1200.0, 3.0, 3.0, 1, 0.0, view_as<int>({0, 0, 255, 255}), 0);
TE_SendToAll();
g_bGunHasLanded[client] = true;
g_bDidGunTossJump[client] = false;
g_iGunTossDroppedEntity[client] = -1;
}
}
}
return Plugin_Stop;
}
void GetMiddleOfVector(float vec[3], float other[3], float fResultVec[3]) {
fResultVec[0] = (vec[0] + other[0]) / 2.0;
fResultVec[1] = (vec[1] + other[1]) / 2.0;
fResultVec[2] = (vec[2] + other[2]) / 2.0;
}
// GUNTOSS RIGHT POS TO WALL: 504.00, -863.00, -255.91
// GUNTOSS LEFT POS TO WALL: -504.00, -939.00, -255.91
public Action Event_OnPlayerSpawn(Event event, const char[] name, bool bDontBroadcast) {
int client = GetClientOfUserId(event.GetInt("userid"));
if (!Helpers_IsConnected(client)) {
return Plugin_Continue;
}
ShowOverlay(client, "", 1.0);
return Plugin_Continue;
}
public void Event_OnBombExploded(Event event, const char[] name, bool bDontBroadcast) {
if(g_CurrentChallenge == Challenge_BOMB_DAMAGE) {
CreateTimer(2.0, Timer_CheckAliveBombExplosion, _, TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action Timer_CheckAliveBombExplosion(Handle tmr, any data) {
ArrayList bombSurvivalLeaderboard = new ArrayList(sizeof(IBombSurvivor_t));
IBombSurvivor_t bombSurvivor;
for(int i = 1; i <= MaxClients; i++) {
if(Helpers_IsConnected(i) && IsPlayerAlive(i)) {
bombSurvivor.clientIdx = i;
int initialHealth = 100;
// int damageTaken = initialHealth - GetClientHealth(i);
int damageTaken = GetClientHealth(i);
// bombSurvivor.damage = damageTaken;
bombSurvivor.damage = damageTaken;
PrintToConsoleAll("[BOMB] %N survived with %d HEALTH", i, damageTaken);
bombSurvivalLeaderboard.PushArray(bombSurvivor, sizeof(IBombSurvivor_t));
}
}
bombSurvivalLeaderboard.SortCustom(BombTimerSortCallback);
int len = bombSurvivalLeaderboard.Length;
Panel panel = new Panel();
char sBuffer[4096], sName[128];
for(int i = 0; i < len; i++) {
bombSurvivalLeaderboard.GetArray(i, bombSurvivor, sizeof(IBombSurvivor_t));
GetClientName(bombSurvivor.clientIdx, sName, sizeof(sName));
int nameLength = strlen(sName);
for(int j = nameLength; j < 16; j++) {
StrCat(sName, sizeof(sName), " ");
}
sName[15] = '\0';
FormatEx(sBuffer, sizeof(sBuffer), "%s%dHP | %s\n", sBuffer, bombSurvivor.damage, sName);
PrintToChatAll(" \x05%N took \x10%d\x05 damage", bombSurvivor.clientIdx, bombSurvivor.damage);
}
panel.SetTitle(sBuffer);
panel.DrawItem("Close");
for(int i = 1; i <= MaxClients; i++) {
if(Helpers_IsConnected(i) && IsPlayerAlive(i)) {
panel.Send(i, BombSurvivalPanelHandler, MENU_TIME_FOREVER);
}
}
delete panel;
delete bombSurvivalLeaderboard;
return Plugin_Stop;
}
public int BombSurvivalPanelHandler(Menu menu, MenuAction action, int client, int param2) {
if (action == MenuAction_Select) {
PrintToConsole(client, "You selected item: %d", param2);
}
else if (action == MenuAction_Cancel) {
PrintToServer("Client %d's menu was cancelled. Reason: %d", client, param2);
}
}
public int BombTimerSortCallback(int index1, int index2, Handle array, Handle hndl) {
IBombSurvivor_t first; IBombSurvivor_t second;
GetArrayArray(array, index1, first, sizeof(IBombSurvivor_t));
GetArrayArray(array, index2, second, sizeof(IBombSurvivor_t));
return (first.damage > second.damage);
}
public Action Event_OnWeaponFire(Event event, const char[] name, bool bDontBroadcast) {
char sWeapon[128];
event.GetString("weapon", sWeapon, sizeof(sWeapon));
int client = GetClientOfUserId(event.GetInt("userid"));
if (!Helpers_IsConnected(client)) {
return Plugin_Continue;
}
if(g_CurrentDuelChallenge == DuelChallenges_HEADSHOT_ONLY) {
StripSlot(client, CS_SLOT_GRENADE);
GivePlayerItem(client, "weapon_decoy");
ClientCommand(client, "slot4");
}
if(g_CurrentDuelChallenge == DuelChallenges_HEADSHOT_ONLY) {
SetAmmoToOne(client);
}
if(g_CurrentChallenge == Challenge_EMPTY_GUNS) {
int iActiveWpn = Client_GetActiveWeapon(client);
if(iActiveWpn == INVALID_ENT_REFERENCE) {
return Plugin_Continue;
}
int primary = Weapon_GetPrimaryClip(iActiveWpn);
int reserved = GetEntProp(iActiveWpn, Prop_Send, "m_iPrimaryReserveAmmoCount");
// stupid.. when gun is empty, for some reason it doesn't send the reserve ammo count.
if(primary == 1 && reserved == 0) {
PrintToChatAll(" \x05%N has used their last bullet!", client);
}
// PrintToConsoleAll(" [NadeMod] Primary: %d", primary);
// PrintToConsoleAll(" [NadeMod] Reserved: %d", reserved);
}
return Plugin_Continue;
}
int g_CurrentValue[3];
int g_ExpectedValue[3];
int g_FadeSpeed = 2;
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int&weapon) {
static int changedButtons[MAXPLAYERS+1] = 0;
// if(g_CurrentChallenge == Challenge_GUNTOSS && g_bDidGunTossJump[client]) {
// if(IsValidEntity(g_iGunTossDroppedEntity[client])) {
// bool bIsWeaponOnGround = (GetEntityFlags(g_iGunTossDroppedEntity[client]) & FL_ONGROUND);
// // PrintToChatAll("Entity is %svalid", (IsValidEntity(g_iGunTossDroppedEntity[client]) ? "" : "not "));
// // PrintToChatAll("(GetEntityFlags(g_iGunTossDroppedEntity[client]) & FL_ONGROUND): %s", bIsWeaponOnGround ? "true" : "false");
// // PrintToChatAll("bIsWeaponOnGround: %s", bIsWeaponOnGround ? "true" : "false");
// if(bIsWeaponOnGround && !g_bGunHasLanded[client]) {
// g_bGunHasLanded[client] = true;
// g_bDidGunTossJump[client] = false;
// Entity_GetAbsOrigin(g_iGunTossDroppedEntity[client], g_fGunTossDroppedOrigin[client]);
// PrintToChatAll(" \x05%N has tossed their gun!", client);
// float fNewJumpOrigin[3], fNewWeaponOrigin[3];
// CopyVector(g_fGunTossJumpPosition[client], fNewJumpOrigin);
// fNewJumpOrigin[2] += 32;
// CopyVector(g_fGunTossDroppedOrigin[client], fNewWeaponOrigin);
// fNewWeaponOrigin[2] += 32;
// TE_SetupBeamPoints(g_fGunTossDroppedOrigin[client], fNewWeaponOrigin, g_iLaserSprite, 0, 0, 0, 1200.0, 3.0, 3.0, 1, 0.0, view_as<int>({0, 255, 0, 255}), 0);
// TE_SendToAll();
// TE_SetupBeamPoints(g_fGunTossJumpPosition[client], fNewJumpOrigin, g_iLaserSprite, 0, 0, 0, 1200.0, 3.0, 3.0, 1, 0.0, view_as<int>({255, 0, 0, 255}), 0);
// TE_SendToAll();
// }
// }
// }
if(g_CurrentChallenge == Challenge_EMPTY_GUNS && !g_bCanShoot) {
if(buttons & IN_ATTACK) {
buttons &= ~IN_ATTACK;
changedButtons[client]++;
}
if(buttons & IN_ATTACK2) {
buttons &= ~IN_ATTACK2;
changedButtons[client]++;
}
if(changedButtons[client] > 0) {
changedButtons[client] = 0;
return Plugin_Changed;
}
}
if(g_CurrentChallenge == Challenge_BOTSOUND && IsFakeClient(client) && IsPlayerAlive(client)) {
int changedButtons = 0;
if(g_iBotShoot1 && client == g_iBot1) {
buttons |= IN_ATTACK;
changedButtons++;
PrintToConsoleAll("[BOT] g_iBot1 is shooting", client);
}
if(g_iBotShoot2 && client == g_iBot2) {
buttons |= IN_ATTACK;
changedButtons++;
PrintToConsoleAll("[BOT] g_iBot2 is shooting", client);
}
if(changedButtons > 0) {
return Plugin_Changed;
}
return Plugin_Continue;
}
if(g_CurrentChallenge == Challenge_KZRACE && Helpers_IsConnected(client) && IsPlayerAlive(client)) {
for(int idx; idx < 3; idx++) {
if (g_ExpectedValue[idx] > g_CurrentValue[idx]) {
if(g_CurrentValue[idx] + g_FadeSpeed > g_ExpectedValue[idx])
g_CurrentValue[idx] = g_ExpectedValue[idx];
else
g_CurrentValue[idx] += g_FadeSpeed;
}
if(g_ExpectedValue[idx] < g_CurrentValue[idx]) {
if(g_CurrentValue[idx] - g_FadeSpeed < g_ExpectedValue[idx])
g_CurrentValue[idx] = g_ExpectedValue[idx];
else
g_CurrentValue[idx] -= g_FadeSpeed;
}
if(g_ExpectedValue[idx] == g_CurrentValue[idx]) {
g_ExpectedValue[idx] = GetRandomInt(0, 255);
}
}
char sHex[32];
FormatEx(sHex, sizeof(sHex), "#%02X%02X%02X", g_CurrentValue[0], g_CurrentValue[1], g_CurrentValue[2]);
int iCurrentTime = GetTime();
char sTimer[128];
if(g_iKZRaceStartTime[client] == -1) {
FormatEx(sTimer, sizeof(sTimer), "<font color=\"%s\">Start Zone</font>", sHex);
}
else if(g_bDidFinishKZCourse[client]) {
FormatEx(sTimer, sizeof(sTimer), "<font color=\"%s\">End Zone</font>\n", sHex);
FormatEx(sTimer, sizeof(sTimer), "%sYou finished in <font color=\"%s\">%d</font> seconds!", sTimer, sHex, g_iTimeToCompleteKZRace[client]);
}
else {
FormatEx(sTimer, sizeof(sTimer), "<font class=\"fontSize-l\" face=\"verdana\">Time: %d</font>", (iCurrentTime - g_iKZRaceStartTime[client]));
}
PrintHintText(client, sTimer);
}
return Plugin_Continue;
}
public Action Command_EnableShoot(int client, int args) {
if(args > 1) {
PrintToChat(client, "Usage: sm_go");
return Plugin_Handled;
}