-
Notifications
You must be signed in to change notification settings - Fork 15
/
ckSurf.sp
2174 lines (1925 loc) · 94.1 KB
/
ckSurf.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
/*=============================================
= ckSurf - CS:GO surf Timer *
* By Elzi =
=============================================*/
/*=============================================
= Includes =
=============================================*/
#include <sourcemod>
#include <sdkhooks>
#include <adminmenu>
#include <cstrike>
#include <smlib>
#include <geoip>
#include <basecomm>
#include <colors>
#undef REQUIRE_EXTENSIONS
#include <clientprefs>
#undef REQUIRE_PLUGIN
#include <dhooks>
#include <mapchooser>
#include <ckSurf>
#include <store>
/*====================================
= Declarations =
====================================*/
/*============================================
= Definitions =
=============================================*/
// Require new syntax and semicolons
//#pragma newdecls required
#pragma semicolon 1
// Plugin info
#define VERSION "1.18"
#define PLUGIN_VERSION 118
// Database definitions
#define MYSQL 0
#define SQLITE 1
#define PERCENT 0x25
// Chat colors
#define WHITE 0x01
#define DARKRED 0x02
#define PURPLE 0x03
#define GREEN 0x04
#define MOSSGREEN 0x05
#define LIMEGREEN 0x06
#define RED 0x07
#define ORANGE 0x10
#define GRAY 0x08
#define YELLOW 0x09
#define DARKGREY 0x0A
#define BLUE 0x0B
#define DARKBLUE 0x0C
#define LIGHTBLUE 0x0D
#define PINK 0x0E
#define LIGHTRED 0x0F
// Trail definitions
#define BEAMLIFE 2.0
#define BONUS_BOT_TRAIL_COLOR {255, 255, 0, 255}
#define RECORD_BOT_TRAIl_COLOR {0, 0, 255, 255}
#define RGB_GREEN {0, 255, 0, 255}
#define RGB_RED {255, 0, 0, 255}
#define RGB_DARKRED {139, 0, 0, 255}
#define RGB_BLUE {0, 0, 255, 255}
#define RGB_LIGHTBLUE {178, 223, 238, 255}
#define RGB_DARKBLUE {0, 0, 139, 255}
#define RBG_YELLOW {255, 255, 0, 255}
#define RGB_GREENYELLOW {173, 255, 47, 255}
#define RGB_PURPLE {128, 0, 128, 255}
#define RGB_MAGENTA {255, 0, 255, 255}
#define RGB_PINK {238, 162, 173, 255}
#define RGB_WHITE {248, 248, 255, 255}
#define RGB_CYAN {0, 255, 255, 255}
#define RGB_SPRINGGREEN {0, 255, 127, 255}
#define RGB_OLIVE {192, 255, 62, 255}
#define RGB_ORANGE {238, 154, 0, 255}
#define RGB_GREY {145, 145, 145, 255}
#define RGB_DARKGREY {69, 69, 69, 255}
// Paths
#define CK_REPLAY_PATH "data/cKreplays/"
#define BLOCKED_LIST_PATH "configs/ckSurf/hidden_chat_commands.txt"
#define MULTI_SERVER_MAPCYCLE "configs/ckSurf/multi_server_mapcycle.txt"
#define CUSTOM_TITLE_PATH "configs/ckSurf/custom_chat_titles.txt"
#define SKILLGROUP_PATH "configs/ckSurf/skillgroups.cfg"
#define PRO_FULL_SOUND_PATH "sound/quake/holyshit.mp3"
#define PRO_RELATIVE_SOUND_PATH "*quake/holyshit.mp3"
#define CP_FULL_SOUND_PATH "sound/quake/wickedsick.mp3"
#define CP_RELATIVE_SOUND_PATH "*quake/wickedsick.mp3"
#define UNSTOPPABLE_SOUND_PATH "sound/quake/unstoppable.mp3"
#define UNSTOPPABLE_RELATIVE_SOUND_PATH "*quake/unstoppable.mp3"
// Checkpoint definitions
#define CPLIMIT 35 // Maximum amount of checkpoints in a map
// Zone definitions
#define ZONE_MODEL "models/props/de_train/barrel.mdl"
#define ZONEAMOUNT 9 // The amount of different type of zones - Types: Start(1), End(2), Stage(3), Checkpoint(4), Speed(5), TeleToStart(6), Validator(7), Chekcer(8), Stop(0)
#define MAXZONEGROUPS 11 // Maximum amount of zonegroups in a map
#define MAXZONES 128 // Maximum amount of zones in a map
// Ranking definitions
#define MAX_PR_PLAYERS 1066
#define MAX_SKILLGROUPS 64
// UI definitions
#define HIDE_RADAR (1 << 12)
#define HIDE_CHAT ( 1<<7 )
#define HIDE_CROSSHAIR 1<<8
// Replay definitions
#define BM_MAGIC 0xBAADF00D
#define BINARY_FORMAT_VERSION 0x01
#define ADDITIONAL_FIELD_TELEPORTED_ORIGIN (1<<0)
#define ADDITIONAL_FIELD_TELEPORTED_ANGLES (1<<1)
#define ADDITIONAL_FIELD_TELEPORTED_VELOCITY (1<<2)
#define FRAME_INFO_SIZE 15
#define AT_SIZE 10
#define ORIGIN_SNAPSHOT_INTERVAL 500
#define FILE_HEADER_LENGTH 74
// Title definitions
#define TITLE_COUNT 23 // The amount of custom titles that can be configured in custom_chat_titles.txt
/*====================================
= Enumerations =
====================================*/
enum FrameInfo
{
playerButtons = 0,
playerImpulse,
Float:actualVelocity[3],
Float:predictedVelocity[3],
Float:predictedAngles[2],
CSWeaponID:newWeapon,
playerSubtype,
playerSeed,
additionalFields,
pause,
}
enum AdditionalTeleport
{
Float:atOrigin[3],
Float:atAngles[3],
Float:atVelocity[3],
atFlags
}
enum FileHeader
{
FH_binaryFormatVersion = 0,
String:FH_Time[32],
String:FH_Playername[32],
FH_Checkpoints,
FH_tickCount,
Float:FH_initialPosition[3],
Float:FH_initialAngles[3],
Handle:FH_frames
}
enum MapZone
{
zoneId, // ID within the map
zoneType, // Types: Start(1), End(2), Stage(3), Checkpoint(4), Speed(5), TeleToStart(6), Validator(7), Chekcer(8), Stop(0)
zoneTypeId, // ID of the same type eg. Start-1, Start-2, Start-3...
Float:PointA[3],
Float:PointB[3],
Float:CenterPoint[3],
String:zoneName[128],
zoneGroup,
Vis,
Team
}
enum SkillGroup
{
PointReq, // Points required for next skillgroup
NameColor, // Color to use for name if colored chatnames is turned on
String:RankName[32], // Skillgroup name without colors
String:RankNameColored[32], // Skillgroup name with colors
}
/*===================================
= Plugin Info =
===================================*/
public Plugin myinfo =
{
name = "ckSurf",
author = "Elzi",
description = "#clan.kikkeli's Surf Plugin",
version = VERSION,
url = ""
};
/*=================================
= Variables =
=================================*/
/*---------- Stages ----------*/
int g_Stage[MAXZONEGROUPS][MAXPLAYERS + 1]; // Which stage is the client in
bool g_bhasStages; // Does the map have stages
/*---------- Spawn locations ----------*/
float g_fSpawnLocation[MAXZONEGROUPS][3]; // Spawn coordinates
float g_fSpawnAngle[MAXZONEGROUPS][3]; // Spawn angle
bool g_bGotSpawnLocation[MAXZONEGROUPS]; // Does zonegroup have a spawn location
/*---------- Player titles ----------*/
bool g_bflagTitles[MAXPLAYERS + 1][TITLE_COUNT]; // Which titles have been given for client
bool g_bflagTitles_orig[MAXPLAYERS + 1][TITLE_COUNT]; // Used to track which title the user gained / lost
bool g_bHasTitle[MAXPLAYERS + 1]; // Does the client have any titles
char g_szflagTitle_Colored[TITLE_COUNT][32]; // Titles with colors
char g_szflagTitle[TITLE_COUNT][32]; // Titles loaded from config
int g_iTitleInUse[MAXPLAYERS + 1]; // Which title the client is using
int g_iCustomTitleCount; // How many custom titles are loaded
// Chat Colors in String Format
char szWHITE[12], szDARKRED[12], szPURPLE[12], szGREEN[12], szMOSSGREEN[12], szLIMEGREEN[12], szRED[12], szGRAY[12], szYELLOW[12], szDARKGREY[12], szBLUE[12], szDARKBLUE[12], szLIGHTBLUE[12], szPINK[12], szLIGHTRED[12], szORANGE[12];
bool g_bAdminSelectedHasFlag[MAXPLAYERS + 1]; // Does the client the admin selected have titles?
char g_szAdminSelectedSteamID[MAXPLAYERS + 1][32]; // SteamID of the user admin chose when giving title
bool g_bAdminFlagTitlesTemp[MAXPLAYERS + 1][TITLE_COUNT]; // Which title admin chose to give in !givetitles
int g_iAdminSelectedClient[MAXPLAYERS + 1]; // Which clientid did the admin select
int g_iAdminEditingType[MAXPLAYERS + 1]; // What the admin is editing
/*---------- VIP Variables ----------*/
// Enable VIP CVar
//bool g_bServerVipCommand;
ConVar g_hServerVipCommand;
// Trail variables
bool g_bTrailOn[MAXPLAYERS + 1]; // Client is using a trail
bool g_bTrailApplied[MAXPLAYERS + 1]; // Client has been given a title
bool g_bClientStopped[MAXPLAYERS + 1]; // Client is not moving
int g_iTrailColor[MAXPLAYERS + 1]; // Trail color the client is using
float g_fClientLastMovement[MAXPLAYERS + 1]; // Last time the client moved
// Auto VIP Cvar
int g_AutoVIPFlag;
bool g_bAutoVIPFlag;
ConVar g_hAutoVIPFlag = null;
// Vote Extend
char g_szUsedVoteExtend[MAXPLAYERS+1][32]; // SteamID's which triggered extend vote
int g_VoteExtends = 0; // How many extends have happened in current map
ConVar g_hVoteExtendTime; // Extend time CVar
ConVar g_hMaxVoteExtends; // Extend max count CVar
/*---------- Bonus variables ----------*/
char g_szBonusFastest[MAXZONEGROUPS][MAX_NAME_LENGTH]; // Name of the #1 in the current maps bonus
char g_szBonusFastestTime[MAXZONEGROUPS][64]; // Fastest bonus time in 00:00:00:00 format
float g_fPersonalRecordBonus[MAXZONEGROUPS][MAXPLAYERS + 1]; // Clients personal bonus record in the current map
char g_szPersonalRecordBonus[MAXZONEGROUPS][MAXPLAYERS + 1][64]; // Personal bonus record in 00:00:00 format
float g_fBonusFastest[MAXZONEGROUPS]; // Fastest bonus time in the current map
float g_fOldBonusRecordTime[MAXZONEGROUPS]; // Old record time, for prints + counting
int g_MapRankBonus[MAXZONEGROUPS][MAXPLAYERS + 1]; // Clients personal bonus rank in the current map
int g_OldMapRankBonus[MAXZONEGROUPS][MAXPLAYERS + 1]; // Old rank in bonus
int g_bMissedBonusBest[MAXPLAYERS + 1]; // Has the client mbissed his best bonus time
int g_tmpBonusCount[MAXZONEGROUPS]; // Used to make sure bonus finished prints are correct
int g_iBonusCount[MAXZONEGROUPS]; // Amount of players that have passed the bonus in current map
int g_totalBonusCount; // How many total bonuses there are
bool g_bhasBonus; // Does map have a bonus?
/*---------- Checkpoint variables ----------*/
float g_fCheckpointTimesRecord[MAXZONEGROUPS][MAXPLAYERS + 1][CPLIMIT]; // Clients best run's times
float g_fCheckpointTimesNew[MAXZONEGROUPS][MAXPLAYERS + 1][CPLIMIT]; // Clients current run's times
float g_fCheckpointServerRecord[MAXZONEGROUPS][CPLIMIT]; // Server record checkpoint times
char g_szLastSRDifference[MAXPLAYERS + 1][64]; // Last difference to the server record checkpoint
char g_szLastPBDifference[MAXPLAYERS + 1][64]; // Last difference to clients own record checkpoint
float g_fLastDifferenceTime[MAXPLAYERS + 1]; // The time difference was shown, used to show for a few seconds in timer panel
float tmpDiff[MAXPLAYERS + 1]; // Used to calculate time gain / lost
int lastCheckpoint[MAXZONEGROUPS][MAXPLAYERS + 1]; // Used to track which checkpoint was last reached
bool g_bCheckpointsFound[MAXZONEGROUPS][MAXPLAYERS + 1]; // Clients checkpoints have been found?
bool g_bCheckpointRecordFound[MAXZONEGROUPS]; // Map record checkpoints found?
float g_fMaxPercCompleted[MAXPLAYERS + 1]; // The biggest % amount the player has reached in current map
/*---------- Advert variables ----------*/
int g_Advert; // Defines which advert to play
/*---------- Maptier Variables ----------*/
char g_sTierString[MAXZONEGROUPS][512]; // The string for each zonegroup
bool g_bTierEntryFound; // Tier data found?
bool g_bTierFound[MAXZONEGROUPS]; // Tier data found in ZGrp
Handle AnnounceTimer[MAXPLAYERS + 1]; // Tier announce timer
/*---------- Zone Variables ----------*/
// Client
bool g_bIgnoreZone[MAXPLAYERS + 1]; // Ignore end zone end touch if teleporting from inside a zone
int g_iClientInZone[MAXPLAYERS + 1][4]; // Which zone the client is in 0 = ZoneType, 1 = ZoneTypeId, 2 = ZoneGroup, 3 = ZoneID
// Zone Counts & Data
int g_mapZonesTypeCount[MAXZONEGROUPS][ZONEAMOUNT]; // Zone type count in each zoneGroup
char g_szZoneGroupName[MAXZONEGROUPS][128]; // Zone group's name
int g_mapZones[MAXZONES][MapZone]; // Map Zone array
int g_mapZonesCount; // The total amount of zones in the map
int g_mapZoneCountinGroup[MAXZONEGROUPS]; // Map zone count in zonegroups
int g_mapZoneGroupCount; // Zone group cound
float g_fZoneCorners[MAXZONES][8][3]; // Additional zone corners, can't store multi dimensional arrays in enums..
// Editing zones
bool g_bEditZoneType[MAXPLAYERS + 1]; // If editing zone type
char g_CurrentZoneName[MAXPLAYERS + 1][64]; // Selected zone's name
float g_Positions[MAXPLAYERS + 1][2][3]; // Selected zone's position
float g_fBonusStartPos[MAXPLAYERS + 1][2][3]; // Bonus start zone position
float g_fBonusEndPos[MAXPLAYERS + 1][2][3]; // Bonus end zone positions
float g_AvaliableScales[5] = { 1.0, 5.0, 10.0, 50.0, 100.0 }; // Scaling options
int g_CurrentSelectedZoneGroup[MAXPLAYERS + 1]; // Currently selected zonegroup
int g_CurrentZoneTeam[MAXPLAYERS + 1]; // Current zone team TODO: Remove
int g_CurrentZoneVis[MAXPLAYERS + 1]; // Current zone visibility per team TODO: Remove
int g_CurrentZoneType[MAXPLAYERS + 1]; // Currenyly selected zone's type
int g_Editing[MAXPLAYERS + 1]; // What state of editing is happening eg. editing, creating etc.
int g_ClientSelectedZone[MAXPLAYERS + 1] = { -1, ... }; // Currently selected zone id
int g_ClientSelectedScale[MAXPLAYERS + 1]; // Currently selected scale
int g_ClientSelectedPoint[MAXPLAYERS + 1]; // Currently selected point
int g_CurrentZoneTypeId[MAXPLAYERS + 1]; // Currently selected zone's type ID
bool g_ClientRenamingZone[MAXPLAYERS + 1]; // Is client renaming zone?
int beamColorT[] = { 255, 0, 0, 255 }; // Zone team colors TODO: remove
int beamColorCT[] = { 0, 0, 255, 255 };
int beamColorN[] = { 255, 255, 0, 255 };
int beamColorM[] = { 0, 255, 0, 255 };
char g_szZoneDefaultNames[ZONEAMOUNT][128] = { "Stop", "Start", "End", "Stage", "Checkpoint", "SpeedStart", "TeleToStart", "Validator", "Checker" }; // Default zone names
int g_BeamSprite; // Zone sprites
int g_HaloSprite;
/*---------- PushFix by Mev, George & Blacky ----------*/
/*---------- https://forums.alliedmods.net/showthread.php?t=267131 ----------*/
ConVar g_hTriggerPushFixEnable;
bool g_bPushing[MAXPLAYERS + 1];
/*---------- Slope Boost Fix by Mev & Blacky ----------*/
/*---------- https://forums.alliedmods.net/showthread.php?t=266888 ----------*/
float g_vCurrent[MAXPLAYERS + 1][3];
float g_vLast[MAXPLAYERS + 1][3];
bool g_bOnGround[MAXPLAYERS + 1];
bool g_bLastOnGround[MAXPLAYERS + 1];
bool g_bFixingRamp[MAXPLAYERS + 1];
ConVar g_hSlopeFixEnable;
/*---------- Forwards ----------*/
Handle g_MapFinishForward;
Handle g_BonusFinishForward;
Handle g_PracticeFinishForward;
/*---------- CVars ----------*/
// Zones
int g_ZoneMenuFlag;
ConVar g_hZoneMenuFlag = null;
ConVar g_hZoneDisplayType = null; // How zones are displayed (lower edge, full)
ConVar g_hZonesToDisplay = null; // Which zones are displayed
ConVar g_hChecker; // Zone refresh rate
Handle g_hZoneTimer = INVALID_HANDLE;
//Zone Colors
int g_iZoneColors[ZONEAMOUNT+2][4]; // ZONE COLOR TYPES: Stop(0), Start(1), End(2), BonusStart(3), BonusEnd(4), Stage(5),
char g_szZoneColors[ZONEAMOUNT+2][24]; // Checkpoint(6), Speed(7), TeleToStart(8), Validator(9), Chekcer(10)
ConVar g_hzoneStartColor = null;
ConVar g_hzoneEndColor = null;
ConVar g_hzoneBonusStartColor = null;
ConVar g_hzoneBonusEndColor = null;
ConVar g_hzoneStageColor = null;
ConVar g_hzoneCheckpointColor = null;
ConVar g_hzoneSpeedColor = null;
ConVar g_hzoneTeleToStartColor = null;
ConVar g_hzoneValidatorColor = null;
ConVar g_hzoneCheckerColor = null;
ConVar g_hzoneStopColor = null;
ConVar g_hAnnounceRecord; // Announce rank type: 0 announce all, 1 announce only PB's, 3 announce only SR's
ConVar g_hCommandToEnd; // !end Enable / Disable
ConVar g_hWelcomeMsg = null;
ConVar g_hReplayBotPlayerModel = null;
ConVar g_hReplayBotArmModel = null; // Replay bot arm model
ConVar g_hPlayerModel = null; // Player models
ConVar g_hArmModel = null; // Player arm models
ConVar g_hcvarRestore = null; // Restore player's runs?
ConVar g_hNoClipS = null; // Allow noclip?
ConVar g_hReplayBot = null; // Replay bot?
ConVar g_hBackupReplays = null; // Back up replay bots?
ConVar g_hReplaceReplayTime = null; // Replace replay times, even if not SR
ConVar g_hAllowVipMute = null; // Allow VIP's to mute?
ConVar g_hTeleToStartWhenSettingsLoaded = null;
bool g_bMapReplay; // Why two bools?
ConVar g_hBonusBot = null; // Bonus bot?
bool g_bMapBonusReplay[MAXZONEGROUPS];
ConVar g_hColoredNames = null; // Colored names in chat?
ConVar g_hPauseServerside = null; // Allow !pause?
ConVar g_hChallengePoints = null; // Allow betting points in challenges?
ConVar g_hAutoBhopConVar = null; // Allow autobhop?
bool g_bAutoBhop;
ConVar g_hDynamicTimelimit = null; // Dynamic timelimit?
ConVar g_hAdminClantag = null; // Admin clan tag?
ConVar g_hConnectMsg = null; // Connect message?
ConVar g_hDisconnectMsg = null; // Disconnect message?
ConVar g_hRadioCommands = null; // Allow radio commands?
ConVar g_hInfoBot = null; // Info bot?
ConVar g_hAttackSpamProtection = null; // Throttle shooting?
int g_AttackCounter[MAXPLAYERS + 1]; // Used to calculate player shots
ConVar g_hGoToServer = null; // Allow !goto?
ConVar g_hAllowRoundEndCvar = null; // Allow round ending?
bool g_bRoundEnd; // Why two bools?
ConVar g_hPlayerSkinChange = null; // Allow changing player models?
ConVar g_hCountry = null; // Display countries for players?
ConVar g_hAutoRespawn = null; // Respawn players automatically?
ConVar g_hCvarNoBlock = null; // Allow player blocking?
ConVar g_hPointSystem = null; // Use the point system?
ConVar g_hCleanWeapons = null; // Clean weapons from ground?
int g_ownerOffset; // Used to clear weapons from ground
ConVar g_hCvarGodMode = null; // Enable god mode?
//ConVar g_hAutoTimer = null;
ConVar g_hMapEnd = null; // Allow map ending?
ConVar g_hAutohealing_Hp = null; // Automatically heal lost HP?
ConVar g_hExtraPoints = null; // How many extra points for improving times?
ConVar g_hExtraPoints2 = null; // How many extra points for finishing a map for the first time?
// Bot Colors & effects:
ConVar g_hReplayBotColor = null; // Replay bot color
int g_ReplayBotColor[3];
ConVar g_hBonusBotColor = null; // Bonus bot color
int g_BonusBotColor[3];
ConVar g_hBonusBotTrail = null; // Bonus bot trail?
ConVar g_hRecordBotTrail = null; // Record bot trail?
ConVar g_hReplayBotTrailColor = null; // Replay bot trail color
int g_ReplayBotTrailColor[4];
ConVar g_hBonusBotTrailColor = null; // Bonus bot trail color
int g_BonusBotTrailColor[4];
ConVar g_hDoubleRestartCommand; // Double !r restart
ConVar g_hStartPreSpeed = null; // Start zone speed cap
ConVar g_hSpeedPreSpeed = null; // Speed Start zone speed cap
ConVar g_hBonusPreSpeed = null; // Bonus start zone speed cap
ConVar g_hSoundEnabled = null; // Enable timer start sound
ConVar g_hSoundPath = null; // Define start sound
//char sSoundPath[64];
ConVar g_hSpawnToStartZone = null; // Teleport on spawn to start zone
ConVar g_hAnnounceRank = null; // Min rank to announce in chat
ConVar g_hForceCT = null; // Force players CT
ConVar g_hChatSpamFilter = null; // Chat spam limiter
float g_fLastChatMessage[MAXPLAYERS + 1]; // Last message time
int g_messages[MAXPLAYERS + 1]; // Spam message count
ConVar g_henableChatProcessing = null; // Is chat processing enabled
ConVar g_hMultiServerMapcycle = null; // Use multi server mapcycle
/*---------- SQL Variables ----------*/
Handle g_hDb = null; // SQL driver
int g_DbType; // Database type
bool g_bInTransactionChain = false; // Used to check if SQL changes are being made
int g_failedTransactions[7]; // Used to track failed transactions when making database changes
bool g_bRenaming = false; // Used to track if sql tables are being renamed
bool g_bSettingsLoaded[MAXPLAYERS + 1]; // Used to track if a players settings have been loaded
bool g_bLoadingSettings[MAXPLAYERS + 1]; // Used to track if players settings are being loaded
bool g_bServerDataLoaded; // Are the servers settings loaded
char g_szRecordMapSteamID[MAX_NAME_LENGTH]; // SteamdID of #1 player in map, used to fetch checkpoint times
int g_iServerHibernationValue;
/*---------- User Commands ----------*/
float g_flastClientUsp[MAXPLAYERS + 1]; // Throttle !usp command
float g_fLastCommandBack[MAXPLAYERS + 1]; // Throttle !back to prevent desync on record bots
bool g_insertingInformation; // Used to check if a admin is inserting zone or maptier information, don't allow many at the same time
bool g_bNoClip[MAXPLAYERS + 1]; // Client is noclipping
/*---------- User Options ----------*/
// org variables track the original setting status, on disconnect, check if changed, if so, update new settings to database
bool g_bHideChat[MAXPLAYERS + 1]; // Hides chat
bool g_borg_HideChat[MAXPLAYERS + 1];
bool g_bViewModel[MAXPLAYERS + 1]; // Hides viewmodel
bool g_borg_ViewModel[MAXPLAYERS + 1];
bool g_bCheckpointsEnabled[MAXPLAYERS + 1]; // Command to disable checkpoints
bool g_borg_CheckpointsEnabled[MAXPLAYERS + 1];
bool g_bActivateCheckpointsOnStart[MAXPLAYERS + 1]; // Did client enable checkpoints? Then start using them again on the next run
bool g_bEnableQuakeSounds[MAXPLAYERS + 1]; // Enable quake sounds?
bool g_borg_EnableQuakeSounds[MAXPLAYERS + 1];
bool g_bShowNames[MAXPLAYERS + 1]; // TODO: remove
bool g_borg_ShowNames[MAXPLAYERS + 1];
bool g_bStartWithUsp[MAXPLAYERS + 1]; // TODO: Remove
bool g_borg_StartWithUsp[MAXPLAYERS + 1];
bool g_bShowTime[MAXPLAYERS + 1]; // TODO: Remove
bool g_borg_ShowTime[MAXPLAYERS + 1];
bool g_bHide[MAXPLAYERS + 1]; // Hide other players?
bool g_borg_Hide[MAXPLAYERS + 1];
bool g_bShowSpecs[MAXPLAYERS + 1]; // Show spectator list?
bool g_borg_ShowSpecs[MAXPLAYERS + 1];
bool g_bGoToClient[MAXPLAYERS + 1]; // Allow !goto
bool g_borg_GoToClient[MAXPLAYERS + 1];
bool g_bAutoBhopClient[MAXPLAYERS + 1]; // Use auto bhop?
bool g_borg_AutoBhopClient[MAXPLAYERS + 1];
bool g_bInfoPanel[MAXPLAYERS + 1]; // Client is showing the info panel
bool g_borg_InfoPanel[MAXPLAYERS + 1];
/*---------- Run Variables ----------*/
float g_fPersonalRecord[MAXPLAYERS + 1]; // Clients personal record in map
bool g_bTimeractivated[MAXPLAYERS + 1]; // Is clients timer running
bool g_bValidRun[MAXPLAYERS + 1]; // Used to check if a clients run is valid in validator and checker zones
bool g_bBonusFirstRecord[MAXPLAYERS + 1]; // First bonus time in map?
bool g_bBonusPBRecord[MAXPLAYERS + 1]; // Personal best time in bonus
bool g_bBonusSRVRecord[MAXPLAYERS + 1]; // New server record in bonus
char g_szBonusTimeDifference[MAXPLAYERS + 1]; // How many seconds were improved / lost in that run
float g_fStartTime[MAXPLAYERS + 1]; // Time when run was started
float g_fFinalTime[MAXPLAYERS + 1]; // Total time the run took
char g_szFinalTime[MAXPLAYERS + 1][32]; // Total time the run took in 00:00:00 format
float g_fPauseTime[MAXPLAYERS + 1]; // Time spent in !pause this run
float g_fStartPauseTime[MAXPLAYERS + 1]; // Time when !pause started
float g_fCurrentRunTime[MAXPLAYERS + 1]; // Current runtime
bool g_bMissedMapBest[MAXPLAYERS + 1]; // Missed personal record time?
bool g_bMapFirstRecord[MAXPLAYERS + 1]; // Was players run his first time finishing the map?
bool g_bMapPBRecord[MAXPLAYERS + 1]; // Was players run his personal best?
bool g_bMapSRVRecord[MAXPLAYERS + 1]; // Was players run the new server record?
char g_szTimeDifference[MAXPLAYERS + 1][32]; // Used to print the client's new times difference to record
float g_fRecordMapTime; // Record map time in seconds
char g_szRecordMapTime[64]; // Record map time in 00:00:00 format
char g_szPersonalRecord[MAXPLAYERS + 1][64]; // Client's peronal record in 00:00:00 format
float g_favg_maptime; // Average map time
float g_fAvg_BonusTime[MAXZONEGROUPS]; // Average bonus times TODO: Combine with g_favg_maptime
bool g_bFirstTimerStart[MAXPLAYERS + 1]; // If timer is started for the first time, print avg times
bool g_bPause[MAXPLAYERS + 1]; // Client has timer paused
int g_MapTimesCount; // How many times the map has been beaten
int g_MapRank[MAXPLAYERS + 1]; // Clients rank in current map
int g_OldMapRank[MAXPLAYERS + 1]; // Clients old rank
char g_szRecordPlayer[MAX_NAME_LENGTH]; // Current map's record player's name
/*---------- Replay Variables ----------*/
bool g_bNewRecordBot; // Checks if the bot is new, if so, set weapon
bool g_bNewBonusBot; // Checks if the bot is new, if so, set weapon
Handle g_hTeleport = null; // Used to track teleportations
Handle g_hRecording[MAXPLAYERS + 1]; // Client is beign recorded
Handle g_hLoadedRecordsAdditionalTeleport = null;
Handle g_hRecordingAdditionalTeleport[MAXPLAYERS + 1];
Handle g_hBotMimicsRecord[MAXPLAYERS + 1] = { null, ... }; // Is mimicing a record
Handle g_hBotTrail[2] = { null, null }; // Timer to refresh bot trails
float g_fInitialPosition[MAXPLAYERS + 1][3]; // Replay start position
float g_fInitialAngles[MAXPLAYERS + 1][3]; // Replay start angle
bool g_bValidTeleportCall[MAXPLAYERS + 1]; // Is teleport valid?
bool g_bNewReplay[MAXPLAYERS + 1]; // Don't allow starting a new run if saving a record run
bool g_bNewBonus[MAXPLAYERS + 1]; // Don't allow starting a new run if saving a record run
int g_BotMimicRecordTickCount[MAXPLAYERS + 1] = { 0, ... };
int g_BotActiveWeapon[MAXPLAYERS + 1] = { -1, ... };
int g_CurrentAdditionalTeleportIndex[MAXPLAYERS + 1];
int g_RecordedTicks[MAXPLAYERS + 1];
int g_RecordPreviousWeapon[MAXPLAYERS + 1];
int g_OriginSnapshotInterval[MAXPLAYERS + 1];
int g_BotMimicTick[MAXPLAYERS + 1] = { 0, ... };
int g_RecordBot = -1; // Record bot client ID
int g_BonusBot = -1; // Bonus bot client ID
int g_InfoBot = -1; // Info bot client ID
bool g_bReplayAtEnd[MAXPLAYERS + 1]; // Replay is at the end
float g_fReplayRestarted[MAXPLAYERS + 1]; // Make replay stand still for long enough for trail to die
char g_szReplayName[128]; // Replay bot name
char g_szReplayTime[128]; // Replay bot time
char g_szBonusName[128]; // Replay bot name
char g_szBonusTime[128]; // Replay bot time
int g_BonusBotCount;
int g_iCurrentBonusReplayIndex;
int g_iBonusToReplay[MAXZONEGROUPS + 1];
float g_fReplayTimes[MAXZONEGROUPS];
/*---------- Misc ----------*/
Handle g_MapList = null; // Used to load the mapcycle
float g_fMapStartTime; // Used to check if a player just joined the server
Handle g_hSkillGroups = null; // Array that holds SkillGroup objects in it
// Use !r twice to restart the run
float g_fErrorMessage[MAXPLAYERS + 1]; // Used to limit error message spam too often
float g_fClientRestarting[MAXPLAYERS + 1]; // Used to track the time the player took to write the second !r, if too long, reset the boolean
bool g_bClientRestarting[MAXPLAYERS + 1]; // Client wanted to restart run
float g_fLastTimeNoClipUsed[MAXPLAYERS + 1]; // Last time the client used noclip
bool g_bRespawnPosition[MAXPLAYERS + 1]; // Does client have a respawn location in memory?
float g_fLastSpeed[MAXPLAYERS + 1]; // Client's last speed, used in panels
bool g_bLateLoaded = false; // Was plugin loaded late?
bool g_bMapChooser; // Known mapchooser loaded? Used to update info bot
bool g_bClientOwnReason[MAXPLAYERS + 1]; // If call admin, ignore chat message
bool g_bNoClipUsed[MAXPLAYERS + 1]; // Has client used noclip to gain current speed
bool g_bOverlay[MAXPLAYERS + 1]; // Map finished overlay
bool g_bSpectate[MAXPLAYERS + 1]; // Is client spectating
bool g_bFirstTeamJoin[MAXPLAYERS + 1]; // First time client joined game, show start messages & start timers
bool g_bFirstSpawn[MAXPLAYERS + 1]; // First time client spawned
bool g_bSelectProfile[MAXPLAYERS + 1];
bool g_specToStage[MAXPLAYERS + 1]; // Is client teleporting from spectate?
float g_fTeleLocation[MAXPLAYERS + 1][3]; // Location where client is spawned from spectate
int g_ragdolls = -1; // Used to clear ragdolls from ground
int g_Server_Tickrate; // Server tickrate
int g_SpecTarget[MAXPLAYERS + 1]; // Who the client is spectating?
int g_LastButton[MAXPLAYERS + 1]; // Buttons the client is using, used to show them when specating
int g_MVPStars[MAXPLAYERS + 1]; // The amount of MVP's a client has TODO: make sure this is used everywhere
int g_PlayerChatRank[MAXPLAYERS + 1]; // What color is client's name in chat (based on rank)
char g_pr_chat_coloredrank[MAXPLAYERS + 1][128]; // Clients rank, colored, used in chat
char g_pr_rankname[MAXPLAYERS + 1][32]; // Client's rank, non-colored, used in clantag
char g_szMapPrefix[2][32]; // Map's prefix, used to execute prefix cfg's
char g_szMapName[128]; // Current map's name
char g_szPlayerPanelText[MAXPLAYERS + 1][512]; // Info panel text when spectating
char g_szCountry[MAXPLAYERS + 1][100]; // Country codes
char g_szCountryCode[MAXPLAYERS + 1][16]; // Country codes
char g_szSteamID[MAXPLAYERS + 1][32]; // Client's steamID
char g_BlockedChatText[256][256]; // Blocked chat commands
float g_fLastOverlay[MAXPLAYERS + 1]; // Last time an overlay was displayed
/*---------- Player location restoring ----------*/
bool g_bPositionRestored[MAXPLAYERS + 1]; // Clients location was restored this run
bool g_bRestorePositionMsg[MAXPLAYERS + 1]; // Show client restore message?
bool g_bRestorePosition[MAXPLAYERS + 1]; // Clients position is being restored
float g_fPlayerCordsLastPosition[MAXPLAYERS + 1][3]; // Client's last location, used on recovering run and coming back from spectate
float g_fPlayerLastTime[MAXPLAYERS + 1]; // Client's last time, used on recovering run and coming back from spec
float g_fPlayerAnglesLastPosition[MAXPLAYERS + 1][3]; // Client's last angles, used on recovering run and coming back from spec
float g_fPlayerCordsRestore[MAXPLAYERS + 1][3]; // Used in restoring players location
float g_fPlayerAnglesRestore[MAXPLAYERS + 1][3]; // Used in restoring players angle
/*---------- Menus ----------*/
Menu g_menuTopSurfersMenu[MAXPLAYERS + 1] = null;
float g_fProfileMenuLastQuery[MAXPLAYERS + 1]; // Last time profile was queried by player, spam protection
int g_MenuLevel[MAXPLAYERS + 1]; // Tracking menu level
int g_OptionsMenuLastPage[MAXPLAYERS + 1]; // Weird options menu tricker TODO: wtf
char g_pr_szrank[MAXPLAYERS + 1][512]; // Client's rank string displayed in !profile
char g_szProfileName[MAXPLAYERS + 1][MAX_NAME_LENGTH]; // !Profile name
char g_szProfileSteamId[MAXPLAYERS + 1][32];
// Admin
int g_AdminMenuFlag; // Admin flag required for !ckadmin
ConVar g_hAdminMenuFlag = null;
Handle g_hAdminMenu = null; // Add !ckadmin to !admin
int g_AdminMenuLastPage[MAXPLAYERS + 1]; // Weird admin menu trickery TODO: wtf
/*---------- Challenge variables ----------*/
/**
TODO:
- Recode completely
*/
float g_fChallenge_RequestTime[MAXPLAYERS + 1]; // How long a challenge request is available
float g_fSpawnPosition[MAXPLAYERS + 1][3]; // Challenge start location
bool g_bChallenge_Checkpoints[MAXPLAYERS + 1]; // Allow checkpoints in challenge. TODO: remove
bool g_bChallenge_Abort[MAXPLAYERS + 1]; // Abort challenge
bool g_bChallenge[MAXPLAYERS + 1];
bool g_bChallenge_Request[MAXPLAYERS + 1];
int g_pr_PointUnit;
int g_Challenge_Bet[MAXPLAYERS + 1];
int g_Challenge_WinRatio[MAX_PR_PLAYERS + 1];
int g_CountdownTime[MAXPLAYERS + 1];
int g_Challenge_PointsRatio[MAX_PR_PLAYERS + 1];
char g_szChallenge_OpponentID[MAXPLAYERS + 1][32];
/*---------- Player Points ----------*/
float g_pr_finishedmaps_perc[MAX_PR_PLAYERS + 1]; // % of maps the client has finished
bool g_pr_RankingRecalc_InProgress; // Is point recalculation in progress?
bool g_pr_Calculating[MAXPLAYERS + 1]; // Clients points are being calculated
bool g_bProfileRecalc[MAX_PR_PLAYERS + 1]; // Has this profile been recalculated?
bool g_bManualRecalc; // Point recalculation type
bool g_pr_showmsg[MAXPLAYERS + 1]; // Print the amount of gained points to chat?
bool g_bRecalcRankInProgess[MAXPLAYERS + 1]; // Is clients points being recalculated?
int g_pr_Recalc_ClientID = 0; // Client ID being recalculated
int g_pr_Recalc_AdminID = -1; // ClientID that started the recalculation
int g_pr_AllPlayers; // Ranked player count on server
int g_pr_RankedPlayers; // Player count with points
int g_pr_MapCount; // Total map count in mapcycle
int g_pr_TableRowCount; // The amount of clients that get recalculated in a full recalculation
int g_pr_points[MAX_PR_PLAYERS + 1]; // Clients points
int g_pr_oldpoints[MAX_PR_PLAYERS + 1]; // Clients points before recalculation
int g_pr_multiplier[MAX_PR_PLAYERS + 1]; // How many times has the client improved on his times
int g_pr_finishedmaps[MAX_PR_PLAYERS + 1]; // How many maps a client has finished
int g_PlayerRank[MAXPLAYERS + 1]; // Players server rank
int g_MapRecordCount[MAXPLAYERS + 1]; // SR's the client has
char g_pr_szName[MAX_PR_PLAYERS + 1][64]; // Used to update client's name in database
char g_pr_szSteamID[MAX_PR_PLAYERS + 1][32]; // steamid of client being recalculated
/*---------- Practice Mode ----------*/
float g_fCheckpointVelocity_undo[MAXPLAYERS + 1][3]; // Velocity at checkpoint that is on !undo
float g_fCheckpointVelocity[MAXPLAYERS + 1][3]; // Current checkpoints velocity
float g_fCheckpointLocation[MAXPLAYERS + 1][3]; // Current checkpoint location
float g_fCheckpointLocation_undo[MAXPLAYERS + 1][3]; // Undo checkpoints location
float g_fCheckpointAngle[MAXPLAYERS + 1][3]; // Current checkpoints angle
float g_fCheckpointAngle_undo[MAXPLAYERS + 1][3]; // Undo checkpoints angle
float g_fLastPlayerCheckpoint[MAXPLAYERS + 1]; // Don't overwrite checkpoint if spamming !cp
bool g_bCreatedTeleport[MAXPLAYERS + 1]; // Client has created atleast one checkpoint
bool g_bPracticeMode[MAXPLAYERS + 1]; // Client is in the practice mode
/*=========================================
= Predefined arrays =
=========================================*/
char EntityList[][] = // Disable entities that often break maps
{
"logic_timer",
"team_round_timer",
"logic_relay",
};
char RadioCMDS[][] = // Disable radio commands
{
"coverme", "takepoint", "holdpos", "regroup", "followme", "takingfire", "go", "fallback", "sticktog",
"getinpos", "stormfront", "report", "roger", "enemyspot", "needbackup", "sectorclear", "inposition",
"reportingin", "getout", "negative", "enemydown", "cheer", "thanks", "nice", "compliment"
};
int RGB_COLORS[][] = // Store defined RGB colors in an array
{
RGB_GREEN, RGB_RED, RGB_DARKRED, RGB_BLUE, RGB_LIGHTBLUE, RGB_DARKBLUE, RBG_YELLOW, RGB_GREENYELLOW,
RGB_PURPLE, RGB_MAGENTA, RGB_PINK, RGB_WHITE, RGB_CYAN, RGB_SPRINGGREEN, RGB_OLIVE, RGB_ORANGE,
RGB_GREY, RGB_DARKGREY
};
char RGB_COLOR_NAMES[][] = // Store RGB color names in an array also
{
"Green", "Red", "Darkred", "Blue", "Lightblue", "Darkblue", "Yellow", "Greenyellow", "Purple",
"Magenta", "Pink", "White", "Cyan", "Springgreen", "Olive", "Orange", "Grey", "Darkgrey"
};
/*===== End of Declarations ======*/
/*================================
= Includes =
================================*/
#include "ckSurf/misc.sp"
#include "ckSurf/admin.sp"
#include "ckSurf/commands.sp"
#include "ckSurf/hooks.sp"
#include "ckSurf/buttonpress.sp"
#include "ckSurf/sql.sp"
#include "ckSurf/timer.sp"
#include "ckSurf/replay.sp"
#include "ckSurf/surfzones.sp"
/*==============================
= Events =
==============================*/
public void OnLibraryAdded(const char[] name)
{
Handle tmp = FindPluginByFile("mapchooser_extended.smx");
if ((StrEqual("mapchooser", name)) || (tmp != null && GetPluginStatus(tmp) == Plugin_Running))
g_bMapChooser = true;
if (tmp != null)
CloseHandle(tmp);
//botmimic 2
if (StrEqual(name, "dhooks") && g_hTeleport == null)
{
// Optionally setup a hook on CBaseEntity::Teleport to keep track of sudden place changes
Handle hGameData = LoadGameConfigFile("sdktools.games");
if (hGameData == null)
return;
int iOffset = GameConfGetOffset(hGameData, "Teleport");
CloseHandle(hGameData);
if (iOffset == -1)
return;
g_hTeleport = DHookCreate(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity, DHooks_OnTeleport);
if (g_hTeleport == null)
return;
DHookAddParam(g_hTeleport, HookParamType_VectorPtr);
DHookAddParam(g_hTeleport, HookParamType_ObjectPtr);
DHookAddParam(g_hTeleport, HookParamType_VectorPtr);
if (GetEngineVersion() == Engine_CSGO)
DHookAddParam(g_hTeleport, HookParamType_Bool);
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
OnClientPutInServer(i);
}
}
}
public void OnPluginEnd()
{
//remove clan tags
for (int x = 1; x <= MaxClients; x++)
{
if (IsValidClient(x))
{
SetEntPropEnt(x, Prop_Send, "m_bSpotted", 1);
SetEntProp(x, Prop_Send, "m_iHideHUD", 0);
SetEntProp(x, Prop_Send, "m_iAccount", 1);
CS_SetClientClanTag(x, "");
OnClientDisconnect(x);
}
}
//set server convars back to default
ServerCommand("sm_cvar sv_enablebunnyhopping 0;sv_friction 5.2;sv_accelerate 5.5;sv_airaccelerate 10;sv_maxvelocity 2000;sv_staminajumpcost .08;sv_staminalandcost .050");
ServerCommand("mp_respawn_on_death_ct 0;mp_respawn_on_death_t 0;mp_respawnwavetime_ct 10.0;mp_respawnwavetime_t 10.0;bot_zombie 0;mp_ignore_round_win_conditions 0");
ServerCommand("sv_infinite_ammo 0;mp_endmatch_votenextmap 1;mp_do_warmup_period 1;mp_warmuptime 60;mp_match_can_clinch 1;mp_match_end_changelevel 0");
ServerCommand("mp_match_restart_delay 15;mp_endmatch_votenextleveltime 20;mp_endmatch_votenextmap 1;mp_halftime 0;mp_do_warmup_period 1;mp_maxrounds 0;bot_quota 0");
ServerCommand("mp_startmoney 800; mp_playercashawards 1; mp_teamcashawards 1");
}
public void OnLibraryRemoved(const char[] name)
{
if (StrEqual(name, "adminmenu"))
g_hAdminMenu = null;
if (StrEqual(name, "dhooks"))
g_hTeleport = null;
}
public void OnMapStart()
{
// Get mapname
GetCurrentMap(g_szMapName, 128);
decl String:mapName[64];
GetCurrentMap(mapName, sizeof(mapName));
if(!((StrContains(mapName, "bhop_", false) != -1)))
{
SetFailState("Bu plugin sadece bhop maplarinda calismaktadir..");
}
// Load spawns
if (!g_bRenaming && !g_bInTransactionChain)
checkSpawnPoints();
// Workshop fix
char mapPieces[6][128];
int lastPiece = ExplodeString(g_szMapName, "/", mapPieces, sizeof(mapPieces), sizeof(mapPieces[]));
Format(g_szMapName, sizeof(g_szMapName), "%s", mapPieces[lastPiece - 1]);
/** Start Loading Server Settings:
* 1. Load zones (db_selectMapZones)
* 2. Get map record time (db_GetMapRecord_Pro)
* 3. Get the amount of players that have finished the map (db_viewMapProRankCount)
* 4. Get the fastest bonus times (db_viewFastestBonus)
* 5. Get the total amount of players that have finsihed the bonus (db_viewBonusTotalCount)
* 6. Get map tier (db_selectMapTier)
* 7. Get record checkpoints (db_viewRecordCheckpointInMap)
* 8. Calculate average run time (db_CalcAvgRunTime)
* 9. Calculate averate bonus time (db_CalcAvgRunTimeBonus)
* 10. Calculate player count (db_CalculatePlayerCount)
* 11. Calculate player count with points (db_CalculatePlayersCountGreater0)
* 12. Get spawn locations (db_selectSpawnLocations)
* 13. Clear latest records (db_ClearLatestRecords)
* 14. Get dynamic timelimit (db_GetDynamicTimelimit)
* -> loadAllClientSettings
*/
if (!g_bRenaming && !g_bInTransactionChain && IsServerProcessing())
db_selectMapZones();
//get map tag
ExplodeString(g_szMapName, "_", g_szMapPrefix, 2, 32);
//sv_pure 1 could lead to problems with the ckSurf models
ServerCommand("sv_pure 0");
//reload language files
LoadTranslations("ckSurf.phrases");
// load configs
loadHiddenChatCommands();
loadCustomTitles();
CheatFlag("bot_zombie", false, true);
for (int i = 0; i < MAXZONEGROUPS; i++)
{
g_bTierFound[i] = false;
g_fBonusFastest[i] = 9999999.0;
g_bCheckpointRecordFound[i] = false;
}
//precache
InitPrecache();
SetCashState();
//timers
CreateTimer(0.1, CKTimer1, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
CreateTimer(1.0, CKTimer2, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
CreateTimer(60.0, AttackTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
CreateTimer(600.0, PlayerRanksTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
g_hZoneTimer = CreateTimer(GetConVarFloat(g_hChecker), BeamBoxAll, _, TIMER_REPEAT);
//AutoBhop?
if (GetConVarBool(g_hAutoBhopConVar))
g_bAutoBhop = true;
else
g_bAutoBhop = false;
//main.cfg & replays
CreateTimer(1.0, DelayedStuff, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
if (g_bLateLoaded)
OnAutoConfigsBuffered();
g_Advert = 0;
CreateTimer(180.0, AdvertTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
int iEnt;
for (int i = 0; i < sizeof(EntityList); i++)
{
while ((iEnt = FindEntityByClassname(iEnt, EntityList[i])) != -1)
{
AcceptEntityInput(iEnt, "Disable");
AcceptEntityInput(iEnt, "Kill");
}
}
// PushFix by Mev, George, & Blacky
// https://forums.alliedmods.net/showthread.php?t=267131
iEnt = -1;
while ((iEnt = FindEntityByClassname(iEnt, "trigger_push")) != -1)
{
SDKHook(iEnt, SDKHook_Touch, OnTouchPushTrigger);
}
//OnConfigsExecuted();
// Set default values
g_insertingInformation = false;
g_fMapStartTime = GetGameTime();
g_bRoundEnd = false;
for (int i = 0; i < MAXPLAYERS+1; i++)
g_szUsedVoteExtend[i][0] = '\0';
g_VoteExtends = 0;
ServerCommand("sm plugins unload sm_parachute");
}
public void OnMapEnd()
{
g_bServerDataLoaded = false;
for (int i = 0; i < MAXZONEGROUPS; i++)
Format(g_sTierString[i], 512, "");
g_RecordBot = -1;
g_BonusBot = -1;
db_Cleanup();
if (g_hSkillGroups != null)
CloseHandle(g_hSkillGroups);
g_hSkillGroups = null;
if (g_hBotTrail[0] != null)
CloseHandle(g_hBotTrail[0]);
g_hBotTrail[0] = null;
if (g_hBotTrail[1] != null)
CloseHandle(g_hBotTrail[1]);
g_hBotTrail[1] = null;
Format(g_szMapName, sizeof(g_szMapName), "");
}
public void OnConfigsExecuted()
{
if (!GetConVarBool(g_hMultiServerMapcycle))
readMapycycle();
else
readMultiServerMapcycle();
// Count the amount of bonuses and then set skillgroups
if (!g_bRenaming && !g_bInTransactionChain)
db_selectBonusCount();
ServerCommand("sv_pure 0");
if (GetConVarBool(g_hAllowRoundEndCvar))
ServerCommand("mp_ignore_round_win_conditions 0");
else
ServerCommand("mp_ignore_round_win_conditions 1;mp_maxrounds 1");
if (GetConVarBool(g_hAutoRespawn))
ServerCommand("mp_respawn_on_death_ct 1;mp_respawn_on_death_t 1;mp_respawnwavetime_ct 3.0;mp_respawnwavetime_t 3.0");
else
ServerCommand("mp_respawn_on_death_ct 0;mp_respawn_on_death_t 0");
ServerCommand("sv_infinite_ammo 2;mp_endmatch_votenextmap 0;mp_do_warmup_period 0;mp_warmuptime 0;mp_match_can_clinch 0;mp_match_end_changelevel 1;mp_match_restart_delay 10;mp_endmatch_votenextleveltime 10;mp_endmatch_votenextmap 0;mp_halftime 0; bot_zombie 1;mp_do_warmup_period 0;mp_maxrounds 1");
}
public void OnAutoConfigsBuffered()
{
//just to be sure that it's not empty
char szMap[128];
char szPrefix[2][32];
GetCurrentMap(szMap, 128);
char mapPieces[6][128];