forked from utharper/sourcemod-hl2dm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxfix.sp
2142 lines (1794 loc) · 60.2 KB
/
xfix.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
/******************************
COMPILE OPTIONS
******************************/
#pragma semicolon 1
#pragma newdecls required
/******************************
NECESSARY INCLUDES
******************************/
#include <sourcemod>
#include <base>
#include <clientprefs>
#include <sdktools>
#include <sdkhooks>
#include <dhooks>
#include <smlib>
#include <basecomm>
#include <jhl2dm>
#include <vphysics>
/******************************
PLUGIN DEFINES
******************************/
#define DEVENABLE 0
/*Team Colors*/
#define PLAYERCOLOR "\x07d8bfd8"
#define TEAMCOLOR "\x07d2b48c"
#define CHATCOLOR "\x07ffffff"
#define REBELS "\x07ff3d42"
#define COMBINE "\x079fcaf2"
#define SPEC "\x07ff811c"
#define UNASSIGNED "\x07f7ff7f"
#define ZOOM_NONE 0
#define ZOOM_XBOW 1
#define ZOOM_SUIT 2
#define ZOOM_TOGL 3
#define FIRSTPERSON 4
/*Setting static strings*/
static const char
/*Plugin Info*/
PL_NAME[] = "HL2MP - Fixes & Enhancements",
PL_AUTHOR[] = "HL2MP Sourcemodders",
PL_DESCRIPTION[] = "Half-Life 2: Deathmatch Fixes & Enhancements",
PL_VERSION[] = "1.6.11";
/******************************
PLUGIN HANDLES
******************************/
Handle g_hTeam[MAXPLAYERS + 1],
hHUD,
gcFov,
g_hCookiePlModel,
g_hCookieFootsteps,
g_hCookieSndFix,
g_hWeapon_ShootPosition = INVALID_HANDLE;
/******************************
PLUGIN FLOATS
******************************/
float gfVolume = 1.0,
g_vecOldWeaponShootPos[MAXPLAYERS + 1][3];
/******************************
PLUGIN BOOLEANS
******************************/
bool gbLate,
g_bPlayerModel[MAXPLAYERS + 1] = { true, ... },
g_bFlipFlopSpeed[MAXPLAYERS + 1] = { true, ... },
g_bFootsteps[MAXPLAYERS + 1] = { true, ... },
g_bSndFix[MAXPLAYERS + 1] = { true, ... },
g_bTchat,
gbRoundEnd,
gbMOTDExists,
gbTeamplay,
g_bAuthenticated[MAXPLAYERS + 1] = { false, ... },
g_bRocketFired[MAXPLAYERS + 1] = { false, ... },
g_bAr2AltFire[MAXPLAYERS + 1] = { false, ... };
/******************************
PLUGIN CONVARS
******************************/
ConVar gCvar;
enum struct _gConVar
{
ConVar g_cTimeleftEnable;
ConVar g_cTimeleftX;
ConVar g_cTimeleftY;
ConVar g_cTimeleftR;
ConVar g_cTimeleftG;
ConVar g_cTimeleftB;
ConVar g_cTimeleftI;
ConVar sk_auto_reload_time;
ConVar g_cplayermodelmsg;
ConVar g_cTeamHook;
ConVar g_cEnable;
ConVar g_cChatEnabled;
ConVar g_cTeamplay;
ConVar fov_minfov;
ConVar fov_defaultfov;
ConVar fov_maxfov;
ConVar sv_gravity;
ConVar mp_falldamage;
ConVar mp_falldamage_multiplier;
ConVar sm_pluginmessages_check;
ConVar sm_missing_sounds_fix;
ConVar sm_hl2_footsteps;
ConVar mp_forcerespawn;
ConVar mp_restartgame;
ConVar fps_max_check;
ConVar sm_rpg_allow_wep_switch;
ConVar sm_ar2_allow_wep_switch;
ConVar fps_max_min_required;
ConVar fps_max_max_required;
ConVar sm_hud_stats;
}
_gConVar gConVar;
/******************************
PLUGIN INTEGERS
******************************/
int giZoom[MAXPLAYERS + 1],
iRocket[MAXPLAYERS + 1],
iOrb[MAXPLAYERS + 1],
iDeploy[MAXPLAYERS + 1];
/******************************
PLUGIN STRINGMAPS
******************************/
StringMap gmKills,
gmDeaths,
gmTeams;
/******************************
PLUGIN STRINGS
******************************/
char g_sFootstepSnds[68][75] = {
"player/footsteps/concrete1.wav",
"player/footsteps/concrete2.wav",
"player/footsteps/concrete3.wav",
"player/footsteps/concrete4.wav",
"player/footsteps/chainlink1.wav",
"player/footsteps/chainlink2.wav",
"player/footsteps/chainlink3.wav",
"player/footsteps/chainlink4.wav",
"player/footsteps/dirt1.wav",
"player/footsteps/dirt2.wav",
"player/footsteps/dirt3.wav",
"player/footsteps/dirt4.wav",
"player/footsteps/duct1.wav",
"player/footsteps/duct2.wav",
"player/footsteps/duct3.wav",
"player/footsteps/duct4.wav",
"player/footsteps/grass1.wav",
"player/footsteps/grass2.wav",
"player/footsteps/grass3.wav",
"player/footsteps/grass4.wav",
"player/footsteps/gravel1.wav",
"player/footsteps/gravel2.wav",
"player/footsteps/gravel3.wav",
"player/footsteps/gravel4.wav",
"player/footsteps/ladder1.wav",
"player/footsteps/ladder2.wav",
"player/footsteps/ladder3.wav",
"player/footsteps/ladder4.wav",
"player/footsteps/metal1.wav",
"player/footsteps/metal2.wav",
"player/footsteps/metal3.wav",
"player/footsteps/metal4.wav",
"player/footsteps/metalgrate1.wav",
"player/footsteps/metalgrate2.wav",
"player/footsteps/metalgrate3.wav",
"player/footsteps/metalgrate4.wav",
//"player/footsteps/mud1.wav",
//"player/footsteps/mud2.wav",
//"player/footsteps/mud3.wav",
//"player/footsteps/mud4.wav",
"player/footsteps/sand1.wav",
"player/footsteps/sand2.wav",
"player/footsteps/sand3.wav",
"player/footsteps/sand4.wav",
//"player/footsteps/slosh1.wav",
//"player/footsteps/slosh2.wav",
//"player/footsteps/slosh3.wav",
//"player/footsteps/slosh4.wav",
"player/footsteps/tile1.wav",
"player/footsteps/tile2.wav",
"player/footsteps/tile3.wav",
"player/footsteps/tile4.wav",
//"player/footsteps/wade1.wav",
//"player/footsteps/wade2.wav",
//"player/footsteps/wade3.wav",
//"player/footsteps/wade4.wav",
"player/footsteps/wood1.wav",
"player/footsteps/wood2.wav",
"player/footsteps/wood3.wav",
"player/footsteps/wood4.wav",
"player/footsteps/woodpanel1.wav",
"player/footsteps/woodpanel2.wav",
"player/footsteps/woodpanel3.wav",
"player/footsteps/woodpanel4.wav",
//"physics/body/body_medium_impact_soft3.wav",
//"physics/body/body_medium_impact_soft4.wav",
//"physics/cardboard/cardboard_box_impact_soft1.wav",
//"physics/cardboard/cardboard_box_impact_soft2.wav",
//"physics/cardboard/cardboard_box_impact_soft3.wav",
//"physics/cardboard/cardboard_box_impact_soft4.wav",
//"physics/flesh/flesh_impact_hard1.wav",
//"physics/flesh/flesh_impact_hard2.wav",
//"physics/glass/glass_impact_soft1.wav",
//"physics/glass/glass_impact_soft2.wav",
//"physics/glass/glass_impact_soft3.wav",
"physics/glass/glass_sheet_step1.wav",
"physics/glass/glass_sheet_step2.wav",
"physics/glass/glass_sheet_step3.wav",
"physics/glass/glass_sheet_step4.wav",
"physics/metal/metal_box_footstep1.wav",
"physics/metal/metal_box_footstep2.wav",
"physics/metal/metal_box_footstep3.wav",
"physics/metal/metal_box_footstep4.wav",
//"physics/metal/metal_grenade_impact_soft1.wav",
//"physics/metal/metal_grenade_impact_soft2.wav",
//"physics/metal/metal_grenade_impact_soft3.wav",
"physics/plaster/ceiling_tile_step1.wav",
"physics/plaster/ceiling_tile_step2.wav",
"physics/plaster/ceiling_tile_step3.wav",
"physics/plaster/ceiling_tile_step4.wav",
//"physics/plaster/drywall_footstep1.wav",
//"physics/plaster/drywall_footstep2.wav",
//"physics/plaster/drywall_footstep3.wav",
//"physics/plaster/drywall_footstep4.wav",
//"physics/plastic/plastic_barrel_impact_soft1.wav",
//"physics/plastic/plastic_barrel_impact_soft2.wav",
//"physics/plastic/plastic_barrel_impact_soft3.wav",
//"physics/plastic/plastic_barrel_impact_soft4.wav",
//"physics/plastic/plastic_box_impact_soft1.wav",
//"physics/plastic/plastic_box_impact_soft2.wav",
//"physics/plastic/plastic_box_impact_soft3.wav",
//"physics/plastic/plastic_box_impact_soft4.wav",
//"physics/rubber/rubber_tire_impact_soft1.wav",
"physics/wood/wood_box_footstep1.wav",
"physics/wood/wood_box_footstep2.wav",
"physics/wood/wood_box_footstep3.wav",
"physics/wood/wood_box_footstep4.wav"
};
static const char g_sWepSnds[8][75] = {
"weapons/crossbow/bolt_load1.wav",
"weapons/crossbow/bolt_load2.wav",
"weapons/physcannon/physcannon_claws_close.wav",
"weapons/physcannon/physcannon_claws_open.wav",
"weapons/physcannon/physcannon_tooheavy.wav",
"weapons/physcannon/physcannon_pickup.wav",
"weapons/physcannon/physcannon_drop.wav",
"weapons/physcannon/hold_loop.wav"
};
static const char g_sChatSnd[1][25] = {
"common/talk.wav"
};
static char g_sModels[19][75] = {
"models/combine_soldier.mdl",
"models/combine_soldier_prisonguard.mdl",
"models/combine_super_soldier.mdl",
"models/police.mdl",
"models/humans/group03/female_01.mdl",
"models/humans/group03/female_02.mdl",
"models/humans/group03/female_03.mdl",
"models/humans/group03/female_04.mdl",
"models/humans/group03/female_06.mdl",
"models/humans/group03/female_07.mdl",
"models/humans/group03/male_01.mdl",
"models/humans/group03/male_02.mdl",
"models/humans/group03/male_03.mdl",
"models/humans/group03/male_04.mdl",
"models/humans/group03/male_05.mdl",
"models/humans/group03/male_06.mdl",
"models/humans/group03/male_07.mdl",
"models/humans/group03/male_08.mdl",
"models/humans/group03/male_09.mdl"
};
static char g_sDisconnectReason[64];
/******************************
DHOOKS
******************************/
DynamicHook gExplosionDamageHook;
/******************************
PLUGIN INFO
******************************/
public Plugin myinfo =
{
name = PL_NAME,
author = PL_AUTHOR,
description = PL_DESCRIPTION,
version = PL_VERSION
};
/******************************
INITIATE THE PLUGIN
******************************/
public void OnPluginStart()
{
gExplosionDamageHook = LoadDHooksOffset("dhooks.hl2mp_tinnitus_fix", "OnDamagedByExplosion");
AddNormalSoundHook(OnSound);
/*PRECACHE SOUNDS*/
for (int i = 1; i < sizeof(g_sWepSnds); i++)
{
PrecacheSound(g_sWepSnds[i]);
}
for (int i = 1; i < sizeof(g_sFootstepSnds); i++)
{
PrecacheSound(g_sFootstepSnds[i]);
}
for (int i = 1; i < sizeof(g_sChatSnd); i++)
{
PrecacheSound(g_sChatSnd[i]);
}
/*PRECACHE MODELS*/
for (int i; i < sizeof(g_sModels); i++)
{
PrecacheModel(g_sModels[i]);
}
if (gbLate)
{
ReplicateToAll("0");
}
gmKills = CreateTrie();
gmDeaths = CreateTrie();
gmTeams = CreateTrie();
/*COOKIES*/
gcFov = RegClientCookie("hl2dm_fov", "Field-of-view value", CookieAccess_Public);
g_hCookiePlModel = RegClientCookie("hl2dm_playermodel", "Player model client messages", CookieAccess_Public);
g_hCookieFootsteps = RegClientCookie("hl2dm_footsteps", "Footstep sounds", CookieAccess_Public);
g_hCookieSndFix = RegClientCookie("hl2dm_sndfix", "Sounds fix", CookieAccess_Public);
/*CONVARS*/
CreateConVar("sm_hl2mp_fixes_version", PL_VERSION, "Version", FCVAR_DONTRECORD | FCVAR_SPONLY | FCVAR_ARCHIVE);
gConVar.g_cplayermodelmsg = CreateConVar("sm_show_playermodel_msg_global", "1", "Shows message that player model was adjusted based on team", 0, true, 0.0, true, 1.0);
gConVar.g_cTeamHook = CreateConVar("sm_playermodel_fix", "1", "Enable/Disable plugin fix", 0, true, 0.0, true, 1.0);
gConVar.g_cEnable = CreateConVar("sm_connect_status_enable", "1", "Determines if the plugin is enabled", 0, true, 0.0, true, 1.0);
gConVar.g_cChatEnabled = CreateConVar("sm_chat_fix", "1", "Enable/Disable Plugin", 0, true, 0.0, true, 1.0);
gConVar.g_cTimeleftEnable = CreateConVar("sm_timeleft_hud_enable", "1", "Enable timeleft to show on HUD", 0, true, 0.0, true, 1.0);
gConVar.g_cTimeleftX = CreateConVar("sm_timeleft_x", "-1.0", "Position the HUD's timeleft on the X axis");
gConVar.g_cTimeleftY = CreateConVar("sm_timeleft_y", "0.01", "Position the HUD's timeleft on the y axis");
gConVar.g_cTimeleftR = CreateConVar("sm_timeleft_r", "255", "Red color intensity of the HUD's timeleft", 0, true, 0.0, true, 255.0);
gConVar.g_cTimeleftG = CreateConVar("sm_timeleft_g", "220", "Green color intensity of the HUD's timeleft", 0, true, 0.0, true, 255.0);
gConVar.g_cTimeleftB = CreateConVar("sm_timeleft_b", "0", "Blue color intensity of the HUD's timeleft", 0, true, 0.0, true, 255.0);
gConVar.g_cTimeleftI = CreateConVar("sm_timeleft_i", "255", "Amount of transparency of the HUD's timeleft", 0, true, 0.0, true, 255.0);
gConVar.fov_minfov = CreateConVar("fov_minfov", "70", "Minimum FOV allowed on server");
gConVar.fov_defaultfov = CreateConVar("fov_defaultfov", "90", "Default FOV of players on server");
gConVar.fov_maxfov = CreateConVar("fov_maxfov", "110", "Maximum FOV allowed on server");
gConVar.mp_falldamage_multiplier = CreateConVar("mp_falldamage_multiplier", "1.0", "Multiplier value for the fall damage", _, true, 0.0);
gConVar.sm_pluginmessages_check = CreateConVar("sm_pluginmessages_check", "1", "Check if a client's \"cl_showpluginmessages\" is set to 0 and displays a message to set it to 1", _, true, 0.0, true, 1.0);
gConVar.sm_missing_sounds_fix = CreateConVar("sm_missing_sounds_fix", "1", "Enable/Disable missing sounds fix", 0, true, 0.0, true, 1.0);
gConVar.sm_hl2_footsteps = CreateConVar("sm_hl2_footsteps", "1", "Enable/Disable HL2 footstep sounds", 0, true, 0.0, true, 1.0);
gConVar.fps_max_check = CreateConVar("sm_fps_max_check", "1", "Enable/Disable the checking of client's fps_max value", 0, true, 0.0, true, 1.0);
gConVar.fps_max_min_required = CreateConVar("sm_fps_min", "60", "Minimum value that a client needs to set their fps_max at", 0, true, 10.0);
gConVar.fps_max_max_required = CreateConVar("sm_fps_max", "1000", "Maximum value that a client needs to set their fps_max at", 0, true, 60.0);
gConVar.sm_rpg_allow_wep_switch = CreateConVar("sm_rpg_allow_wep_switch", "0", "Whether players can switch guns after an active rocket has been fired", 0, true, 0.0, true, 1.0);
gConVar.sm_ar2_allow_wep_switch = CreateConVar("sm_ar2_allow_wep_switch", "0", "Whether players can switch guns after an active orb has been fired", 0, true, 0.0, true, 1.0);
// gConVar.sm_hud_stats = CreateConVar("sm_hud_stats", "1", "Shows observed player's information on HUD", 0, true, 0.0, true, 1.0); // TODO: Show observed player's HUD elements
gConVar.g_cTeamplay = FindConVar("mp_teamplay");
gConVar.mp_falldamage = FindConVar("mp_falldamage");
gConVar.sv_gravity = FindConVar("sv_gravity");
gConVar.mp_forcerespawn = FindConVar("mp_forcerespawn");
gConVar.sk_auto_reload_time = FindConVar("sk_auto_reload_time"); // Tie the relaod time to this ConVar
gConVar.mp_restartgame = FindConVar("mp_restartgame");
gCvar = FindConVar("sv_footsteps");
/*HOOKING*/
HookUserMessage(GetUserMessageId("TextMsg"), dfltmsg, true); // To get rid of default engine messages
HookEvent("player_team", playerteam_callback, EventHookMode_Pre); // To fix death when names get changed through SM commands
HookEvent("player_disconnect", playerdisconnect_callback, EventHookMode_Pre); // Connect messages
HookEvent("player_connect_client", Event_PlayerConnect, EventHookMode_Pre); // Connect messages
HookEvent("player_death", event_death, EventHookMode_Pre);
HookEvent("server_cvar", Event_GameMessage, EventHookMode_Pre);
HookEvent("round_start", Event_RoundBegin, EventHookMode_Pre);
HookConVarChange(gConVar.g_cTeamHook, OnConVarChanged_pModelFix);
HookConVarChange(gConVar.g_cTeamplay, OnConVarChanged_Teamplay);
HookConVarChange(gConVar.g_cTimeleftEnable, OnConVarChanged_HudTimeleft);
HookUserMessage(GetUserMessageId("VGUIMenu"), UserMsg_VGUIMenu, false);
gConVar.sv_gravity.AddChangeHook(OnGravityChanged);
AddCommandListener(cmd_say, "say");
AddCommandListener(cmd_tsay, "say_team");
AddCommandListener(OnClientChangeFOV, "fov");
AddCommandListener(OnClientToggleZoom, "toggle_zoom");
AddCommandListener(HandleUse, "phys_swap");
AddCommandListener(HandleUse, "use");
/*PUBLIC COMMANDS*/
RegConsoleCmd("sm_plmdl_msg", Command_playermdlmsg, "Display message that player model was adjusted when switching teams");
RegConsoleCmd("sm_fov", Command_FOV, "Set your desired field-of-view value");
RegConsoleCmd("sm_footsteps", Command_footsteps, "Toggle between default or HL2 footstep sounds");
RegConsoleCmd("sm_sndfix", Command_Sndfix, "Enable/Disable sound fixes");
RegConsoleCmd("xfix", xfix_credits, "Credits listing");
BulletFix();
AutoExecConfig(true, "hl2mp_fix_config");
for (int i = MaxClients; i > 0; --i) // Late load for client pref
{
if (!AreClientCookiesCached(i))
continue;
OnClientCookiesCached(i);
}
if (gbLate)
{
for (int client = 1; client < MaxClients; client++)
{
OnClientPutInServer(client);
}
}
}
void BulletFix()
{
Handle gameData = LoadGameConfigFile("dhooks.weapon_shootposition"); // Bullet position fix by xutaxkamay
if (gameData == INVALID_HANDLE)
{
SetFailState("[SM] FireBullets Fix cannot load: Missing gamedata.");
}
else PrintToServer("[SM] FireBullets Fix has successfully loaded.");
int offset = GameConfGetOffset(gameData, "Weapon_ShootPosition");
if (offset == -1)
{
SetFailState("[FireBullets Fix] failed to find offset");
}
LogMessage("Found offset for Weapon_ShootPosition %d", offset);
g_hWeapon_ShootPosition = DHookCreate(offset, HookType_Entity, ReturnType_Vector, ThisPointer_CBaseEntity);
if (g_hWeapon_ShootPosition == INVALID_HANDLE)
{
SetFailState("[FireBullets Fix] couldn't hook Weapon_ShootPosition");
}
CloseHandle(gameData);
}
public Action xfix_credits(int client, int args)
{
if (!client)
{
PrintToServer("===================================\nHL2MP - Fixes & Enhancements\n Version: %s\n===================================\n\n\
This plugin is a collection of fixes for Half-Life 2: Deathmatch made possible thanks to:\n \
1) Adrian - Tinnitus Dhooks fix\n\n \
2) Benni - Gravity Gun prop hold fix\n \
3) Chanz - Sprint delay fix\n \
4) Grey83 - Set local angles fix\n \
5) Harper - Creator of xFix and fixing a myriad of HL2MP issues!\n \
6) Peter Brev - Additional HL2MP fixes\n \
7) Sidez - Grenade glow edict fix\n \
8) Toizy - Jesus/T-Pose animation fix\n \
9) V952 - Shotgun lag compensation fix\n \
10) Xutaxkamay - Bullet fix\n\n \
xFix is a continuously updated plugin featuring more fixes as they become available!",
PL_VERSION);
return Plugin_Handled;
}
if (GetCmdReplySource() == SM_REPLY_TO_CHAT) ReplyToCommand(client, "[SM] Check your console for output");
PrintToConsole(client, "===================================\nHL2MP - Fixes & Enhancements\n Version: %s\n===================================\n\n\
This plugin is a collection of fixes for Half-Life 2: Deathmatch made possible thanks to:\n \
1) Adrian - Tinnitus Dhooks fix\n\n \
2) Benni - Gravity Gun prop hold fix\n \
3) Chanz - Sprint delay fix\n \
4) Grey83 - Set local angles fix\n \
5) Harper - Creator of xFix and fixing a myriad of HL2MP issues!\n \
6) Peter Brev - Additional HL2MP fixes\n \
7) Sidez - Grenade glow edict fix\n \
8) Toizy - Jesus/T-Pose animation fix\n \
9) V952 - Shotgun lag compensation fix\n \
10) Xutaxkamay - Bullet fix\n\n \
xFix is a continuously updated plugin featuring more fixes as they become available!",
PL_VERSION);
return Plugin_Handled;
}
public void OnClientCookiesCached(int client)
{
char sPlMdl[8], sFootsteps[8], SndFix[8];
GetClientCookie(client, g_hCookiePlModel, sPlMdl, sizeof(sPlMdl));
GetClientCookie(client, g_hCookieFootsteps, sFootsteps, sizeof(sFootsteps));
GetClientCookie(client, g_hCookieSndFix, SndFix, sizeof(SndFix));
g_bPlayerModel[client] = (sPlMdl[0] != '\0' && StringToInt(sPlMdl));
g_bFootsteps[client] = (sFootsteps[0] != '\0' && StringToInt(sFootsteps));
g_bSndFix[client] = (SndFix[0] != '\0' && StringToInt(SndFix));
}
void q_PluginMessages(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
{
if (result != ConVarQuery_Okay)
return;
if (strcmp(cvarValue, "0") == 0) // Help player turn on plugin messages
{
PrintToChat(client, "\x01[SM] It looks like menu panels cannot be displayed for you. Please type \x04cl_showpluginmessages 1\x01 in your console.");
return;
}
}
void q_fpsmax(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
{
if (!IsClientInGame(client) || IsFakeClient(client))
return;
if (result != ConVarQuery_Okay)
{
KickClient(client, "Client command query \"fps_max\" failed. Reconnect.");
return;
}
int cvar = StringToInt(cvarValue);
if (cvar < GetConVarInt(gConVar.fps_max_min_required) || cvar > GetConVarInt(gConVar.fps_max_max_required))
KickClient(client, "This server requires your \"fps_max\" value to be set between %d and %d. Your value: %d",
GetConVarInt(gConVar.fps_max_min_required), GetConVarInt(gConVar.fps_max_max_required), cvar);
return;
}
public void OnMapStart()
{
for (int i = 1; i < sizeof(g_sWepSnds); i++)
{
PrecacheSound(g_sWepSnds[i]);
}
if (GetConVarInt(gConVar.fps_max_check) == 1)
if (GetConVarInt(gConVar.fps_max_min_required) > GetConVarInt(gConVar.fps_max_max_required)) // in theory, this shouldn't be required, but this is just a safety net
{
// set back to default
SetConVarInt(gConVar.fps_max_min_required, 10);
SetConVarInt(gConVar.fps_max_max_required, 60);
}
CreateTimer(30.0, CheckAngles, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
if (GetConVarInt(gConVar.g_cTimeleftEnable) == 1)
CreateTimer(1.0, Timer_Countdown, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
gbMOTDExists = (FileExists("cfg/motd.txt") && FileSize("cfg/motd.txt") > 2);
gbTeamplay = gConVar.g_cTeamplay.BoolValue;
gbRoundEnd = false;
CreateTimer(0.1, T_CheckPlayerStates, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
public void OnMapEnd()
{
gmKills.Clear();
gmDeaths.Clear();
}
public Action Event_RoundBegin(Event event, const char[] name, bool dontBroadcast)
{
gmTeams.Clear();
gmKills.Clear();
gmDeaths.Clear();
for (int client = 1; client <= MaxClients; client++)
{
if (client < 1 || client > MaxClients || !IsClientInGame(client) || IsFakeClient(client))
continue;
if (IsClientObserver(client))
{
Client_SetHideHud(client, HIDEHUD_HEALTH);
}
}
return Plugin_Continue;
}
Action event_death(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
g_bAr2AltFire[client] = false;
g_bRocketFired[client] = false;
if (GetConVarInt(gConVar.mp_forcerespawn) > 0)
CreateTimer(3.0, t_forcerespawn, client, TIMER_FLAG_NO_MAPCHANGE); // mp_forcerespawn bypass fix
return Plugin_Continue;
}
Action t_forcerespawn(Handle timer, int client)
{
if (IsClientInGame(client) && !IsPlayerAlive(client))
DispatchSpawn(client);
return Plugin_Stop;
}
public void OnClientPutInServer(int iClient)
{
if (GetConVarBool(gConVar.sm_pluginmessages_check))
QueryClientConVar(iClient, "cl_showpluginmessages", q_PluginMessages);
if (GetConVarBool(gConVar.fps_max_check))
QueryClientConVar(iClient, "fps_max", q_fpsmax);
if (!IsFakeClient(iClient))
gExplosionDamageHook.HookEntity(Hook_Pre, iClient, OnClientDamagedByExplosion);
iRocket[iClient] = 0;
iOrb[iClient] = 0;
CreateTimer(60.0, t_AuthCheck, iClient, TIMER_FLAG_NO_MAPCHANGE);
SDKHook(iClient, SDKHook_WeaponSwitchPost, OnClientSwitchWeapon);
DHookEntity(g_hWeapon_ShootPosition, true, iClient, _, Weapon_ShootPosition_Post);
ReplicateTo(iClient, "0");
if (GetConVarBool(gConVar.g_cEnable))
{
int c_Teamplay;
c_Teamplay = GetConVarInt(FindConVar("mp_teamplay"));
if (c_Teamplay == 0)
{
PrintToChatAll("\x04%N \x01is connected.", iClient);
}
}
if (!IsClientSourceTV(iClient))
{
SDKHook(iClient, SDKHook_WeaponCanSwitchTo, Hook_WeaponCanSwitchTo);
SDKHook(iClient, SDKHook_OnTakeDamage, Hook_OnTakeDamage);
if (!gbMOTDExists)
{
// disable showing the MOTD panel if there's nothing to show
CreateTimer(0.5, T_BlockConnectMOTD, iClient, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
MRESReturn OnClientDamagedByExplosion(DHookParam params)
{
return MRES_Supercede; // Prevent ear ringing sound, which may play infinitely (engine DSP bug)
}
public void OnClientPostAdminCheck(int client)
{
g_bAuthenticated[client] = true;
if (IsFakeClient(client)) return;
char id[32];
GetClientAuthId(client, AuthId_Steam2, id, sizeof(id));
for (int i = 1; i <= MaxClients; i++)
{
if (client == i || !IsClientConnected(i))
continue;
char targetid[32];
GetClientAuthId(i, AuthId_Steam2, id, sizeof(id));
// if (StrEqual(id, targetid, false))
if (strcmp(id, targetid, false) == 0)
{
KickClient(i, "SteamID Hijack detected.");
LogMessage("Kicked \"%L\" for hijacking the SteamID of \"%L\".", i, client);
}
}
}
Action t_AuthCheck(Handle timer, int client)
{
if (!IsClientInGame(client) || IsFakeClient(client))
return Plugin_Stop;
if (!g_bAuthenticated[client])
{
KickClient(client, "Steam authentication ticket failed. Reconnect.");
LogMessage("[SM] \"%L\" kicked. Unverified SteamID.");
}
return Plugin_Stop;
}
/******************************
SOUNDS
******************************/
public Action Command_footsteps(int client, int args)
{
if (GetConVarInt(gConVar.sm_hl2_footsteps) == 0)
{
ReplyToCommand(client, "[SM] This server uses only the default footsteps.");
return Plugin_Handled;
}
char sFootsteps[8];
if (g_bFootsteps[client])
{
g_bFootsteps[client] = false;
ReplyToCommand(client, "[SM] HL2 footstep sounds are now enabled.");
IntToString(g_bFootsteps[client], sFootsteps, sizeof(sFootsteps));
SetClientCookie(client, g_hCookieFootsteps, sFootsteps);
return Plugin_Handled;
}
else if (!g_bFootsteps[client])
{
g_bFootsteps[client] = true;
ReplyToCommand(client, "[SM] Default footstep sounds are now enabled.");
IntToString(g_bFootsteps[client], sFootsteps, sizeof(sFootsteps));
SetClientCookie(client, g_hCookieFootsteps, sFootsteps);
return Plugin_Handled;
}
return Plugin_Handled;
}
public Action Command_Sndfix(int client, int args)
{
if (GetConVarInt(gConVar.sm_missing_sounds_fix) == 0)
{
ReplyToCommand(client, "[SM] This server has deactivated the missing sounds fix.");
return Plugin_Handled;
}
char SndFix[8];
if (g_bSndFix[client])
{
g_bSndFix[client] = false;
ReplyToCommand(client, "[SM] Sound fix is now turned on.");
IntToString(g_bSndFix[client], SndFix, sizeof(SndFix));
SetClientCookie(client, g_hCookieSndFix, SndFix);
return Plugin_Handled;
}
else if (!g_bSndFix[client])
{
g_bSndFix[client] = true;
ReplyToCommand(client, "[SM] Sound fix is now turned off.");
IntToString(g_bSndFix[client], SndFix, sizeof(SndFix));
SetClientCookie(client, g_hCookieSndFix, SndFix);
return Plugin_Handled;
}
return Plugin_Handled;
}
public Action OnSound(int iClients[MAXPLAYERS], int &iNumClients, char sSample[PLATFORM_MAX_PATH], int &iEntity, int &iChannel, float &fVolume, int &iLevel, int &iPitch, int &iFlags, char sEntry[PLATFORM_MAX_PATH], int &seed)
{
if (iEntity < 1 || iEntity > MaxClients || !IsClientInGame(iEntity))
return Plugin_Continue;
if (StrContains(sSample, "npc/metropolice/gear", false) != -1 || StrContains(sSample, "npc/combine_soldier/gear", false) != -1 || StrContains(sSample, "npc/footsteps/hardboot_generic", false) != -1)
{
float pos[3];
float ang[3];
GetClientAbsOrigin(iEntity, pos);
ang[0] = 90.0;
ang[1] = 0.0;
ang[2] = 0.0;
char surfname[128];
Handle trace = TR_TraceRayFilterEx(pos, ang, MASK_SHOT | MASK_SHOT_HULL | MASK_WATER, RayType_Infinite, TraceEntityFilter, iEntity);
// int surfflags = TR_GetSurfaceFlags(trace);
TR_GetSurfaceName(trace, surfname, sizeof(surfname));
int surfprops = TR_GetSurfaceProps(trace);
// int surfdisp = TR_GetDisplacementFlags(trace);
CloseHandle(trace);
// PrintToChat(iEntity, "TRMaterial Flags %i Props %i Name %s Disp: %i", surfflags, surfprops, surfname, surfdisp);
if (GetConVarInt(gConVar.sm_hl2_footsteps) == 1)
{
if (!g_bFootsteps[iEntity])
{
if (GetEntityMoveType(iEntity) == MOVETYPE_LADDER)
{
Format(sSample, sizeof(sSample), "player/footsteps/ladder%i.wav", GetRandomInt(1, 4));
}
//else if (StrContains(surfname, "cardboard", false) != -1)
//{
// Format(sSample, sizeof(sSample), "physics/cardboard/cardboard_box_impact_soft%i.wav", GetRandomInt(1, 4));
//}
else if (StrContains(surfname, "ceiling_tile", false) != -1)
{
Format(sSample, sizeof(sSample), "physics/plaster/ceiling_tile_step%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "chainlink", false) != -1 || surfprops == 37)
{
Format(sSample, sizeof(sSample), "player/footsteps/chainlink%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "dirt", false) != -1 || StrContains(surfname, "mud", false) != -1 || surfprops == 9 || surfprops == 10 || surfprops == 44)
{
Format(sSample, sizeof(sSample), "player/footsteps/dirt%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "glass", false) != -1)
{
Format(sSample, sizeof(sSample), "physics/glass/glass_sheet_step%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "grass", false) != -1)
{
Format(sSample, sizeof(sSample), "player/footsteps/grass%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "gravel", false) != -1 || StrContains(surfname, "plaster", false) != -1)
{
Format(sSample, sizeof(sSample), "player/footsteps/gravel%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "metal_box", false) != -1)
{
Format(sSample, sizeof(sSample), "physics/metal/metal_box_footstep%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "metalgrate", false) != -1)
{
Format(sSample, sizeof(sSample), "player/footsteps/metalgrate%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "metalvent", false) != -1)
{
Format(sSample, sizeof(sSample), "player/footsteps/duct%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "sand", false) != -1)
{
Format(sSample, sizeof(sSample), "player/footsteps/sand%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "solidmetal", false) != -1 || surfprops == 3 || surfprops == 8)
{
Format(sSample, sizeof(sSample), "player/footsteps/metal%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "tile", false) != -1)
{
Format(sSample, sizeof(sSample), "player/footsteps/tile%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "wood_box", false) != -1 || StrContains(surfname, "wood_crate", false) != -1)
{
Format(sSample, sizeof(sSample), "physics/wood/wood_box_footstep%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "wood_panel", false) != -1)
{
Format(sSample, sizeof(sSample), "player/footsteps/woodpanel%i.wav", GetRandomInt(1, 4));
}
else if (StrContains(surfname, "wood", false) != -1 || surfprops == 14 || surfprops == 19)
{
Format(sSample, sizeof(sSample), "player/footsteps/wood%i.wav", GetRandomInt(1, 4));
}
else
{
Format(sSample, sizeof(sSample), "player/footsteps/concrete%i.wav", GetRandomInt(1, 4));
}
}
}
}
else if (StrContains(sSample, "npc/footsteps/hardboot_generic", false) == -1)
{
if (GetConVarInt(gConVar.sm_missing_sounds_fix) == 1)
{
if (!g_bSndFix[iEntity])
{
if (strcmp(sSample, "weapons/slam/throw.wav", false) == 0)
{
Format(sSample, sizeof(sSample), "weapons/slam/throw.wav");
}
else if (strcmp(sSample, "weapons/physcannon/physcannon_tooheavy.wav", false) == 0)
{
Format(sSample, sizeof(sSample), "weapons/physcannon/physcannon_tooheavy.wav");
}
else if (strcmp(sSample, ")weapons/physcannon/physcannon_claws_close.wav", false) == 0) // No idea why it needs a closed bracket here.
{
Format(sSample, sizeof(sSample), "weapons/physcannon/physcannon_claws_close.wav");
}
else if (strcmp(sSample, ")weapons/physcannon/physcannon_claws_open.wav", false) == 0) // Same thing here.
{
Format(sSample, sizeof(sSample), "weapons/physcannon/physcannon_claws_close.wav");
}
else if (strcmp(sSample, ")weapons/physcannon/physcannon_pickup.wav", false) == 0) // Same thing here.
{
Format(sSample, sizeof(sSample), "weapons/physcannon/physcannon_pickup.wav");
}
else if (StrContains(sSample, ")weapons/physcannon/physcannon_drop.wav", false) != -1)
{
Format(sSample, sizeof(sSample), "weapons/physcannon/physcannon_drop.wav");
}
else if (strcmp(sSample, "weapons/physcannon/hold_loop.wav", false) == 0) // This one seems broken or not included in the sound hook. I will leave it in there in case Sourcemod gets updated with it working.
{
Format(sSample, sizeof(sSample), "weapons/physcannon/hold_loop.wav");
}
else if (strcmp(sSample, "weapons/crossbow/bolt_load1.wav", false) == 0 || strcmp(sSample, "weapons/crossbow/bolt_load2.wav", false) == 0)
{
Format(sSample, sizeof(sSample), "weapons/crossbow/bolt_load%i.wav", GetRandomInt(1, 2));
}
else return Plugin_Continue;
}
else return Plugin_Continue;
}
else return Plugin_Continue;
}
if (iEntity > 1 && iEntity <= MaxClients && IsClientInGame(iEntity))
{
if (StrContains(sSample, "npc/metropolice/die", false) != -1)
{
Format(sSample, sizeof(sSample), "npc/combine_soldier/die%i.wav", GetRandomInt(1, 3));
return Plugin_Changed;
}
}
for (int iClient = 1; iClient <= MaxClients; iClient++)
{
if (!IsClientConnected(iClient) || !IsClientInGame(iClient))
continue;
EmitSoundToClient(iClient, sSample, iEntity, iChannel, iLevel, iFlags, fVolume * gfVolume, iPitch);
}
return Plugin_Changed;
}
void ReplicateTo(int iClient, const char[] sValue)
{
if (IsClientInGame(iClient) && !IsFakeClient(iClient))
{
gCvar.ReplicateToClient(iClient, sValue);
}
}
void ReplicateToAll(const char[] sValue)
{
for (int iClient = 1; iClient <= MaxClients; iClient++)
{
ReplicateTo(iClient, sValue);
}
}
bool TraceEntityFilter(int entity, int contentsMask, any data)
{