forked from dataviruset/sm-hosties
/
lastrequest.sp
6103 lines (5673 loc) · 217 KB
/
lastrequest.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
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
/*
* SourceMod Hosties Project
* by: SourceMod Hosties Dev Team
*
* This file is part of the SM Hosties project.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Include files
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>
#include <hosties>
#include <lastrequest>
// Compiler options
#pragma semicolon 1
// Global variables
new bool:g_bIsLRAvailable = true;
new bool:g_bRoundInProgress = true;
new bool:g_bListenersAdded = false;
new bool:g_bAnnouncedThisRound = false;
new bool:g_bInLastRequest[MAXPLAYERS+1];
new bool:g_bIsARebel[MAXPLAYERS+1];
new Handle:gH_BuildLR[MAXPLAYERS+1];
new LastRequest:g_LRLookup[MAXPLAYERS+1];
new g_LR_PermissionLookup[MAXPLAYERS+1];
new Handle:g_GunTossTimer = INVALID_HANDLE;
new Handle:g_ChickenFightTimer = INVALID_HANDLE;
new Handle:g_DodgeballTimer = INVALID_HANDLE;
new Handle:g_BeaconTimer = INVALID_HANDLE;
new Handle:g_RaceTimer = INVALID_HANDLE;
new Handle:g_DelayLREnableTimer = INVALID_HANDLE;
new Handle:g_BeerGogglesTimer = INVALID_HANDLE;
new Handle:g_CountdownTimer = INVALID_HANDLE;
new Handle:g_FarthestJumpTimer = INVALID_HANDLE;
new Handle:gH_Frwd_LR_CleanUp = INVALID_HANDLE;
new Handle:gH_Frwd_LR_Start = INVALID_HANDLE;
new Handle:gH_Frwd_LR_Process = INVALID_HANDLE;
new Handle:gH_Frwd_LR_StartGlobal = INVALID_HANDLE;
new Handle:gH_Frwd_LR_Available = INVALID_HANDLE;
new BeamSprite = -1;
new HaloSprite = -1;
new LaserSprite = -1;
new LaserHalo = -1;
new greenColor[] = {15, 255, 15, 255};
new redColor[] = {255, 25, 15, 255};
new blueColor[] = {50, 75, 255, 255};
new greyColor[] = {128, 128, 128, 255};
new yellowColor[] = {255, 255, 0, 255};
new g_Offset_Health = -1;
new g_Offset_Armor = -1;
new g_Offset_Clip1 = -1;
new g_Offset_Ammo = -1;
new g_Offset_FOV = -1;
new g_Offset_ActiveWeapon = -1;
new g_Offset_GroundEnt = -1;
new g_Offset_DefFOV = -1;
new g_Offset_PunchAngle = -1;
new g_Offset_SecAttack = -1;
new Handle:gH_DArray_LastRequests = INVALID_HANDLE;
new Handle:gH_DArray_LR_Partners = INVALID_HANDLE;
new Handle:gH_DArray_Beacons = INVALID_HANDLE;
new Handle:gH_DArray_LR_CustomNames = INVALID_HANDLE;
new Handle:gH_Cvar_LR_KnifeFight_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Shot4Shot_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_GunToss_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_ChickenFight_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_HotPotato_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Dodgeball_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_NoScope_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_RockPaperScissors_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Rebel_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Mag4Mag_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Race_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_RussianRoulette_On = INVALID_HANDLE;
new Handle:gH_Cvar_LR_JumpContest_On = INVALID_HANDLE;
new Handle:gH_Cvar_Announce_Delay_Enable = INVALID_HANDLE;
new Handle:gH_Cvar_LR_HotPotato_Mode = INVALID_HANDLE;
new Handle:gH_Cvar_MaxPrisonersToLR = INVALID_HANDLE;
new Handle:gH_Cvar_RebelAction = INVALID_HANDLE;
new Handle:gH_Cvar_RebelHandling = INVALID_HANDLE;
new Handle:gH_Cvar_SendGlobalMsgs = INVALID_HANDLE;
new Handle:gH_Cvar_ColorRebels = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Enable = INVALID_HANDLE;
new Handle:gH_Cvar_LR_MenuTime = INVALID_HANDLE;
new Handle:gH_Cvar_LR_KillTimeouts = INVALID_HANDLE;
new Handle:gH_Cvar_ColorRebels_Red = INVALID_HANDLE;
new Handle:gH_Cvar_ColorRebels_Blue = INVALID_HANDLE;
new Handle:gH_Cvar_ColorRebels_Green = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Beacons = INVALID_HANDLE;
new Handle:gH_Cvar_LR_HelpBeams = INVALID_HANDLE;
new Handle:gH_Cvar_LR_HelpBeams_Distance = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Beacon_Interval = INVALID_HANDLE;
new Handle:gH_Cvar_RebelOnImpact = INVALID_HANDLE;
new Handle:gH_Cvar_LR_ChickenFight_Slay = INVALID_HANDLE;
new Handle:gH_Cvar_LR_ChickenFight_C_Blue = INVALID_HANDLE;
new Handle:gH_Cvar_LR_ChickenFight_C_Red = INVALID_HANDLE;
new Handle:gH_Cvar_LR_ChickenFight_C_Green = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Dodgeball_CheatCheck = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Dodgeball_SpawnTime = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Dodgeball_Gravity = INVALID_HANDLE;
new Handle:gH_Cvar_LR_HotPotato_MaxTime = INVALID_HANDLE;
new Handle:gH_Cvar_LR_HotPotato_MinTime = INVALID_HANDLE;
new Handle:gH_Cvar_LR_HotPotato_Speed = INVALID_HANDLE;
new Handle:gH_Cvar_LR_NoScope_Sound = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Sound = INVALID_HANDLE;
new Handle:gH_Cvar_LR_NoScope_Weapon = INVALID_HANDLE;
new Handle:gH_Cvar_LR_S4S_DoubleShot = INVALID_HANDLE;
new Handle:gH_Cvar_LR_GunToss_MarkerMode = INVALID_HANDLE;
new Handle:gH_Cvar_LR_GunToss_StartMode = INVALID_HANDLE;
new Handle:gH_Cvar_LR_GunToss_ShowMeter = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Race_AirPoints = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Race_NotifyCTs = INVALID_HANDLE;
new Handle:gH_Cvar_Announce_CT_FreeHit = INVALID_HANDLE;
new Handle:gH_Cvar_Announce_LR = INVALID_HANDLE;
new Handle:gH_Cvar_Announce_Rebel = INVALID_HANDLE;
new Handle:gH_Cvar_Announce_RebelDown = INVALID_HANDLE;
new Handle:gH_Cvar_Announce_Weapon_Attack = INVALID_HANDLE;
new Handle:gH_Cvar_Announce_HotPotato_Eqp = INVALID_HANDLE;
new Handle:gH_Cvar_Announce_Shot4Shot = INVALID_HANDLE;
new Handle:gH_Cvar_LR_NonContKiller_Action = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Delay_Enable_Time = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Damage = INVALID_HANDLE;
new Handle:gH_Cvar_LR_NoScope_Delay = INVALID_HANDLE;
new Handle:gH_Cvar_LR_ChickenFight_Rebel = INVALID_HANDLE;
new Handle:gH_Cvar_LR_HotPotato_Rebel = INVALID_HANDLE;
new Handle:gH_Cvar_LR_KnifeFight_Rebel = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Rebel_MaxTs = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Rebel_MinCTs = INVALID_HANDLE;
new Handle:gH_Cvar_LR_M4M_MagCapacity = INVALID_HANDLE;
new Handle:gH_Cvar_LR_KnifeFight_LowGrav = INVALID_HANDLE;
new Handle:gH_Cvar_LR_KnifeFight_HiSpeed = INVALID_HANDLE;
new Handle:gH_Cvar_LR_KnifeFight_Drunk = INVALID_HANDLE;
new Handle:gH_Cvar_LR_Beacon_Sound = INVALID_HANDLE;
new Handle:gH_Cvar_LR_AutoDisplay = INVALID_HANDLE;
new Handle:gH_Cvar_LR_BlockSuicide = INVALID_HANDLE;
new Handle:gH_Cvar_LR_VictorPoints = INVALID_HANDLE;
new g_iLastCT_FreeAttacker = -1;
new gShadow_LR_KnifeFight_On = -1;
new gShadow_LR_Shot4Shot_On = -1;
new gShadow_LR_GunToss_On = -1;
new gShadow_LR_ChickenFight_On = -1;
new gShadow_LR_HotPotato_On = -1;
new gShadow_LR_Dodgeball_On = -1;
new gShadow_LR_NoScope_On = -1;
new gShadow_LR_RockPaperScissors_On = -1;
new gShadow_LR_Rebel_On = -1;
new gShadow_LR_Mag4Mag_On = -1;
new gShadow_LR_Race_On = -1;
new gShadow_LR_RussianRoulette_On = -1;
new gShadow_LR_JumpContest_On = -1;
new Float:gShadow_LR_Beacon_Interval = -1.0;
new bool:gShadow_LR_ChickenFight_Slay = false;
new gShadow_LR_ChickenFight_C_Blue = -1;
new gShadow_LR_ChickenFight_C_Red = -1;
new gShadow_LR_ChickenFight_C_Green = -1;
new bool:gShadow_LR_Dodgeball_CheatCheck = false;
new Float:gShadow_LR_Dodgeball_SpawnTime = -1.0;
new Float:gShadow_LR_Dodgeball_Gravity = -1.0;
new gShadow_RebelOnImpact = -1;
new gShadow_ColorRebels_Red = -1;
new gShadow_ColorRebels_Blue = -1;
new gShadow_ColorRebels_Green = -1;
new gShadow_LR_HotPotato_Mode = -1;
new gShadow_MaxPrisonersToLR = -1;
new gShadow_RebelAction = -1;
new gShadow_RebelHandling = -1;
new gShadow_SendGlobalMsgs = -1;
new gShadow_ColorRebels = -1;
new bool:gShadow_LR_Enable = false;
new gShadow_LR_MenuTime = 0;
new bool:gShadow_LR_AutoDisplay = false;
new bool:gShadow_LR_Beacons = false;
new bool:gShadow_LR_HelpBeams = false;
new Float:gShadow_LR_HelpBeams_Distance = -1.0;
new Float:gShadow_LR_HotPotato_MaxTime = -1.0;
new Float:gShadow_LR_HotPotato_MinTime = -1.0;
new Float:gShadow_LR_HotPotato_Speed = -1.0;
new bool:gShadow_LR_S4S_DoubleShot;
new bool:gShadow_LR_NonContKiller_Action;
new gShadow_LR_GunToss_MarkerMode = -1;
new gShadow_LR_GunToss_StartMode = -1;
new gShadow_LR_GunToss_ShowMeter = -1;
new bool:gShadow_LR_Race_AirPoints = false;
new bool:gShadow_LR_Race_NotifyCTs = false;
new gShadow_Announce_CT_FreeHit = 0;
new bool:gShadow_Announce_LR = false;
new bool:gShadow_Announce_Rebel = false;
new bool:gShadow_Announce_RebelDown = false;
new bool:gShadow_Announce_HotPotato_Eqp = false;
new bool:gShadow_Announce_Weapon_Attack = false;
new bool:gShadow_Announce_Shot4Shot = false;
new String:gShadow_LR_NoScope_Sound[PLATFORM_MAX_PATH];
new String:gShadow_LR_Sound[PLATFORM_MAX_PATH];
new gShadow_LR_NoScope_Weapon = -1;
new bool:gShadow_Announce_Delay_Enable = false;
new Float:gShadow_LR_Delay_Enable_Time = 0.0;
new bool:g_bPushedToMenu = false;
new bool:gShadow_LR_Damage = false;
new gShadow_LR_NoScope_Delay = -1;
new gShadow_LR_ChickenFight_Rebel = -1;
new gShadow_LR_HotPotato_Rebel = -1;
new gShadow_LR_KnifeFight_Rebel = -1;
new gShadow_LR_Rebel_MaxTs = -1;
new gShadow_LR_Rebel_MinCTs = -1;
new gShadow_LR_M4M_MagCapacity = -1;
new Float:gShadow_LR_KnifeFight_LowGrav = -1.0;
new Float:gShadow_LR_KnifeFight_HiSpeed = -1.0;
new gShadow_LR_KnifeFight_Drunk = -1;
new String:gShadow_LR_Beacon_Sound[PLATFORM_MAX_PATH];
new bool:gShadow_LR_KillTimeouts = false;
new bool:gShadow_LR_BlockSuicide = false;
new gShadow_LR_VictorPoints = -1;
// Autostart
new LastRequest:g_selection[MAXPLAYERS + 1];
new g_LR_Player_Guard[MAXPLAYERS + 1] = 0;
// Custom types local to the plugin
enum NoScopeWeapon
{
NSW_AWP = 0,
NSW_Scout,
NSW_SG550,
NSW_G3SG1
};
enum PistolWeapon
{
Pistol_Deagle = 0,
Pistol_P228,
Pistol_Glock,
Pistol_FiveSeven,
Pistol_Dualies,
Pistol_USP,
Pistol_Tec9,
Pistol_CZ75,
Pistol_USPS,
Pistol_Revolver
};
enum KnifeType
{
Knife_Vintage = 0,
Knife_Drunk,
Knife_LowGrav,
Knife_HiSpeed,
Knife_Drugs,
Knife_ThirdPerson,
Knife_Throwing,
Knife_Flying
};
enum JumpContest
{
Jump_TheMost = 0,
Jump_Farthest,
Jump_BrinkOfDeath
};
new String:g_sLastRequestPhrase[LastRequest][MAX_DISPLAYNAME_SIZE];
LastRequest_OnPluginStart()
{
// Populate translation entries
// no longer pulling LANG_SERVER
g_sLastRequestPhrase[LR_KnifeFight] = "Knife Fight";
g_sLastRequestPhrase[LR_Shot4Shot] = "Shot4Shot";
g_sLastRequestPhrase[LR_GunToss] = "Gun Toss";
g_sLastRequestPhrase[LR_ChickenFight] = "Chicken Fight";
g_sLastRequestPhrase[LR_HotPotato] = "Hot Potato";
g_sLastRequestPhrase[LR_Dodgeball] = "Dodgeball";
g_sLastRequestPhrase[LR_NoScope] = "No Scope Battle";
g_sLastRequestPhrase[LR_RockPaperScissors] = "Rock Paper Scissors";
g_sLastRequestPhrase[LR_Rebel] = "Rebel!";
g_sLastRequestPhrase[LR_Mag4Mag] = "Mag4Mag";
g_sLastRequestPhrase[LR_Race] = "Race";
g_sLastRequestPhrase[LR_RussianRoulette] = "Russian Roulette";
g_sLastRequestPhrase[LR_JumpContest] = "Jumping Contest";
// Gather all offsets
g_Offset_Health = FindSendPropOffs("CBasePlayer", "m_iHealth");
if (g_Offset_Health == -1)
{
SetFailState("Unable to find offset for health.");
}
g_Offset_Armor = FindSendPropOffs("CCSPlayer", "m_ArmorValue");
if (g_Offset_Armor == -1)
{
SetFailState("Unable to find offset for armor.");
}
g_Offset_Clip1 = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1");
if (g_Offset_Clip1 == -1)
{
SetFailState("Unable to find offset for clip.");
}
if (g_Game != Game_CSGO)
{
g_Offset_Ammo = FindSendPropInfo("CCSPlayer", "m_iAmmo");
if (g_Offset_Ammo == -1)
{
SetFailState("Unable to find offset for ammo.");
}
}
g_Offset_FOV = FindSendPropOffs("CBasePlayer", "m_iFOV");
if (g_Offset_FOV == -1)
{
SetFailState("Unable to find offset for FOV.");
}
g_Offset_ActiveWeapon = FindSendPropInfo("CCSPlayer", "m_hActiveWeapon");
if (g_Offset_ActiveWeapon == -1)
{
SetFailState("Unable to find offset for active weapon.");
}
g_Offset_GroundEnt = FindSendPropOffs("CBasePlayer", "m_hGroundEntity");
if (g_Offset_GroundEnt == -1)
{
SetFailState("Unable to find offset for ground entity.");
}
g_Offset_DefFOV = FindSendPropOffs("CBasePlayer", "m_iDefaultFOV");
if (g_Offset_DefFOV == -1)
{
SetFailState("Unable to find offset for default FOV.");
}
if (g_Game == Game_CSS)
{
g_Offset_PunchAngle = FindSendPropInfo("CBasePlayer", "m_vecPunchAngle");
}
else if (g_Game == Game_CSGO)
{
g_Offset_PunchAngle = FindSendPropInfo("CBasePlayer", "m_aimPunchAngle");
}
if (g_Offset_PunchAngle == -1)
{
SetFailState("Unable to find offset for punch angle.");
}
g_Offset_SecAttack = FindSendPropOffs("CBaseCombatWeapon", "m_flNextSecondaryAttack");
if (g_Offset_SecAttack == -1)
{
SetFailState("Unable to find offset for next secondary attack.");
}
// Console commands
RegConsoleCmd("sm_lr", Command_LastRequest);
RegConsoleCmd("sm_lastrequest", Command_LastRequest);
// Admin commands
RegAdminCmd("sm_stoplr", Command_CancelLR, ADMFLAG_SLAY);
RegAdminCmd("sm_cancellr", Command_CancelLR, ADMFLAG_SLAY);
RegAdminCmd("sm_abortlr", Command_CancelLR, ADMFLAG_SLAY);
// Events hooks
HookEvent("round_start", LastRequest_RoundStart);
HookEvent("round_end", LastRequest_RoundEnd);
HookEvent("player_hurt", LastRequest_PlayerHurt);
HookEvent("player_death", LastRequest_PlayerDeath);
HookEvent("bullet_impact", LastRequest_BulletImpact);
HookEvent("player_disconnect", LastRequest_PlayerDisconnect);
HookEvent("weapon_zoom", LastRequest_WeaponZoom, EventHookMode_Pre);
HookEvent("weapon_fire", LastRequest_WeaponFire);
HookEvent("player_jump", LastRequest_PlayerJump);
HookEvent("player_spawn", LastRequest_PlayerSpawn);
// Make global arrays
gH_DArray_LastRequests = CreateArray(2);
gH_DArray_Beacons = CreateArray();
gH_DArray_LR_CustomNames = CreateArray(MAX_DISPLAYNAME_SIZE);
gH_DArray_LR_Partners = CreateArray(10);
// array structure:
// -- block 0 -> LastRequest type
// -- block 1 -> Prisoner client index
// -- block 2 -> Guard client index
// -- block 3 -> LR Data (Prisoner)
// -- block 4 -> LR Data (Guard)
// -- block 5 -> LR Data (Global 1)
// -- block 6 -> LR Data (Global 2)
// -- block 7 -> LR Data (Global 3)
// -- block 8 -> LR Data (Global 4)
// -- block 9 -> Handle to Additional Data
// Create forwards for custom LR plugins
gH_Frwd_LR_Available = CreateGlobalForward("OnAvailableLR", ET_Ignore, Param_Cell);
gH_Frwd_LR_CleanUp = CreateForward(ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
gH_Frwd_LR_Start = CreateForward(ET_Ignore, Param_Cell, Param_Cell);
gH_Frwd_LR_Process = CreateForward(ET_Event, Param_Cell, Param_Cell);
gH_Frwd_LR_StartGlobal = CreateGlobalForward("OnStartLR", ET_Ignore, Param_Cell, Param_Cell, Param_Cell);
// Register cvars
gH_Cvar_LR_Enable = CreateConVar("sm_hosties_lr", "1", "Enable or disable Last Requests (the !lr command): 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_Enable = true;
gH_Cvar_LR_MenuTime = CreateConVar("sm_hosties_lr_menutime", "0", "Sets the time the LR menu is displayed (in seconds)", 0, true, 0.0);
gShadow_LR_MenuTime = 0;
gH_Cvar_LR_KillTimeouts = CreateConVar("sm_hosties_lr_killtimeouts", "0", "Kills Ts who timeout the LR menu and controls whether the exit button is displayed: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_KillTimeouts = false;
gH_Cvar_LR_KnifeFight_On = CreateConVar("sm_hosties_lr_kf_enable", "1", "Enable LR Knife Fight: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_KnifeFight_On = true;
gH_Cvar_LR_Shot4Shot_On = CreateConVar("sm_hosties_lr_s4s_enable", "1", "Enable LR Shot4Shot: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_Shot4Shot_On = true;
gH_Cvar_LR_GunToss_On = CreateConVar("sm_hosties_lr_gt_enable", "1", "Enable LR Gun Toss: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_GunToss_On = true;
gH_Cvar_LR_ChickenFight_On = CreateConVar("sm_hosties_lr_cf_enable", "1", "Enable LR Chicken Fight: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_ChickenFight_On = true;
gH_Cvar_LR_HotPotato_On = CreateConVar("sm_hosties_lr_hp_enable", "1", "Enable LR Hot Potato: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_HotPotato_On = true;
gH_Cvar_LR_Dodgeball_On = CreateConVar("sm_hosties_lr_db_enable", "1", "Enable LR Dodgeball: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_Dodgeball_On = true;
gH_Cvar_LR_NoScope_On = CreateConVar("sm_hosties_lr_ns_enable", "1", "Enable LR No Scope Battle: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_NoScope_On = true;
gH_Cvar_LR_RockPaperScissors_On = CreateConVar("sm_hosties_lr_rps_enable", "1", "Enable LR Rock Paper Scissors: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_RockPaperScissors_On = true;
gH_Cvar_LR_Rebel_On = CreateConVar("sm_hosties_lr_rebel_on", "1", "Enables the LR Rebel: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_Rebel_On = true;
gH_Cvar_LR_Mag4Mag_On = CreateConVar("sm_hosties_lr_mag4mag_on", "1", "Enables the LR Magazine4Magazine: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_Mag4Mag_On = true;
gH_Cvar_LR_Race_On = CreateConVar("sm_hosties_lr_race_on", "1", "Enables the LR Race: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_Race_On = true;
gH_Cvar_LR_RussianRoulette_On = CreateConVar("sm_hosties_lr_russianroulette_on", "1", "Enables the LR Russian Roulette: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_RussianRoulette_On = true;
gH_Cvar_LR_JumpContest_On = CreateConVar("sm_hosties_lr_jumpcontest_on", "1", "Enables the LR Jumping Contest: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_JumpContest_On = true;
gH_Cvar_LR_HotPotato_Mode = CreateConVar("sm_hosties_lr_hp_teleport", "2", "Teleport CT to T on hot potato contest start: 0 - disable, 1 - enable, 2 - enable and freeze", 0, true, 0.0, true, 2.0);
gShadow_LR_HotPotato_Mode = 2;
gH_Cvar_SendGlobalMsgs = CreateConVar("sm_hosties_lr_send_global_msgs", "0", "Specifies if non-death related LR messages are sent to everyone or just the active participants in that LR. 0: participants, 1: everyone", 0, true, 0.0, true, 1.0);
gShadow_SendGlobalMsgs = 0;
gH_Cvar_MaxPrisonersToLR = CreateConVar("sm_hosties_lr_ts_max", "2", "The maximum number of terrorists left to enable LR: 0 - LR is always enabled, >0 - maximum number of Ts", 0, true, 0.0, true, 63.0);
gShadow_MaxPrisonersToLR = 1;
gH_Cvar_RebelAction = CreateConVar("sm_hosties_lr_rebel_action", "2", "Decides what to do with those who rebel/interfere during an LR. 1 - Abort, 2 - Slay.", 0, true, 1.0, true, 2.0);
gShadow_RebelAction = 2;
gH_Cvar_RebelHandling = CreateConVar("sm_hosties_lr_rebel_mode", "1", "LR-mode for rebelling terrorists: 0 - Rebelling Ts can never have a LR, 1 - Rebelling Ts must let the CT decide if a LR is OK, 2 - Rebelling Ts can have a LR just like other Ts", 0, true, 0.0);
gShadow_RebelHandling = 1;
gH_Cvar_RebelOnImpact = CreateConVar("sm_hosties_lr_rebel_impact", "0", "Sets terrorists to rebels for firing a bullet. 0 - Disabled, 1 - Enabled.", 0, true, 0.0, true, 1.0);
gShadow_RebelOnImpact = 0;
gH_Cvar_ColorRebels = CreateConVar("sm_hosties_rebel_color", "0", "Turns on coloring rebels", 0, true, 0.0, true, 1.0);
gShadow_ColorRebels = 0;
gH_Cvar_ColorRebels_Red = CreateConVar("sm_hosties_rebel_red", "255", "What color to turn a rebel into (set R, G and B values to 255 to disable) (Rgb): x - red value", 0, true, 0.0, true, 255.0);
gShadow_ColorRebels_Red = 255;
gH_Cvar_ColorRebels_Green = CreateConVar("sm_hosties_rebel_green", "0", "What color to turn a rebel into (rGb): x - green value", 0, true, 0.0, true, 255.0);
gShadow_ColorRebels_Green = 0;
gH_Cvar_ColorRebels_Blue = CreateConVar("sm_hosties_rebel_blue", "0", "What color to turn a rebel into (rgB): x - blue value", 0, true, 0.0, true, 255.0);
gShadow_ColorRebels_Blue = 0;
gH_Cvar_LR_Beacons = CreateConVar("sm_hosties_lr_beacon", "1", "Beacon players on LR or not: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_Beacons = true;
gH_Cvar_LR_HelpBeams = CreateConVar("sm_hosties_lr_beams", "1", "Displays connecting beams between LR contestants: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_HelpBeams = true;
gH_Cvar_LR_HelpBeams_Distance = CreateConVar("sm_hosties_lr_beams_distance", "0.0", "Controls how close LR partners must be before the connecting beams will disappear: 0 - always on, >0 the distance in game units", 0, true, 0.0);
gShadow_LR_HelpBeams_Distance = 0.0;
gH_Cvar_LR_Beacon_Interval = CreateConVar("sm_hosties_lr_beacon_interval", "1.0", "The interval in seconds of which the beacon 'beeps' on LR", 0, true, 0.1);
gShadow_LR_Beacon_Interval = 1.0;
gH_Cvar_LR_ChickenFight_Slay = CreateConVar("sm_hosties_lr_cf_slay", "1", "Slay the loser of a Chicken Fight instantly? 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_ChickenFight_Slay = true;
gH_Cvar_LR_ChickenFight_C_Blue = CreateConVar("sm_hosties_lr_cf_loser_blue", "0", "What color to turn the loser of a chicken fight into (rgB): x - blue value", 0, true, 0.0, true, 255.0);
gShadow_LR_ChickenFight_C_Blue = 0;
gH_Cvar_LR_ChickenFight_C_Green = CreateConVar("sm_hosties_lr_cf_loser_green", "255", "What color to turn the loser of a chicken fight into (rGb): x - green value", 0, true, 0.0, true, 255.0);
gShadow_LR_ChickenFight_C_Green = 255;
gH_Cvar_LR_ChickenFight_C_Red = CreateConVar("sm_hosties_lr_cf_loser_red", "255", "What color to turn the loser of a chicken fight into (only if sm_hosties_lr_cf_slay == 0, set R, G and B values to 255 to disable) (Rgb): x - red value", 0, true, 0.0, true, 255.0);
gShadow_LR_ChickenFight_C_Red = 255;
gH_Cvar_LR_Dodgeball_CheatCheck = CreateConVar("sm_hosties_lr_db_cheatcheck", "1", "Enable health-checker in LR Dodgeball to prevent contestant cheating (healing themselves): 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_Dodgeball_CheatCheck = true;
gH_Cvar_LR_Dodgeball_SpawnTime = CreateConVar("sm_hosties_lr_db_flash_duration", "1.4", "The amount of time after a thrown flash before a new flash is given to a contestant: float value - delay in seconds", 0, true, 0.7, true, 6.0);
gShadow_LR_Dodgeball_SpawnTime = 1.4;
gH_Cvar_LR_Dodgeball_Gravity = CreateConVar("sm_hosties_lr_db_gravity", "0.6", "What gravity multiplier the dodgeball contestants will get: <1.0 - less/lower, >1.0 - more/higher", 0, true, 0.1, true, 2.0);
gShadow_LR_Dodgeball_Gravity = 0.6;
gH_Cvar_LR_HotPotato_MaxTime = CreateConVar("sm_hosties_lr_hp_maxtime", "20.0", "Maximum time in seconds the Hot Potato contest will last for (time is randomized): float value - time", 0, true, 8.0, true, 120.0);
gShadow_LR_HotPotato_MaxTime = 20.0;
gH_Cvar_LR_HotPotato_MinTime = CreateConVar("sm_hosties_lr_hp_mintime", "10.0", "Minimum time in seconds the Hot Potato contest will last for (time is randomized): float value - time", 0, true, 0.0, true, 45.0);
gShadow_LR_HotPotato_MinTime = 10.0;
gH_Cvar_LR_HotPotato_Speed = CreateConVar("sm_hosties_lr_hp_speed_multipl", "1.5", "What speed multiplier a hot potato contestant who has the deagle is gonna get: <1.0 - slower, >1.0 - faster", 0, true, 0.8, true, 3.0);
gShadow_LR_HotPotato_Speed = 1.5;
gH_Cvar_LR_S4S_DoubleShot = CreateConVar("sm_hosties_lr_s4s_dblsht_action", "1", "What to do with someone who fires 2 shots in a row in Shot4Shot: 0 - nothing (ignore completely), 1 - Follow rebel punishment cvars", 0, true, 0.0, true, 1.0);
gShadow_LR_S4S_DoubleShot = false;
gH_Cvar_LR_NoScope_Sound = CreateConVar("sm_hosties_noscope_sound", "sm_hosties/noscopestart1.mp3", "What sound to play when a No Scope Battle starts, relative to the sound-folder: -1 - disable, path - path to sound file", 0);
Format(gShadow_LR_NoScope_Sound, sizeof(gShadow_LR_NoScope_Sound ), "sm_hosties/noscopestart1.mp3");
gH_Cvar_LR_Sound = CreateConVar("sm_hosties_lr_sound", "sm_hosties/lr1.mp3", "What sound to play when LR gets available, relative to the sound-folder (also requires sm_hosties_announce_lr to be 1): -1 - disable, path - path to sound file", 0);
Format(gShadow_LR_Sound, sizeof(gShadow_LR_Sound), "sm_hosties/lr1.mp3");
gH_Cvar_LR_Beacon_Sound = CreateConVar("sm_hosties_beacon_sound", "buttons/blip1.wav", "What sound to play each second a beacon is 'ping'ed.", 0);
Format(gShadow_LR_Beacon_Sound, sizeof(gShadow_LR_Beacon_Sound), "buttons/blip1.wav");
gH_Cvar_LR_NoScope_Weapon = CreateConVar("sm_hosties_lr_ns_weapon", "2", "Weapon to use in a No Scope Battle: 0 - AWP, 1 - scout, 2 - let the terrorist choose, 3 - SG550, 4 - G3SG1", 0, true, 0.0, true, 2.0);
gShadow_LR_NoScope_Weapon = 2;
gH_Cvar_LR_NonContKiller_Action = CreateConVar("sm_hosties_lr_p_killed_action", "1", "What to do when a LR-player gets killed by a player not in LR during LR: 0 - just abort LR, 1 - abort LR and slay the attacker", 0, true, 0.0, true, 1.0);
gShadow_LR_NonContKiller_Action = true;
gH_Cvar_LR_GunToss_MarkerMode = CreateConVar("sm_hosties_lr_gt_markers", "0", "Deagle marking (requires sm_hosties_lr_gt_mode 1): 0 - markers straight up where the deagles land, 1 - markers starting where the deagle was dropped ending at the deagle landing point", 0);
gShadow_LR_GunToss_MarkerMode = 0;
gH_Cvar_LR_GunToss_StartMode = CreateConVar("sm_hosties_lr_gt_mode", "1", "How Gun Toss will be played: 0 - no double-dropping checking, deagle gets 7 ammo at start, 1 - double dropping check, deagle gets 7 ammo on drop, colouring of deagles, deagle markers", 0);
gShadow_LR_GunToss_StartMode = 1;
gH_Cvar_LR_GunToss_ShowMeter = CreateConVar("sm_hosties_lr_gt_meter", "1", "Displays a distance meter: 0 - do not display, 1 - display", 0, true, 0.0, true, 1.0);
gShadow_LR_GunToss_ShowMeter = 1;
gH_Cvar_LR_Delay_Enable_Time = CreateConVar("sm_hosties_lr_enable_delay", "0.0", "Delay in seconds before a last request can be started: 0.0 - instantly, >0.0 - (float value) delay in seconds", 0, true, 0.0);
gShadow_LR_Delay_Enable_Time = 0.0;
gH_Cvar_LR_Damage = CreateConVar("sm_hosties_lr_damage", "0", "Enables that players can not attack players in LR and players in LR can not attack players outside LR: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_Damage = false;
gH_Cvar_LR_NoScope_Delay = CreateConVar("sm_hosties_lr_ns_delay", "3", "Delay in seconds before a No Scope Battle begins (to prepare the contestants...)", 0, true, 0.0);
gShadow_LR_NoScope_Delay = 3;
gH_Cvar_LR_ChickenFight_Rebel = CreateConVar("sm_hosties_lr_cf_cheat_action", "1", "What to do with a chicken fighter who attacks the other player with another weapon than knife: 0 - abort LR, 1 - slay player", 0, true, 0.0, true, 1.0);
gShadow_LR_ChickenFight_Rebel = 1;
gH_Cvar_LR_HotPotato_Rebel = CreateConVar("sm_hosties_lr_hp_cheat_action", "1", "What to do with a hot potato contestant who attacks the other player: 0 - abort LR, 1 - slay player", 0, true, 0.0, true, 1.0);
gShadow_LR_HotPotato_Rebel = 1;
gH_Cvar_LR_KnifeFight_Rebel = CreateConVar("sm_hosties_lr_kf_cheat_action", "1", "What to do with a knife fighter who attacks the other player with another weapon than knife: 0 - abort LR, 1 - slay player", 0, true, 0.0, true, 1.0);
gShadow_LR_KnifeFight_Rebel = 1;
gH_Cvar_LR_Race_AirPoints = CreateConVar("sm_hosties_lr_race_airpoints", "0", "Allow prisoners to set race points in the air.", 0, true, 0.0, true, 1.0);
gShadow_LR_Race_AirPoints = false;
gH_Cvar_LR_Race_NotifyCTs = CreateConVar("sm_hosties_lr_race_tell_cts", "1", "Tells all CTs when a T has selected the race option from the LR menu", 0, true, 0.0, true, 1.0);
gShadow_LR_Race_NotifyCTs = false;
gH_Cvar_LR_Rebel_MaxTs = CreateConVar("sm_hosties_lr_rebel_ts", "1", "If the Rebel LR option is enabled, specifies the maximum number of alive terrorists needed for the option to appear in the LR menu.", 0, true, 1.0);
gShadow_LR_Rebel_MaxTs = 1;
gH_Cvar_LR_Rebel_MinCTs = CreateConVar("sm_hosties_lr_rebel_cts", "1", "If the Rebel LR option is enabled, specifies how minimum number of alive counter-terrorists needed for the option to appear in the LR menu.", 0, true, 1.0);
gShadow_LR_Rebel_MinCTs = 1;
gH_Cvar_LR_M4M_MagCapacity = CreateConVar("sm_hosties_lr_m4m_capacity", "7", "The number of bullets in each magazine given to Mag4Mag LR contestants", 0, true, 2.0);
gShadow_LR_M4M_MagCapacity = 7;
gH_Cvar_LR_KnifeFight_LowGrav = CreateConVar("sm_hosties_lr_kf_gravity", "0.6", "The multiplier used for the low-gravity knife fight.", 0, true, 0.0, true, 1.0);
gShadow_LR_KnifeFight_LowGrav = 0.6;
gH_Cvar_LR_KnifeFight_HiSpeed = CreateConVar("sm_hosties_lr_kf_speed", "2.2", "The multiplier used for the high-speed knife fight.", 0, true, 1.1);
gShadow_LR_KnifeFight_HiSpeed = 2.2;
gH_Cvar_LR_KnifeFight_Drunk = CreateConVar("sm_hosties_lr_kf_drunk", "4", "The multiplier used for how drunk the player will be during the drunken boxing knife fight.", 0, true, 0.0);
gShadow_LR_KnifeFight_Drunk = 4;
gH_Cvar_Announce_CT_FreeHit = CreateConVar("sm_hosties_announce_attack", "1", "Enable or disable announcements when a CT attacks a non-rebelling T: 0 - disable, 1 - console, 2 - chat, 3 - both", 0, true, 0.0, true, 3.0);
gShadow_Announce_CT_FreeHit = 1;
gH_Cvar_Announce_LR = CreateConVar("sm_hosties_announce_lr", "1", "Enable or disable chat announcements when Last Requests starts to be available: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_Announce_LR = true;
gH_Cvar_Announce_Rebel = CreateConVar("sm_hosties_announce_rebel", "0", "Enable or disable chat announcements when a terrorist becomes a rebel: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_Announce_Rebel = false;
gH_Cvar_Announce_RebelDown = CreateConVar("sm_hosties_announce_rebel_down", "0", "Enable or disable chat announcements when a rebel is killed: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_Announce_RebelDown = false;
gH_Cvar_Announce_Weapon_Attack = CreateConVar("sm_hosties_announce_wpn_attack", "0", "Enable or disable an announcement telling that a non-rebelling T has a weapon when he gets attacked by a CT (also requires sm_hosties_announce_attack 1): 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_Announce_Weapon_Attack = false;
gH_Cvar_Announce_Shot4Shot = CreateConVar("sm_hosties_lr_s4s_shot_taken", "1", "Enable announcements in Shot4Shot or Mag4Mag when a contestant empties their gun: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_Announce_Shot4Shot = false;
gH_Cvar_Announce_Delay_Enable = CreateConVar("sm_hosties_announce_lr_delay", "1", "Enable or disable chat announcements to tell that last request delaying is activated and how long the delay is: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_Announce_Delay_Enable = false;
gH_Cvar_Announce_HotPotato_Eqp = CreateConVar("sm_hosties_lr_hp_pickupannounce", "0", "Enable announcement when a Hot Potato contestant picks up the hot potato: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_Announce_HotPotato_Eqp = false;
gH_Cvar_LR_AutoDisplay = CreateConVar("sm_hosties_lr_autodisplay", "0", "Automatically display the LR menu to non-rebelers when they become elgible for LR: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_AutoDisplay = false;
gH_Cvar_LR_BlockSuicide = CreateConVar("sm_hosties_lr_blocksuicide", "0", "Blocks LR participants from commiting suicide to avoid deaths: 0 - disable, 1 - enable", 0, true, 0.0, true, 1.0);
gShadow_LR_BlockSuicide = false;
gH_Cvar_LR_VictorPoints = CreateConVar("sm_hosties_lr_victorpoints", "1", "Amount of frags CS:S or 2x points to score in CS:GO to reward victor in an LR where other player automatically dies", 0, true, 0.0);
gShadow_LR_VictorPoints = 1;
// Listen for changes
HookConVarChange(gH_Cvar_LR_KnifeFight_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_Shot4Shot_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_GunToss_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_ChickenFight_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_HotPotato_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_Dodgeball_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_NoScope_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_RockPaperScissors_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_Rebel_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_Mag4Mag_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_Race_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_RussianRoulette_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_JumpContest_On, ConVarChanged_LastRequest);
HookConVarChange(gH_Cvar_LR_Enable, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_MenuTime, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_KillTimeouts, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_HotPotato_Mode, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_SendGlobalMsgs, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_MaxPrisonersToLR, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_RebelAction, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_RebelHandling, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_ColorRebels, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Beacons, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_HelpBeams, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_HelpBeams_Distance, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Beacon_Interval, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_RebelOnImpact, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_ColorRebels_Blue, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_ColorRebels_Green, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_ColorRebels_Red, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_ChickenFight_C_Blue, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_ChickenFight_C_Green, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_ChickenFight_C_Red, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_ChickenFight_Slay, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Dodgeball_CheatCheck, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Dodgeball_Gravity, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Dodgeball_SpawnTime, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_HotPotato_MaxTime, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_HotPotato_MinTime, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_HotPotato_Speed, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_NoScope_Sound, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Sound, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Beacon_Sound, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_NoScope_Weapon, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_NonContKiller_Action, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_S4S_DoubleShot, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_GunToss_MarkerMode, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_GunToss_StartMode, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_GunToss_ShowMeter, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Delay_Enable_Time, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Damage, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_NoScope_Delay, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_KnifeFight_Rebel, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_ChickenFight_Rebel, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_HotPotato_Rebel, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Race_AirPoints, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Race_NotifyCTs, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Rebel_MinCTs, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_Rebel_MaxTs, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_M4M_MagCapacity, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_KnifeFight_LowGrav, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_KnifeFight_HiSpeed, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_KnifeFight_Drunk, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_Announce_CT_FreeHit, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_Announce_LR, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_Announce_Rebel, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_Announce_RebelDown, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_Announce_Weapon_Attack, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_Announce_Shot4Shot, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_Announce_Delay_Enable, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_Announce_HotPotato_Eqp, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_AutoDisplay, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_BlockSuicide, ConVarChanged_Setting);
HookConVarChange(gH_Cvar_LR_VictorPoints, ConVarChanged_Setting);
// Account for late loading
for (new idx = 1; idx <= MaxClients ; idx++)
{
if (IsClientInGame(idx))
{
SDKHook(idx, SDKHook_WeaponDrop, OnWeaponDrop);
SDKHook(idx, SDKHook_WeaponEquip, OnWeaponEquip);
SDKHook(idx, SDKHook_WeaponCanUse, OnWeaponDecideUse);
SDKHook(idx, SDKHook_OnTakeDamage, OnTakeDamage);
}
g_bIsARebel[idx] = false;
g_bInLastRequest[idx] = false;
gH_BuildLR[idx] = INVALID_HANDLE;
}
}
LastRequest_Menus(Handle:h_TopMenu, TopMenuObject:obj_Hosties)
{
AddToTopMenu(h_TopMenu, "sm_stoplr", TopMenuObject_Item, AdminMenu_StopLR, obj_Hosties, "sm_stoplr", ADMFLAG_SLAY);
}
public AdminMenu_StopLR(Handle:h_TopMenu, TopMenuAction:action, TopMenuObject:item, client, String:buffer[], maxlength)
{
if (action == TopMenuAction_DisplayOption)
{
Format(buffer, maxlength, "Stop All LastRequests");
}
else if (action == TopMenuAction_SelectOption)
{
StopActiveLRs(client);
}
}
LastRequest_APL()
{
CreateNative("AddLastRequestToList", Native_LR_AddToList);
CreateNative("RemoveLastRequestFromList", Native_LR_RemoveFromList);
CreateNative("IsClientRebel", Native_IsClientRebel);
CreateNative("IsClientInLastRequest", Native_IsClientInLR);
CreateNative("ProcessAllLastRequests", Native_ProcessLRs);
CreateNative("ChangeRebelStatus", Native_ChangeRebelStatus);
CreateNative("InitializeLR", Native_LR_Initialize);
CreateNative("CleanupLR", Native_LR_Cleanup);
RegPluginLibrary("lastrequest");
}
public Native_ProcessLRs(Handle:h_Plugin, iNumParameters)
{
new Function:LoopCallback = GetNativeCell(1);
AddToForward(gH_Frwd_LR_Process, h_Plugin, LoopCallback);
new LastRequest:thisType = GetNativeCell(2);
new theLRArraySize = GetArraySize(gH_DArray_LR_Partners);
for (new idx = 0; idx < GetArraySize(gH_DArray_LR_Partners); idx++)
{
new LastRequest:type = GetArrayCell(gH_DArray_LR_Partners, idx, _:Block_LRType);
if (type == thisType)
{
Call_StartForward(gH_Frwd_LR_Process);
Call_PushCell(gH_DArray_LR_Partners);
Call_PushCell(idx);
Call_Finish();
}
}
RemoveFromForward(gH_Frwd_LR_Process, h_Plugin, LoopCallback);
return theLRArraySize;
}
public Native_LR_AddToList(Handle:h_Plugin, iNumParameters)
{
new Function:StartCall = GetNativeCell(1);
new Function:CleanUpCall = GetNativeCell(2);
AddToForward(gH_Frwd_LR_Start, h_Plugin, StartCall);
AddToForward(gH_Frwd_LR_CleanUp, h_Plugin, CleanUpCall);
decl String:sLR_Name[MAX_DISPLAYNAME_SIZE];
GetNativeString(3, sLR_Name, MAX_DISPLAYNAME_SIZE);
new bool:AutoStart;
if (iNumParameters > 3)
{
AutoStart = GetNativeCell(4);
}
else
{
AutoStart = true;
}
new iPosition = PushArrayString(gH_DArray_LR_CustomNames, sLR_Name);
// take the maximum number of LRs + the custom LR index to get new value to push
iPosition += _:LastRequest;
new iIndex = PushArrayCell(gH_DArray_LastRequests, iPosition);
SetArrayCell(gH_DArray_LastRequests, iIndex, AutoStart, 1);
return iPosition;
}
public Native_LR_RemoveFromList(Handle:h_Plugin, iNumParameters)
{
new Function:StartCall = GetNativeCell(1);
new Function:CleanUpCall = GetNativeCell(2);
RemoveFromForward(gH_Frwd_LR_Start, h_Plugin, StartCall);
RemoveFromForward(gH_Frwd_LR_CleanUp, h_Plugin, CleanUpCall);
decl String:sLR_Name[MAX_DISPLAYNAME_SIZE];
GetNativeString(3, sLR_Name, MAX_DISPLAYNAME_SIZE);
new iPosition = FindStringInArray(gH_DArray_LR_CustomNames, sLR_Name);
if (iPosition == -1)
{
return ThrowNativeError(SP_ERROR_NATIVE, "LR Name (%s) Not Found", sLR_Name);
}
else
{
RemoveFromArray(gH_DArray_LR_CustomNames, iPosition);
iPosition += _:LastRequest;
RemoveFromArray(gH_DArray_LastRequests, iPosition);
}
return 1;
}
public Native_LR_Initialize(Handle:h_Plugin, iNumParameters)
{
if(iNumParameters == 1)
{
new LR_Player_Prisoner = 0;
if(GetNativeCell(1) != 0)
{
if(GetClientTeam(GetNativeCell(1)) == 2)
{
LR_Player_Prisoner = GetNativeCell(1);
}
}
if(LR_Player_Prisoner != 0 && g_LR_Player_Guard[LR_Player_Prisoner] != 0)
{
if(!IsLastRequestAutoStart(g_selection[LR_Player_Prisoner]))
{
new iArrayIndex = PushArrayCell(gH_DArray_LR_Partners, g_selection[LR_Player_Prisoner]);
SetArrayCell(gH_DArray_LR_Partners, iArrayIndex, LR_Player_Prisoner, _:Block_Prisoner);
SetArrayCell(gH_DArray_LR_Partners, iArrayIndex, g_LR_Player_Guard[LR_Player_Prisoner], _:Block_Guard);
g_bInLastRequest[LR_Player_Prisoner] = true;
g_bInLastRequest[g_LR_Player_Guard[LR_Player_Prisoner]] = true;
// Fire global
Call_StartForward(gH_Frwd_LR_StartGlobal);
Call_PushCell(LR_Player_Prisoner);
Call_PushCell(g_LR_Player_Guard[LR_Player_Prisoner]);
// LR type
Call_PushCell(g_selection[LR_Player_Prisoner]);
new ignore;
Call_Finish(_:ignore);
// Close datapack
if (gH_BuildLR[LR_Player_Prisoner] != INVALID_HANDLE)
{
CloseHandle(gH_BuildLR[LR_Player_Prisoner]);
}
gH_BuildLR[LR_Player_Prisoner] = INVALID_HANDLE;
// Beacon players
if (gShadow_LR_Beacons)
{
AddBeacon(LR_Player_Prisoner);
AddBeacon(g_LR_Player_Guard[LR_Player_Prisoner]);
}
}
}
else
{
ThrowNativeError(SP_ERROR_NATIVE, "InitializeLR Failure (Invalid client(s) index).");
}
}
else
{
ThrowNativeError(SP_ERROR_NATIVE, "InitializeLR Failure (Wrong number of parameters).");
}
}
public Native_LR_Cleanup(Handle:h_Plugin, iNumParameters)
{
if(iNumParameters == 1)
{
new LR_Player_Prisoner = 0;
if(GetNativeCell(1) != 0)
{
if(GetClientTeam(GetNativeCell(1)) == 2 && !g_bInLastRequest[GetNativeCell(1)])
{
LR_Player_Prisoner = GetNativeCell(1);
}
}
if(LR_Player_Prisoner != 0)
{
if(!IsLastRequestAutoStart(g_selection[LR_Player_Prisoner]))
{
g_LR_Player_Guard[LR_Player_Prisoner] = 0;
}
}
else
{
ThrowNativeError(SP_ERROR_NATIVE, "CleanupLR Failure (Invalid client index or player is already in LR).");
}
}
else
{
ThrowNativeError(SP_ERROR_NATIVE, "CleanupLR Failure (Wrong number of parameters).");
}
}
public Native_IsClientRebel(Handle:h_Plugin, iNumParameters)
{
new client = GetNativeCell(1);
if (client > MaxClients || client < 0)
{
return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", client);
}
return bool:g_bIsARebel[client];
}
public Native_ChangeRebelStatus(Handle:h_Plugin, iNumParameters)
{
new client = GetNativeCell(1);
if (client > MaxClients || client < 0)
{
return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index (%d)", client);
}
new status = GetNativeCell(2);
if (status < 0 || status > 1)
{
return ThrowNativeError(SP_ERROR_NATIVE, "Invalid rebel status (%d)", status);
}
g_bIsARebel[client] = bool:status;
return 1;
}
public Native_IsClientInLR(Handle:h_Plugin, iNumParameters)
{
new client = GetNativeCell(1);
if (!IsClientInGame(client))
{
return ThrowNativeError(SP_ERROR_NATIVE, "Given client index (%d) not in game", client);
}
return Local_IsClientInLR(client);
}
Local_IsClientInLR(client)
{
new iArraySize = GetArraySize(gH_DArray_LR_Partners);
for (new idx = 0; idx < iArraySize; idx++)
{
new LR_Player_Prisoner = GetArrayCell(gH_DArray_LR_Partners, idx, _:Block_Prisoner);
new LR_Player_Guard = GetArrayCell(gH_DArray_LR_Partners, idx, _:Block_Guard);
if ((LR_Player_Prisoner == client) || (LR_Player_Guard == client))
{
// check if a partner exists
if ((LR_Player_Prisoner == 0) || (LR_Player_Guard == 0))
{
return -1;
}
else
{
return (LR_Player_Prisoner == client ? LR_Player_Guard : LR_Player_Prisoner);
}
}
}
return 0;
}
public LastRequest_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
g_bAnnouncedThisRound = false;
// Set variable to know that the round has started
g_bRoundInProgress = true;
// roundstart done, enable LR if there should be no LR delay (credits to Caza for this :p)
if (gShadow_LR_Delay_Enable_Time > 0.0)
{
g_bIsLRAvailable = false;
g_DelayLREnableTimer = CreateTimer(gShadow_LR_Delay_Enable_Time, Timer_EnableLR, _, TIMER_FLAG_NO_MAPCHANGE);
if (gShadow_Announce_Delay_Enable)
{
PrintToChatAll(CHAT_BANNER, "LR Delay Announcement", RoundToNearest(gShadow_LR_Delay_Enable_Time));
}
}
else
{
g_bIsLRAvailable = true;
}
for (new idx = 1; idx <= MaxClients; idx++)
{
g_bIsARebel[idx] = false;
g_bInLastRequest[idx] = false;
g_LR_Player_Guard[idx] = 0;
SetCorrectPlayerColor(idx);
}
}
public Action:Timer_EnableLR(Handle:timer)
{
if (g_DelayLREnableTimer == timer)
{
g_bIsLRAvailable = true;
g_DelayLREnableTimer = INVALID_HANDLE;
}
return Plugin_Stop;
}
public Action:Command_CancelLR(client, args)
{
StopActiveLRs(client);
return Plugin_Handled;
}
StopActiveLRs(client)
{
new iArraySize = GetArraySize(gH_DArray_LR_Partners);
while (iArraySize > 0)
{
CleanupLastRequest(client, iArraySize-1);
RemoveFromArray(gH_DArray_LR_Partners, iArraySize-1);
iArraySize--;
}
ShowActivity(client, "%t", "LR Aborted");
}
public LastRequest_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
// Block LRs and reset
g_bIsLRAvailable = false;
// Set variable to know that the round has ended
g_bRoundInProgress = false;
// Remove all the LR data
ClearArray(gH_DArray_LR_Partners);
ClearArray(gH_DArray_Beacons);
// Stop timers for short rounds
if (g_DelayLREnableTimer != INVALID_HANDLE)
{
g_DelayLREnableTimer = INVALID_HANDLE;
}
// Cancel menus of all alive prisoners
ClosePotentialLRMenus();
}
public LastRequest_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new iArraySize = GetArraySize(gH_DArray_LR_Partners);
if (iArraySize > 0)
{
for (new idx = 0; idx < GetArraySize(gH_DArray_LR_Partners); idx++)
{
new LastRequest:type = GetArrayCell(gH_DArray_LR_Partners, idx, _:Block_LRType);
new LR_Player_Prisoner = GetArrayCell(gH_DArray_LR_Partners, idx, _:Block_Prisoner);
new LR_Player_Guard = GetArrayCell(gH_DArray_LR_Partners, idx, _:Block_Guard);
if (victim == LR_Player_Prisoner || victim == LR_Player_Guard)
{
if (attacker != LR_Player_Prisoner && attacker != LR_Player_Guard \
&& attacker && (type != LR_Rebel))
{