generated from ClaudiuHKS/AdvancedQuakeSounds
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhattrick.sp
1918 lines (1539 loc) · 57.7 KB
/
hattrick.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
/**
* MAIN REQUIREMENTS
*/
#include <sourcemod>
#include <sdktools>
#include <cstrike>
/**
* CUSTOM DEFINITIONS TO BE EDITED
*/
#define _WELCOME_CON_MSG_1_ "Welcome. Committing suicide will not alter your score. Unlimited team changes are allowed. The voting system is enabled."
#define _WELCOME_CON_MSG_2_ "You may /rs, /map, /votemap, /voterr or /voterestart."
#define _WELCOME_MSG_1_ " \x01\x0BWelcome\x01. Committing\x09 suicide\x01 will not alter your\x04 score\x01. Unlimited\x09 team changes\x01 are\x04 allowed\x01. The\x09 voting system\x01 is\x04 enabled\x01."
#define _WELCOME_MSG_2_ " \x01You may\x05 /rs\x01,\x05 /map\x01,\x05 /votemap\x01,\x05 /voterr\x01 or\x05 /voterestart\x01."
#define _SV_MAX_RATE_ (786432) // Maximum INT Value That 'sv_maxrate' Can Have In CS:GO
#define _RATE_CON_MSG_1_ "You are using rate %s. We recommend the maximum, rate %s."
#define _RATE_CON_MSG_2_ "You can type it in your console. You will also need a strong internet connection."
#define _RATE_MSG_1_ " \x01You are using\x05 rate %s\x01. We recommend the maximum,\x09 rate %s\x01."
#define _RATE_MSG_2_ " \x01You can type it in your\x0B console\x01. You will also need a\x04 strong internet connection\x01."
#define _BOT_QUOTA_ (2) // bot_quota
#define _SV_FULL_ALLTALK_ (1) // sv_full_alltalk
#define _SUICIDE_SCORE_ (0) // contributionscore_suicide
#define _SUICIDE_PENALTY_ (0) // mp_suicide_penalty
#define _STEAM_SV_KEYS_KV_FILE_ "SteamSvKeys.TXT"
#define _STEAM_SV_KEYS_KV_TITLE_ "SteamSvKeys"
#define _SV_TICK_RATE_KV_FILE_ "SvTickRate.TXT"
#define _SV_TICK_RATE_KV_TITLE_ "SvTickRate"
#define _DESC_SM_CVAR_ "sm_cvar REQ:CVar OPT:Value - Reveals Or Changes A CVar Value"
#define _DESC_SM_CVAR_COL_ " \x01sm_cvar\x07 REQ:CVar\x0B OPT:Value\x09 -\x05 Reveals Or Changes A CVar Value"
#define _DESC_SM_EXEC_TICK_CFG_ "sm_exec_tick_cfg - Executes The Tick Based Config File"
#define _DESC_SM_EXEC_TICK_CFG_COL_ " \x01sm_exec_tick_cfg\x09 -\x05 Executes The Tick Based Config File"
#define _MIN_DIST_SPAWN_POINTS_ 56.000000
/**
* CUSTOM DEFINITIONS
*/
#define _PREP_OFFS_(%0,%1,%2) if (%1 < 1) %1 = _Get_Offs_(%0, %2)
/**
* CUSTOM INFORMATION
*/
public Plugin myinfo =
{
name = "Hattrick",
author = "CARAMEL® HACK",
description = "Provides Custom Stuff",
version = __DATE__,
url = "https://hattrick.go.ro/",
};
/**
* GLOBAL VARIABLES
*/
static const char g_szGoreEffects[][] =
{
"blood_impact_headshot_01b", \
"blood_impact_headshot_01d", \
"blood_impact_red_01_chunk",
};
static const char g_szIPS[] = "info_particle_system";
static bool g_bMsgShown[MAXPLAYERS] = { false, ... };
static bool g_bRateMsgShown[MAXPLAYERS] = { false, ... };
static Handle g_hBotQuota = INVALID_HANDLE;
static Handle g_hSvFullAllTalk = INVALID_HANDLE;
static Handle g_hHostName = INVALID_HANDLE;
static Handle g_hSvTags = INVALID_HANDLE;
static Handle g_hSuicideScore = INVALID_HANDLE;
static Handle g_hSuicidePenalty = INVALID_HANDLE;
static int g_nPatchSize = -1;
static int g_nPatchOffs = -1;
static int g_nPatchOrigBytes[512] = { 0, ... };
static Address g_hPatchAddr = Address_Null;
static bool g_bLateLoaded = false;
static bool g_bPatchStatus = false;
static bool g_bMapStartedToLoad = false;
static bool g_bPlayerDmgHooked = false;
static bool g_bPlayerDeathHooked = false;
static bool g_bPlayerTeamHooked = false;
static bool g_bQuotaConVarChangeHooked = false;
static bool g_bAllTalkConVarChangeHooked = false;
static bool g_bHostNameConVarChangeHooked = false;
static bool g_bSvTagsConVarChangeHooked = false;
static bool g_bSScoreConVarChangeHooked = false;
static bool g_bSPenConVarChangeHooked = false;
static float g_fRateMsgTimeStamp = 0.0;
/**
* CUSTOM PRIVATE FUNCTIONS
*/
static void _Precache_Gore_Effect_(const char[] szName)
{
static int nEnty = 0;
if (g_bMapStartedToLoad)
{
nEnty = CreateEntityByName(g_szIPS);
if (nEnty > 0)
{
if (IsValidEntity(nEnty))
{
if (DispatchKeyValue(nEnty, "effect_name", szName))
{
if (DispatchSpawn(nEnty))
{
ActivateEntity(nEnty);
AcceptEntityInput(nEnty, "START");
}
}
CreateTimer(1.0, _Timer_Remove_Gore_Effect_, nEnty, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
}
static void _Create_Random_Gore_Effect_(int nVictim, const char[] szName)
{
static float fEyePos[3] = { 0.0, ... }, fEyeAng[3] = { 0.0, ... };
static char szEyeAng[128] = { 0, ... };
static int nEnty = 0;
if (GetRandomInt(1, 2) == 1)
{
nEnty = CreateEntityByName(g_szIPS);
if (nEnty > 0)
{
if (IsValidEntity(nEnty))
{
GetClientEyePosition(nVictim, fEyePos);
if (GetClientEyeAngles(nVictim, fEyeAng))
{
TeleportEntity(nEnty, fEyePos, fEyeAng, NULL_VECTOR);
if (DispatchKeyValue(nEnty, "effect_name", szName))
{
FormatEx(szEyeAng, sizeof (szEyeAng), "%f %f %f", fEyeAng[0], fEyeAng[1], fEyeAng[2]);
if (DispatchKeyValue(nEnty, "angles", szEyeAng))
{
if (DispatchSpawn(nEnty))
{
ActivateEntity(nEnty);
AcceptEntityInput(nEnty, "START");
}
}
}
}
CreateTimer(1.0, _Timer_Remove_Gore_Effect_, nEnty, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
}
static float _Vec_Dis_2D_(const float fPosA[3], const float fPosB[3])
{
static float fTmpPosA[3] = { 0.000000, ... }, fTmpPosB[3] = { 0.000000, ... };
fTmpPosA[0] = fPosA[0];
fTmpPosA[1] = fPosA[1];
fTmpPosA[2] = 0.0;
fTmpPosB[0] = fPosB[0];
fTmpPosB[1] = fPosB[1];
fTmpPosB[2] = 0.0;
return GetVectorDistance(fTmpPosA, fTmpPosB, false);
}
static bool _Create_Dir_(const char[] szDirPath, const int nFlags = \
((FPERM_U_READ | FPERM_U_WRITE | FPERM_U_EXEC) | \
(FPERM_G_READ | FPERM_G_WRITE | FPERM_G_EXEC) | \
(FPERM_O_READ | FPERM_O_WRITE | FPERM_O_EXEC)))
{
static int nIter = 0;
for (nIter = nFlags; nIter != -1; nIter--)
{
if (CreateDirectory(szDirPath, nIter))
{
return true;
}
}
return false;
}
static void _Get_Sv_Full_Ip_(char[] szFullIpAddr, const int nLen)
{
static char net_public_adr[PLATFORM_MAX_PATH] = { 0, ... }, hostip[PLATFORM_MAX_PATH] = { 0, ... },
ip[PLATFORM_MAX_PATH] = { 0, ... }, hostport[PLATFORM_MAX_PATH] = { 0, ... };
static ConVar net_public_adr_h = null, hostip_h = null, ip_h = null, hostport_h = null;
static int hostip_n = 0;
if (net_public_adr_h == null)
{
net_public_adr_h = FindConVar("net_public_adr");
}
if (hostip_h == null)
{
hostip_h = FindConVar("hostip");
}
if (ip_h == null)
{
ip_h = FindConVar("ip");
}
if (hostport_h == null)
{
hostport_h = FindConVar("hostport");
}
if (net_public_adr_h != null)
{
net_public_adr_h.GetString(net_public_adr, sizeof (net_public_adr));
ReplaceStringEx(net_public_adr, sizeof (net_public_adr), "::", ":", 2, 1, true);
}
if (hostip_h != null)
{
hostip_n = hostip_h.IntValue;
FormatEx(hostip, sizeof (hostip), "%d.%d.%d.%d", (hostip_n >> 24) & 0xFF, (hostip_n >> 16) & 0xFF, (hostip_n >> 8) & 0xFF, hostip_n & 0xFF);
}
if (ip_h != null)
{
ip_h.GetString(ip, sizeof (ip));
ReplaceStringEx(ip, sizeof (ip), "::", ":", 2, 1, true);
}
if (hostport_h != null)
{
hostport_h.GetString(hostport, sizeof (hostport));
}
if (IsCharNumeric(net_public_adr[0]))
{
if (FindCharInString(net_public_adr, ':') == -1)
{
FormatEx(szFullIpAddr, nLen, "%s:%s", net_public_adr, hostport);
}
else
{
strcopy(szFullIpAddr, nLen, net_public_adr);
}
}
else if (IsCharNumeric(hostip[0]))
{
if (FindCharInString(hostip, ':') == -1)
{
FormatEx(szFullIpAddr, nLen, "%s:%s", hostip, hostport);
}
else
{
strcopy(szFullIpAddr, nLen, hostip);
}
}
else if (IsCharNumeric(ip[0]))
{
if (FindCharInString(ip, ':') == -1)
{
FormatEx(szFullIpAddr, nLen, "%s:%s", ip, hostport);
}
else
{
strcopy(szFullIpAddr, nLen, ip);
}
}
else if (strlen(net_public_adr) > 0)
{
if (FindCharInString(net_public_adr, ':') == -1)
{
FormatEx(szFullIpAddr, nLen, "%s:%s", net_public_adr, hostport);
}
else
{
strcopy(szFullIpAddr, nLen, net_public_adr);
}
}
else if (strlen(hostip) > 0)
{
if (FindCharInString(hostip, ':') == -1)
{
FormatEx(szFullIpAddr, nLen, "%s:%s", hostip, hostport);
}
else
{
strcopy(szFullIpAddr, nLen, hostip);
}
}
else if (strlen(ip) > 0)
{
if (FindCharInString(ip, ':') == -1)
{
FormatEx(szFullIpAddr, nLen, "%s:%s", ip, hostport);
}
else
{
strcopy(szFullIpAddr, nLen, ip);
}
}
else
{
FormatEx(szFullIpAddr, nLen, ":%s", hostport);
}
}
bool _Get_From_Kv_File_(const char[] szFileTitle, const char[] szFileName, const char[] szEntry, const char[] szKey, char[] szValue, const int nLen)
{
static KeyValues hKv = null;
static char szBuffer[PLATFORM_MAX_PATH] = { 0, ... };
hKv = new KeyValues(szFileTitle);
if (hKv == null)
{
return false;
}
hKv.ImportFromFile(szFileName);
if (!hKv.GotoFirstSubKey())
{
delete hKv;
hKv = null;
return false;
}
do
{
hKv.GetSectionName(szBuffer, sizeof (szBuffer));
if (strcmp(szBuffer, szEntry, false) == 0)
{
hKv.GetString(szKey, szValue, nLen);
delete hKv;
hKv = null;
return true;
}
}
while (hKv.GotoNextKey());
delete hKv;
hKv = null;
return false;
}
static int _CVar_Flags_Str_(ConVar& hConVar, char[] szStr, int nMaxLen)
{
static const char szDesc[][] =
{
"gamedll", "clientdll", "hidden", "protected", "sponly", "notify", "unlogged",
"replicated", "cheat",
};
static const int nFlags[] =
{
FCVAR_GAMEDLL, FCVAR_CLIENTDLL, FCVAR_HIDDEN, FCVAR_PROTECTED, FCVAR_SPONLY, FCVAR_NOTIFY, FCVAR_UNLOGGED,
FCVAR_REPLICATED, FCVAR_CHEAT,
};
static int nConVarFlags = 0, nIter = 0, nFlagsNum = 0;
if (hConVar != null)
{
for (nIter = 0, nFlagsNum = 0, nConVarFlags = hConVar.Flags; nIter < sizeof (nFlags); nIter++)
{
if (nConVarFlags & nFlags[nIter])
{
switch (nFlagsNum)
{
case 0:
{
FormatEx(szStr, nMaxLen, "%s, ", szDesc[nIter]);
nFlagsNum++;
break;
}
default:
{
Format(szStr, nMaxLen, "%s%s, ", szStr, szDesc[nIter]);
nFlagsNum++;
break;
}
}
}
}
if (nFlagsNum > 0)
{
Format(szStr, nMaxLen, "%s$", szStr);
ReplaceStringEx(szStr, nMaxLen, ", $", "", 3, 0, true);
}
return nFlagsNum;
}
return 0;
}
static int _Get_Sv_Tick_Rate_()
{
return RoundToNearest(1.0 / GetTickInterval());
}
static int _Get_Offs_(int nEntity, const char[] szProp)
{
static const char szTables[][] =
{
"CBaseEntity", "CBaseCSEntity",
"CBasePlayer", "CBaseCSPlayer",
"CBaseGrenade", "CBaseCSGrenade",
"CBaseGrenadeProjectile", "CBaseCSGrenadeProjectile",
"CBasePlayerResource", "CBaseCSPlayerResource",
"CBaseViewModel", "CBaseCSViewModel",
"CBaseC4", "CBaseCSC4",
"CBaseAnimating", "CBaseCSAnimating",
"CBaseCombatCharacter", "CBaseCSCombatCharacter",
"CBaseCombatWeapon", "CBaseCSCombatWeapon",
"CBaseWeaponWorldModel", "CBaseCSWeaponWorldModel",
"CBaseRagdoll", "CBaseCSRagdoll",
"CEntity", "CSEntity", "CCSEntity",
"CPlayer", "CSPlayer", "CCSPlayer",
"CGrenade", "CSGrenade", "CCSGrenade",
"CGrenadeProjectile", "CSGrenadeProjectile", "CCSGrenadeProjectile",
"CPlayerResource", "CSPlayerResource", "CCSPlayerResource",
"CViewModel", "CSViewModel", "CCSViewModel",
"CC4", "CSC4", "CCSC4",
"CAnimating", "CSAnimating", "CCSAnimating",
"CCombatCharacter", "CSCombatCharacter", "CCSCombatCharacter",
"CCombatWeapon", "CSCombatWeapon", "CCSCombatWeapon",
"CWeaponWorldModel", "CSWeaponWorldModel", "CCSWeaponWorldModel",
"CRagdoll", "CSRagdoll", "CCSRagdoll",
};
static int nOffs = 0, nTable = 0;
if ((nOffs = FindDataMapInfo(nEntity, szProp)) > 0)
{
return nOffs;
}
for (nTable = 0; nTable < sizeof (szTables); nTable++)
{
if ((nOffs = FindSendPropInfo(szTables[nTable], szProp)) > 0)
{
return nOffs;
}
}
return nOffs;
}
/**
* CUSTOM PUBLIC FORWARDS
*/
public APLRes AskPluginLoad2(Handle hSelf, bool bLateLoaded, char[] szError, int nErrorMaxLen)
{
if (Engine_CSGO != GetEngineVersion())
{
strcopy(szError, nErrorMaxLen, "This Plug-in Only Works On Counter-Strike: Global Offensive");
return APLRes_Failure;
}
g_bLateLoaded = bLateLoaded;
return APLRes_Success;
}
public void OnPluginStart()
{
if (g_bLateLoaded)
{
g_bMapStartedToLoad = true;
}
RegAdminCmd("sm_cvar", _SM_CVar_, ADMFLAG_CONVARS, _DESC_SM_CVAR_, "cvar");
RegAdminCmd("sm_exec_tick_cfg", _SM_Exec_Tick_Cfg_, ADMFLAG_CONFIG, _DESC_SM_EXEC_TICK_CFG_, "exec");
OnMapStart();
OnConfigsExecuted();
}
public void OnMapStart()
{
static char szFullIpAddr[PLATFORM_MAX_PATH] = { 0, ... }, szDataPath[PLATFORM_MAX_PATH] = { 0, ... }, szSteamKeysKvFile[PLATFORM_MAX_PATH] = { 0, ... },
szSteamKey[PLATFORM_MAX_PATH] = { 0, ... }, szTickRateKvFile[PLATFORM_MAX_PATH] = { 0, ... }, szTickRate[PLATFORM_MAX_PATH] = { 0, ... },
szDefaultTickRate[PLATFORM_MAX_PATH] = { 0, ... }, szHours[PLATFORM_MAX_PATH] = { 0, ... }, szCurrentHour[PLATFORM_MAX_PATH] = { 0, ... },
szBuffer[PLATFORM_MAX_PATH] = { 0, ... }, szCfg[PLATFORM_MAX_PATH] = { 0, ... };
static int nIter = 0, nTickInterval = 0, nHostStateInterval = 0, nTickRate = 0, nDefaultTickRate = 0, nTeam = 0, nEnty = 0, m_vecOrigin = 0;
static Address hStartSound = Address_Null, hSpawnServer = Address_Null, hTickInterval = Address_Null, hIntervalPerTick = Address_Null;
static float fPos[3] = { 0.000000, ... }, fAng[3] = { 0.000000, ... }, fExPos[3] = { 0.000000, ... };
static float fIntervalPerTick = 0.0, fDefaultIntervalPerTick = 0.0;
static Handle hData = INVALID_HANDLE;
static bool bSpawn = false;
BuildPath(Path_SM, szDataPath, sizeof (szDataPath), "data");
if (!DirExists(szDataPath))
{
_Create_Dir_(szDataPath);
}
if (DirExists(szDataPath))
{
FormatEx(szSteamKeysKvFile, sizeof (szSteamKeysKvFile), "%s/%s", szDataPath, _STEAM_SV_KEYS_KV_FILE_);
if (FileExists(szSteamKeysKvFile))
{
_Get_Sv_Full_Ip_(szFullIpAddr, sizeof (szFullIpAddr));
if (_Get_From_Kv_File_(_STEAM_SV_KEYS_KV_TITLE_, szSteamKeysKvFile, szFullIpAddr, "sv_setsteamaccount", szSteamKey, sizeof (szSteamKey)))
{
if (strlen(szSteamKey) > 0)
{
if (IsCharNumeric(szSteamKey[0]) || (IsCharAlpha(szSteamKey[0]) && IsCharUpper(szSteamKey[0])))
{
ServerCommand("sv_setsteamaccount %s", szSteamKey);
}
}
}
}
}
if (!g_bPlayerDmgHooked)
{
HookEventEx("player_hurt", _Player_Damage_Ev_, EventHookMode_Post);
g_bPlayerDmgHooked = true;
}
if (!g_bPlayerDeathHooked)
{
HookEventEx("player_death", _Player_Death_, EventHookMode_Post);
g_bPlayerDeathHooked = true;
}
if (!g_bPlayerTeamHooked)
{
HookEventEx("player_team", _Player_Team_, EventHookMode_Post);
g_bPlayerTeamHooked = true;
}
if (g_hBotQuota == INVALID_HANDLE)
{
g_hBotQuota = FindConVar("bot_quota");
}
if (g_hSvFullAllTalk == INVALID_HANDLE)
{
g_hSvFullAllTalk = FindConVar("sv_full_alltalk");
}
if (g_hHostName == INVALID_HANDLE)
{
g_hHostName = FindConVar("hostname");
}
if (g_hSvTags == INVALID_HANDLE)
{
g_hSvTags = FindConVar("sv_tags");
}
if (g_hSuicideScore == INVALID_HANDLE)
{
g_hSuicideScore = FindConVar("contributionscore_suicide");
}
if (g_hSuicidePenalty == INVALID_HANDLE)
{
g_hSuicidePenalty = FindConVar("mp_suicide_penalty");
}
if (g_hBotQuota != INVALID_HANDLE)
{
if (GetConVarInt(g_hBotQuota) != _BOT_QUOTA_)
{
IntToString(_BOT_QUOTA_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hBotQuota, szBuffer, true, true);
}
if (!g_bQuotaConVarChangeHooked)
{
HookConVarChange(g_hBotQuota, _Con_Var_Change_);
g_bQuotaConVarChangeHooked = true;
}
if (GetConVarInt(g_hBotQuota) != _BOT_QUOTA_)
{
IntToString(_BOT_QUOTA_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hBotQuota, szBuffer, true, true);
}
}
if (g_hSvFullAllTalk != INVALID_HANDLE)
{
if (GetConVarInt(g_hSvFullAllTalk) != _SV_FULL_ALLTALK_)
{
IntToString(_SV_FULL_ALLTALK_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSvFullAllTalk, szBuffer, true, true);
}
if (!g_bAllTalkConVarChangeHooked)
{
HookConVarChange(g_hSvFullAllTalk, _Con_Var_Change_);
g_bAllTalkConVarChangeHooked = true;
}
if (GetConVarInt(g_hSvFullAllTalk) != _SV_FULL_ALLTALK_)
{
IntToString(_SV_FULL_ALLTALK_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSvFullAllTalk, szBuffer, true, true);
}
}
if (g_hSuicideScore != INVALID_HANDLE)
{
if (GetConVarInt(g_hSuicideScore) != _SUICIDE_SCORE_)
{
IntToString(_SUICIDE_SCORE_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSuicideScore, szBuffer, true, true);
}
if (!g_bSScoreConVarChangeHooked)
{
HookConVarChange(g_hSuicideScore, _Con_Var_Change_);
g_bSScoreConVarChangeHooked = true;
}
if (GetConVarInt(g_hSuicideScore) != _SUICIDE_SCORE_)
{
IntToString(_SUICIDE_SCORE_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSuicideScore, szBuffer, true, true);
}
}
if (g_hSuicidePenalty != INVALID_HANDLE)
{
if (GetConVarInt(g_hSuicidePenalty) != _SUICIDE_PENALTY_)
{
IntToString(_SUICIDE_PENALTY_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSuicidePenalty, szBuffer, true, true);
}
if (!g_bSPenConVarChangeHooked)
{
HookConVarChange(g_hSuicidePenalty, _Con_Var_Change_);
g_bSPenConVarChangeHooked = true;
}
if (GetConVarInt(g_hSuicidePenalty) != _SUICIDE_PENALTY_)
{
IntToString(_SUICIDE_PENALTY_, szBuffer, sizeof (szBuffer));
SetConVarString(g_hSuicidePenalty, szBuffer, true, true);
}
}
if (g_hHostName != INVALID_HANDLE)
{
if (!g_bHostNameConVarChangeHooked)
{
HookConVarChange(g_hHostName, _Con_Var_Change_);
g_bHostNameConVarChangeHooked = true;
}
}
if (g_hSvTags != INVALID_HANDLE)
{
if (!g_bSvTagsConVarChangeHooked)
{
HookConVarChange(g_hSvTags, _Con_Var_Change_);
g_bSvTagsConVarChangeHooked = true;
}
}
if ((hData = LoadGameConfigFile("hattrick.games")) != INVALID_HANDLE)
{
if
(
(
(g_hPatchAddr = GameConfGetAddress(hData, "WalkMoveMaxSpeed"))
!=
(Address_Null)
)
&&
(
(g_nPatchOffs = GameConfGetOffset(hData, "CappingOffset"))
!=
(-1)
)
&&
(
(g_nPatchSize = GameConfGetOffset(hData, "PatchBytes"))
!=
(-1)
)
)
{
if (!g_bPatchStatus)
{
for (nIter = 0; nIter < g_nPatchSize; nIter++)
{
g_nPatchOrigBytes[nIter] = LoadFromAddress(g_hPatchAddr + view_as<Address>(g_nPatchOffs) + view_as<Address>(nIter), NumberType_Int8);
StoreToAddress(g_hPatchAddr + view_as<Address>(g_nPatchOffs) + view_as<Address>(nIter), 0x90, NumberType_Int8);
}
g_bPatchStatus = true;
}
}
if
(
(
(hStartSound = GameConfGetAddress(hData, "sv_startsound"))
!=
(Address_Null)
)
&&
(
(hSpawnServer = GameConfGetAddress(hData, "spawnserver"))
!=
(Address_Null)
)
&&
(
(nTickInterval = GameConfGetOffset(hData, "m_flTickInterval"))
!=
(-1)
)
&&
(
(nHostStateInterval = GameConfGetOffset(hData, "host_state_interval"))
!=
(-1)
)
)
{
hTickInterval = view_as<Address>(LoadFromAddress(hStartSound + view_as<Address>(nTickInterval), NumberType_Int32));
hIntervalPerTick = view_as<Address>(LoadFromAddress(hSpawnServer + view_as<Address>(nHostStateInterval), NumberType_Int32));
if (hTickInterval != Address_Null && hIntervalPerTick != Address_Null)
{
if (DirExists(szDataPath))
{
FormatEx(szTickRateKvFile, sizeof (szTickRateKvFile), "%s/%s", szDataPath, _SV_TICK_RATE_KV_FILE_);
if (FileExists(szTickRateKvFile))
{
_Get_Sv_Full_Ip_(szFullIpAddr, sizeof (szFullIpAddr));
if (_Get_From_Kv_File_(_SV_TICK_RATE_KV_TITLE_, szTickRateKvFile, szFullIpAddr, "tick_rate", szTickRate, sizeof (szTickRate)))
{
if (_Get_From_Kv_File_(_SV_TICK_RATE_KV_TITLE_, szTickRateKvFile, szFullIpAddr, "default_tick_rate", szDefaultTickRate, sizeof (szDefaultTickRate)))
{
if (_Get_From_Kv_File_(_SV_TICK_RATE_KV_TITLE_, szTickRateKvFile, szFullIpAddr, "hours_for_not_default", szHours, sizeof (szHours)))
{
if (strlen(szTickRate) > 0 && strlen(szDefaultTickRate) > 0 && strlen(szHours) > 0)
{
FormatTime(szCurrentHour, sizeof (szCurrentHour), "%H");
nTickRate = StringToInt(szTickRate);
nDefaultTickRate = StringToInt(szDefaultTickRate);
fIntervalPerTick = 1.0 / float(nTickRate);
fDefaultIntervalPerTick = 1.0 / float(nDefaultTickRate);
if (StrContains(szHours, szCurrentHour) != -1)
{
StoreToAddress(hTickInterval, view_as<int>(fIntervalPerTick), NumberType_Int32);
StoreToAddress(hIntervalPerTick, view_as<int>(fIntervalPerTick), NumberType_Int32);
}
else
{
StoreToAddress(hTickInterval, view_as<int>(fDefaultIntervalPerTick), NumberType_Int32);
StoreToAddress(hIntervalPerTick, view_as<int>(fDefaultIntervalPerTick), NumberType_Int32);
}
}
}
}
}
}
}
}
}
CloseHandle(hData);
hData = INVALID_HANDLE;
}
g_fRateMsgTimeStamp = 0.0;
if (g_bMapStartedToLoad)
{
for (nIter = 0; nIter < sizeof (g_szGoreEffects); nIter++)
{
_Precache_Gore_Effect_(g_szGoreEffects[nIter]);
}
GetCurrentMap(szBuffer, sizeof (szBuffer));
for (nIter = 0; nIter < strlen(szBuffer); nIter++)
{
szBuffer[nIter] = CharToLower(szBuffer[nIter]);
}
hData = CreateKeyValues(szBuffer);
if (hData != INVALID_HANDLE)
{
BuildPath(Path_SM, szCfg, sizeof (szCfg), "configs/spawns_%s.cfg", szBuffer);
if (FileToKeyValues(hData, szCfg))
{
nIter = 0;
FormatEx(szBuffer, sizeof (szBuffer), "spawn_%d_origin", nIter);
KvGetVector(hData, szBuffer, fPos);
while (fPos[0] != 0.000000)
{
FormatEx(szBuffer, sizeof (szBuffer), "spawn_%d_angles", nIter);
KvGetVector(hData, szBuffer, fAng);
fAng[0] = 0.000000;
fAng[2] = 0.000000;
FormatEx(szBuffer, sizeof (szBuffer), "spawn_%d_team", nIter);
nTeam = KvGetNum(hData, szBuffer);
nEnty = INVALID_ENT_REFERENCE;
bSpawn = true;
if (nTeam == CS_TEAM_T)
{
while ((nEnty = FindEntityByClassname(nEnty, "info_player_terrorist")) != INVALID_ENT_REFERENCE)
{
_PREP_OFFS_(nEnty, m_vecOrigin, "m_vecOrigin");
GetEntDataVector(nEnty, m_vecOrigin, fExPos);
if (_Vec_Dis_2D_(fExPos, fPos) < _MIN_DIST_SPAWN_POINTS_)
{
bSpawn = false;
break;
}
}
}
else
{
while ((nEnty = FindEntityByClassname(nEnty, "info_player_counterterrorist")) != INVALID_ENT_REFERENCE)
{
_PREP_OFFS_(nEnty, m_vecOrigin, "m_vecOrigin");
GetEntDataVector(nEnty, m_vecOrigin, fExPos);
if (_Vec_Dis_2D_(fExPos, fPos) < _MIN_DIST_SPAWN_POINTS_)
{
bSpawn = false;
break;
}
}
}
if (bSpawn)
{
nEnty = CreateEntityByName(nTeam == CS_TEAM_T ? "info_player_terrorist" : "info_player_counterterrorist");
if (nEnty > 0)
{
if (IsValidEntity(nEnty))
{
if (DispatchSpawn(nEnty))
{
TeleportEntity(nEnty, fPos, fAng, NULL_VECTOR);
}
}
}
}
FormatEx(szBuffer, sizeof (szBuffer), "spawn_%d_origin", ++nIter);
KvGetVector(hData, szBuffer, fPos);
}
}
CloseHandle(hData);
}
}
}
public void OnConfigsExecuted()
{
static char szHostName[PLATFORM_MAX_PATH] = { 0, ... }, szHostPort[PLATFORM_MAX_PATH] = { 0, ... }, szTags[PLATFORM_MAX_PATH] = { 0, ... },
szTickRate[PLATFORM_MAX_PATH] = { 0, ... };
static ConVar hHostName = null, hHostPort = null, hTags = null;
static int nTickRate = 0;
nTickRate = _Get_Sv_Tick_Rate_();
IntToString(nTickRate, szTickRate, sizeof (szTickRate));
ServerCommand("exec %d_tickrate.cfg", nTickRate);
if (hHostName == null)
{
hHostName = FindConVar("hostname");
}
if (hHostPort == null)