-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
galileo_reloaded.sma
4682 lines (3920 loc) · 159 KB
/
galileo_reloaded.sma
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
/*********************** Licensing *******************************************************
*
* Copyright 2008-2010 @ Brad Jones
* Copyright 2015-2016 @ Addons zz
*
* Plugin Theard: https://forums.alliedmods.net/showthread.php?t=273019
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 3 of the License, or ( at
* your option ) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*****************************************************************************************
*/
#define PLUGIN_VERSION "1.0-3"
#include <amxmodx>
#include <amxmisc>
/** This is to view internal program data while execution. See the function 'debugMesssageLogger(...)'
* at the end of this file, for more information. Default value: 0 - which is disabled.
*/
#define IS_DEBUG_ENABLED 1
#if IS_DEBUG_ENABLED > 0
#define DEBUG_LOGGER(%1) debugMesssageLogger( %1 )
/**
* Test unit variables related to debug level 1, displays basic debug messages.
*/
new g_debug_level
new g_max_delay_result
new g_totalSuccessfulTests
new g_totalFailureTests
new Array: g_tests_idsAndNames
new Array: g_tests_delayed_ids
new Array: g_tests_failure_ids
new bool:g_is_test_changed_cvars
new Float:test_extendmap_max
new Float:test_mp_timelimit
#else
#define DEBUG_LOGGER(%1) //
#endif
/**
* Contains all unit tests to execute.
*/
#define ALL_TESTS_TO_EXECUTE \
{ \
test_register_test(); \
test_gal_in_empty_cycle1(); \
test_gal_in_empty_cycle2(); \
test_gal_in_empty_cycle3(); \
test_gal_in_empty_cycle4(); \
test_is_map_extension_allowed1(); \
}
#define LONG_STRING 256
#define COLOR_MESSAGE 192
#define SHORT_STRING 64
#define TASKID_REMINDER 52691153
#define TASKID_VOTE_MANAGEEND 52691152
#define TASKID_SHOW_LAST_ROUND_HUD 52691052
#define TASKID_EMPTYSERVER 98176977
#define TASKID_START_VOTING_BY_ROUNDS 52691160
#define TASKID_UNLOCK_VOTING 52691163
#define TASKID_VOTE_COUNTDOWNPENDINGVOTE 52691164
#define TASKID_VOTE_HANDLEDISPLAY 52691264
#define TASKID_VOTE_DISPLAY 52691165
#define TASKID_VOTE_EXPIRE 52691166
#define TASKID_DBG_FAKEVOTES 52691167
#define TASKID_VOTE_STARTDIRECTOR 52691168
#define TASKID_MAP_CHANGE 52691169
#define RTV_CMD_STANDARD 1
#define RTV_CMD_SHORTHAND 2
#define RTV_CMD_DYNAMIC 4
#define SOUND_GETREADYTOCHOOSE 1
#define SOUND_COUNTDOWN 2
#define SOUND_TIMETOCHOOSE 4
#define SOUND_RUNOFFREQUIRED 8
#define MAPFILETYPE_SINGLE 1
#define MAPFILETYPE_GROUPS 2
#define SHOWSTATUS_VOTE 1
#define SHOWSTATUS_END 2
#define SHOWSTATUSTYPE_COUNT 1
#define SHOWSTATUSTYPE_PERCENTAGE 2
#define ANNOUNCECHOICE_PLAYERS 1
#define ANNOUNCECHOICE_ADMINS 2
#define MAX_NOMINATION_CNT 5
#define MAX_PREFIX_CNT 32
#define MAX_RECENT_MAP_CNT 16
#define MAX_PLAYER_CNT 33
#define MAX_STANDARD_MAP_CNT 25
#define MAX_MAPNAME_LEN 31
#define MAX_MAPS_IN_VOTE 8
#define MAX_NOM_MATCH_CNT 1000
#define VOTE_IN_PROGRESS 1
#define VOTE_FORCED 2
#define VOTE_IS_RUNOFF 4
#define VOTE_IS_OVER 8
#define VOTE_IS_EARLY 16
#define VOTE_HAS_EXPIRED 32
#define SRV_START_CURRENTMAP 1
#define SRV_START_NEXTMAP 2
#define SRV_START_MAPVOTE 3
#define SRV_START_RANDOMMAP 4
#define LISTMAPS_USERID 0
#define LISTMAPS_LAST 1
#define START_VOTEMAP_MIN_TIME 151
#define START_VOTEMAP_MAX_TIME 129
/**
* The rounds number before the mp_maxrounds/mp_winlimit to be reached to start the map voting.
*/
#define VOTE_START_ROUNDS 4
/**
* Start a map voting delayed after the mp_maxrounds or mp_winlimit minimum to be reached.
*/
#define VOTE_START_ROUNDS_DELAY \
{ \
g_is_maxrounds_vote_map = true; \
set_task( get_pcvar_num( g_freezetime_pointer ) + 10.0, \
"start_voting_by_rounds", TASKID_START_VOTING_BY_ROUNDS ); \
}
/**
* Determines if it is a end of map vote due time limit or max rounds expiration.
*/
#define IS_FINAL_VOTE \
( get_cvar_float( "mp_timelimit" ) < START_VOTEMAP_MIN_TIME ) \
|| ( g_is_maxrounds_vote_map )
/**
* Convert colored strings codes '!g for green', '!y for yellow', '!t for team'.
*/
#define INSERT_COLOR_TAGS(%1) \
{ \
replace_all( %1, charsmax( %1 ), "!g", "^4" ); \
replace_all( %1, charsmax( %1 ), "!t", "^3" ); \
replace_all( %1, charsmax( %1 ), "!n", "^1" ); \
replace_all( %1, charsmax( %1 ), "!y", "^1" ); \
}
#define REMOVE_COLOR_TAGS(%1) \
{ \
replace_all( %1, charsmax( %1 ), "^1", "" ); \
replace_all( %1, charsmax( %1 ), "^2", "" ); \
replace_all( %1, charsmax( %1 ), "^3", "" ); \
replace_all( %1, charsmax( %1 ), "^4", "" ); \
}
#define PRINT_COLORED_MESSAGE(%1,%2) \
{ \
message_begin( MSG_ONE_UNRELIABLE, g_user_msgid, _, %1 ); \
write_byte( %1 ); \
write_string( %2 ); \
message_end(); \
}
/**
* Call the internal function to perform its task and stop the current test execution to avoid
* double failure at the test control system.
*/
#define SET_TEST_FAILURE(%1) \
{ \
( set_test_failure_internal( %1 ) ); \
return; \
}
/**
* Lock the voting to fight concurrency problem between mp_maxrounds, mp_winlimit and mp_timelimit.
*/
new g_is_voting_locked
/**
* Variables related to debug level 32: displays messages related to the rounds end map voting
*/
new g_originalMaxRounds
new g_originalWinLimit
new Float:g_originalTimelimit
new g_freezetime_pointer
new g_winlimit_pointer;
new g_maxrounds_pointer;
new g_total_rounds_played;
new g_total_terrorists_wins;
new g_total_CT_wins;
new g_is_maxrounds_extend
new g_is_maxrounds_vote_map
new g_isTimeToChangeLevel
new g_is_last_round
new g_isTimeToRestart
new g_isTimeLimitChanged
new g_is_map_extension_allowed
/**
* Server cvars
*/
new cvar_emptyCycle;
new cvar_unnominateDisconnected;
new cvar_endOnRound
new cvar_endOnRound_msg
new cvar_endOnRound_players
new cvar_voteWeight
new cvar_voteWeightFlags
new cvar_extendmapMax;
new cvar_extendmapStep;
new cvar_extendmapStepRounds;
new cvar_endOfMapVote;
new cvar_emptyWait
new cvar_emptyMapFile
new cvar_rtvWait
new cvar_rtvRatio
new cvar_rtvCommands;
new cvar_cmdVotemap
new cvar_cmdListmaps
new cvar_listmapsPaginate;
new cvar_banRecent
new cvar_banRecentStyle
new cvar_voteDuration;
new cvar_nomMapFile
new cvar_nomPrefixes;
new cvar_nomQtyUsed
new cvar_nomPlayerAllowance;
new cvar_voteExpCountdown
new cvar_voteMapChoiceCnt
new cvar_voteAnnounceChoice
new cvar_voteUniquePrefixes;
new cvar_rtvReminder;
new cvar_srvStart;
new cvar_runoffEnabled
new cvar_runoffDuration;
new cvar_voteStatus
new cvar_voteStatusType;
new cvar_soundsMute;
/**
* Various Artists
*/
new bool:g_is_supported_color_chat
new bool:g_is_to_cancel_end_vote
new bool:g_isUsingEmptyCycle
new Array: g_emptyCycleMap
new g_emptyMapCnt
new g_cntRecentMap;
new Array:g_nominationMap
new g_nominationMapCnt;
new Array:g_fillerMap;
new Float:g_rtvWait;
new g_rockedVoteCnt;
#if AMXX_VERSION_NUM < 183
new g_user_msgid
new g_colored_player_id
new g_colored_players_number
new g_colored_current_index
new print_colored_players_ids[ 32 ]
#endif
new MENU_CHOOSEMAP[] = "gal_menuChooseMap";
new DIR_CONFIGS[ 128 ];
new DIR_DATA[ 128 ];
new g_totalVoteOptions
new g_totalVoteOptions_temp
new g_choiceMax;
new g_voteStatus
new g_voteDuration
new g_totalVotesCounted;
new CLR_RED[ 3 ]; // \r
new CLR_WHITE[ 3 ]; // \w
new CLR_YELLOW[ 3 ]; // \y
new CLR_GREY[ 3 ]; // \d
new g_refreshVoteStatus = true
new g_voteWeightFlags[ 32 ];
new g_nextmap[ MAX_MAPNAME_LEN + 1 ];
new g_totalVoteAtMapType[ 3 ]
new g_snuffDisplay[ MAX_PLAYER_CNT + 1 ];
new g_mapPrefix[ MAX_PREFIX_CNT ][ 16 ]
new g_mapPrefixCnt = 1;
new g_currentMap[ MAX_MAPNAME_LEN + 1 ]
new g_nomination[ MAX_PLAYER_CNT + 1 ][ MAX_NOMINATION_CNT + 1 ]
new g_nominationCnt
new g_nominationMatchesMenu[ MAX_PLAYER_CNT ];
new g_vote[ 512 ];
new g_arrayOfRunOffChoices[ 2 ];
new bool:g_voted[ MAX_PLAYER_CNT + 1 ] = { true, ... }
new g_arrayOfMapsWithVotesNumber[ MAX_MAPS_IN_VOTE + 1 ];
new bool:g_rockedVote[ MAX_PLAYER_CNT + 1 ]
new g_recentMap[ MAX_RECENT_MAP_CNT ][ MAX_MAPNAME_LEN + 1 ]
new g_mapsVoteMenuNames[ MAX_MAPS_IN_VOTE + 1 ][ MAX_MAPNAME_LEN + 1 ]
new g_menuChooseMap;
new g_isRunOffNeedingKeepCurrentMap = false;
public plugin_init()
{
register_plugin( "Galileo", PLUGIN_VERSION, "Addons zz/Brad Jones" );
register_dictionary( "common.txt" );
register_dictionary_colored( "galileo_reloaded.txt" );
register_cvar( "GalileoReloaded", PLUGIN_VERSION, FCVAR_SERVER | FCVAR_SPONLY );
register_cvar( "gal_server_starting", "1", FCVAR_SPONLY );
register_cvar( "gal_debug", "0" );
cvar_extendmapMax = register_cvar( "amx_extendmap_max", "90" );
cvar_extendmapStep = register_cvar( "amx_extendmap_step", "15" );
cvar_extendmapStepRounds = register_cvar( "amx_extendmap_step_rounds", "30" );
cvar_emptyCycle = register_cvar( "gal_in_empty_cycle", "0", FCVAR_SPONLY );
cvar_unnominateDisconnected = register_cvar( "gal_unnominate_disconnected", "0" );
cvar_endOnRound = register_cvar( "gal_endonround", "2" );
cvar_endOnRound_msg = register_cvar( "gal_endonround_msg", "1" );
cvar_endOnRound_players = register_cvar( "gal_endonround_players", "1" );
cvar_voteWeight = register_cvar( "gal_vote_weight", "1" );
cvar_voteWeightFlags = register_cvar( "gal_vote_weightflags", "y" );
cvar_cmdVotemap = register_cvar( "gal_cmd_votemap", "0" );
cvar_cmdListmaps = register_cvar( "gal_cmd_listmaps", "2" );
cvar_listmapsPaginate = register_cvar( "gal_listmaps_paginate", "10" );
cvar_banRecent = register_cvar( "gal_banrecent", "3" );
cvar_banRecentStyle = register_cvar( "gal_banrecentstyle", "1" );
cvar_endOfMapVote = register_cvar( "gal_endofmapvote", "1" );
cvar_emptyWait = register_cvar( "gal_emptyserver_wait", "0" );
cvar_emptyMapFile = register_cvar( "gal_emptyserver_mapfile", "" );
cvar_srvStart = register_cvar( "gal_srv_start", "0" );
cvar_rtvCommands = register_cvar( "gal_rtv_commands", "3" );
cvar_rtvWait = register_cvar( "gal_rtv_wait", "10" );
cvar_rtvRatio = register_cvar( "gal_rtv_ratio", "0.60" );
cvar_rtvReminder = register_cvar( "gal_rtv_reminder", "2" );
cvar_nomPlayerAllowance = register_cvar( "gal_nom_playerallowance", "2" );
cvar_nomMapFile = register_cvar( "gal_nom_mapfile", "mapcycle" );
cvar_nomPrefixes = register_cvar( "gal_nom_prefixes", "1" );
cvar_nomQtyUsed = register_cvar( "gal_nom_qtyused", "0" );
cvar_voteDuration = register_cvar( "gal_vote_duration", "15" );
cvar_voteExpCountdown = register_cvar( "gal_vote_expirationcountdown", "1" );
cvar_voteMapChoiceCnt = register_cvar( "gal_vote_mapchoices", "5" );
cvar_voteAnnounceChoice = register_cvar( "gal_vote_announcechoice", "1" );
cvar_voteStatus = register_cvar( "gal_vote_showstatus", "1" );
cvar_voteStatusType = register_cvar( "gal_vote_showstatustype", "2" );
cvar_voteUniquePrefixes = register_cvar( "gal_vote_uniqueprefixes", "0" );
cvar_runoffEnabled = register_cvar( "gal_runoff_enabled", "0" );
cvar_runoffDuration = register_cvar( "gal_runoff_duration", "10" );
cvar_soundsMute = register_cvar( "gal_sounds_mute", "0" );
register_logevent( "event_game_commencing", 2, "0=World triggered",
"1=Game_Commencing", "1&Restart_Round_" )
register_logevent( "team_win", 6, "0=Team" )
register_logevent( "round_end", 2, "1=Round_End" )
register_clcmd( "say", "cmd_say", -1 );
register_clcmd( "votemap", "cmd_HL1_votemap" );
register_clcmd( "listmaps", "cmd_HL1_listmaps" );
register_concmd( "gal_startvote", "cmd_startVote", ADMIN_MAP );
register_concmd( "gal_createmapfile", "cmd_createMapFile", ADMIN_RCON );
g_menuChooseMap = register_menuid( MENU_CHOOSEMAP );
g_maxrounds_pointer = get_cvar_pointer( "mp_maxrounds" )
g_winlimit_pointer = get_cvar_pointer( "mp_winlimit" )
g_freezetime_pointer = get_cvar_pointer( "mp_freezetime" )
#if AMXX_VERSION_NUM < 183
g_user_msgid = get_user_msgid( "SayText" )
#endif
register_menucmd( g_menuChooseMap, MENU_KEY_1 | MENU_KEY_2 |
MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 |
MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9 | MENU_KEY_0,
"vote_handleChoice" );
}
/**
* Called when all plugins went through plugin_init( ).
* When this forward is called, most plugins should have registered their
* cvars and commands already.
*/
public plugin_cfg()
{
#if IS_DEBUG_ENABLED > 0
g_debug_level = get_cvar_num( "gal_debug" );
g_tests_idsAndNames = ArrayCreate( SHORT_STRING )
g_tests_delayed_ids = ArrayCreate( 1 )
g_tests_failure_ids = ArrayCreate( 1 )
#endif
reset_rounds_scores()
formatex( DIR_CONFIGS[ get_configsdir( DIR_CONFIGS, sizeof( DIR_CONFIGS ) - 1 ) ],
sizeof( DIR_CONFIGS ) - 1, "/galileo_reloaded" );
formatex( DIR_DATA[ get_datadir( DIR_DATA, sizeof( DIR_DATA ) - 1 ) ],
sizeof( DIR_DATA ) - 1, "/galileo_reloaded" );
server_cmd( "exec %s/galileo_reloaded.cfg", DIR_CONFIGS );
server_exec();
g_is_supported_color_chat = ( is_running( "czero" )
|| is_running( "cstrike" ) )
if( colored_menus() )
{
copy( CLR_RED, 2, "\r" );
copy( CLR_WHITE, 2, "\w" );
copy( CLR_YELLOW, 2, "\y" );
}
g_rtvWait = get_pcvar_float( cvar_rtvWait );
g_choiceMax = max( min( MAX_MAPS_IN_VOTE, get_pcvar_num( cvar_voteMapChoiceCnt ) ), 2 )
get_pcvar_string( cvar_voteWeightFlags, g_voteWeightFlags, sizeof( g_voteWeightFlags ) - 1 );
get_mapname( g_currentMap, sizeof( g_currentMap ) - 1 );
DEBUG_LOGGER( 4, "Current MAP [%s]", g_currentMap )
DEBUG_LOGGER( 4, "" )
g_fillerMap = ArrayCreate( 32 );
g_nominationMap = ArrayCreate( 32 );
// initialize nominations table
nomination_clearAll();
if( get_pcvar_num( cvar_banRecent ) )
{
register_clcmd( "say recentmaps", "cmd_listrecent", 0 );
map_loadRecentList();
if( !( get_cvar_num( "gal_server_starting" )
&& get_pcvar_num( cvar_srvStart ) ) )
{
map_writeRecentList();
}
}
if( get_pcvar_num( cvar_rtvCommands ) & RTV_CMD_STANDARD )
{
register_clcmd( "say rockthevote", "cmd_rockthevote", 0 );
}
if( get_pcvar_num( cvar_nomPlayerAllowance ) )
{
register_concmd( "gal_listmaps", "map_listAll" );
register_clcmd( "say nominations", "cmd_nominations", 0, "- displays current nominations for next map" );
if( get_pcvar_num( cvar_nomPrefixes ) )
{
map_loadPrefixList();
}
map_loadNominationList();
}
if( get_cvar_num( "gal_server_starting" ) )
{
srv_handleStart();
}
if( get_pcvar_num( cvar_emptyWait ) )
{
g_emptyCycleMap = ArrayCreate( 32 );
map_loadEmptyCycleList();
set_task( 60.0, "srv_initEmptyCheck" );
}
// setup the main task that schedules the end map voting and allow round finish feature.
set_task( 15.0, "vote_manageEnd", TASKID_VOTE_MANAGEEND, _, _, "b" );
#if IS_DEBUG_ENABLED > 0
// delayed because it need to wait the 'server.cfg' run to save its cvars
set_task( 10.0, "runTests" )
#endif
}
public team_win()
{
new winlimit_integer
new wins_Terrorist_trigger
new wins_CT_trigger
new string_team_winner[ 16 ]
read_logargv( 1, string_team_winner, charsmax( string_team_winner ) )
if( string_team_winner[ 0 ] == 'T' )
{
g_total_terrorists_wins++
}
else if( string_team_winner[ 0 ] == 'C' )
{
g_total_CT_wins++
}
winlimit_integer = get_pcvar_num( g_winlimit_pointer )
if( winlimit_integer )
{
wins_CT_trigger = g_total_CT_wins + VOTE_START_ROUNDS
wins_Terrorist_trigger = g_total_terrorists_wins + VOTE_START_ROUNDS
if( ( ( wins_CT_trigger > winlimit_integer )
|| ( wins_Terrorist_trigger > winlimit_integer ) )
&& !g_is_maxrounds_vote_map )
{
g_is_maxrounds_extend = false;
VOTE_START_ROUNDS_DELAY
}
}
DEBUG_LOGGER( 32, "Team_Win: string_team_winner = %s, winlimit_integer = %d, \
wins_CT_trigger = %d, wins_Terrorist_trigger = %d", \
string_team_winner, winlimit_integer, wins_CT_trigger, wins_Terrorist_trigger )
}
public round_end()
{
new maxrounds_number;
new current_rounds_trigger
g_total_rounds_played++
maxrounds_number = get_pcvar_num( g_maxrounds_pointer )
if( maxrounds_number )
{
current_rounds_trigger = g_total_rounds_played + VOTE_START_ROUNDS
if( ( current_rounds_trigger > maxrounds_number )
&& !g_is_maxrounds_vote_map )
{
g_is_maxrounds_extend = true;
VOTE_START_ROUNDS_DELAY
}
}
DEBUG_LOGGER( 32, "Round_End: maxrounds_number = %d, \
g_total_rounds_played = %d, current_rounds_trigger = %d", \
maxrounds_number, g_total_rounds_played, current_rounds_trigger )
if( g_is_last_round )
{
if( g_isTimeToChangeLevel ) // when time runs out, end at the current round end
{
intermission_display()
}
else // when time runs out, end at the next round end
{
g_isTimeToChangeLevel = true
remove_task( TASKID_SHOW_LAST_ROUND_HUD )
set_task( 5.0, "configure_last_round_HUD", 1 )
}
}
}
stock intermission_display( is_map_change_stays = false )
{
if( g_isTimeToChangeLevel )
{
g_isTimeToChangeLevel = false;
if( is_map_change_stays )
{
set_task( 5.0, "map_change_stays", TASKID_MAP_CHANGE );
}
else
{
set_task( 5.0, "map_change", TASKID_MAP_CHANGE );
}
// freeze the game and show the scoreboard
message_begin( MSG_ALL, SVC_INTERMISSION );
message_end();
}
}
public start_voting_by_rounds()
{
vote_startDirector( false )
}
stock reset_rounds_scores()
{
g_is_maxrounds_vote_map = false;
g_is_maxrounds_extend = false;
g_total_rounds_played = -1
g_total_terrorists_wins = 0
g_total_CT_wins = 0
}
public plugin_end()
{
map_restoreOriginalTimeLimit()
#if IS_DEBUG_ENABLED > 0
restore_server_cvars_for_test()
ArrayDestroy( g_tests_idsAndNames )
ArrayDestroy( g_tests_delayed_ids )
ArrayDestroy( g_tests_failure_ids )
#endif
}
/**
* Indicates which action to take when it is detected that the server has been restarted.
* 0 - stay on the map the server started with
* 1 - change to the map that was being played when the server was reset
* 2 - change to what would have been the next map had the server not
* been restarted ( if the next map isn't known, this acts like 3 )
* 3 - start an early map vote after the first two minutes
* 4 - change to a randomly selected map from your nominatable map list
*/
public srv_handleStart()
{
// this is the key that tells us if this server has been restarted or not
set_cvar_num( "gal_server_starting", 0 );
// take the defined "server start" action
new startAction = get_pcvar_num( cvar_srvStart );
if( startAction )
{
new nextMap[ 32 ];
if( startAction == SRV_START_CURRENTMAP
|| startAction == SRV_START_NEXTMAP )
{
new filename[ 256 ];
formatex( filename, sizeof( filename ) - 1, "%s/info.dat", DIR_DATA );
new file = fopen( filename, "rt" );
if( file ) // !feof( file )
{
fgets( file, nextMap, sizeof( nextMap ) - 1 );
if( startAction == SRV_START_NEXTMAP )
{
nextMap[ 0 ] = 0;
fgets( file, nextMap, sizeof( nextMap ) - 1 );
}
}
fclose( file );
}
else if( startAction == SRV_START_RANDOMMAP )
{
// pick a random map from allowable nominations
// if noms aren't allowed, the nomination list hasn't already been loaded
if( get_pcvar_num( cvar_nomPlayerAllowance ) == 0 )
{
map_loadNominationList();
}
if( g_nominationMapCnt )
{
ArrayGetString( g_nominationMap, random_num( 0, g_nominationMapCnt - 1 ), nextMap, sizeof( nextMap ) - 1 );
}
}
trim( nextMap );
if( nextMap[ 0 ]
&& is_map_valid( nextMap ) )
{
server_cmd( "changelevel %s", nextMap );
}
else
{
vote_manageEarlyStart();
}
}
}
/**
* Action of srv_handleStart to take when it is detected that the server has been
* restarted. 3 - start an early map vote after the first two minutes.
*/
stock vote_manageEarlyStart()
{
g_voteStatus |= VOTE_IS_EARLY;
set_task( 120.0, "vote_startDirector", TASKID_VOTE_STARTDIRECTOR );
}
stock map_setNext( nextMap[] )
{
// set the queryable cvar
set_cvar_string( "amx_nextmap", nextMap );
// update our data file
new filename[ 256 ];
formatex( filename, sizeof( filename ) - 1, "%s/info.dat", DIR_DATA );
new file = fopen( filename, "wt" );
if( file )
{
fprintf( file, "%s", g_currentMap );
fprintf( file, "^n%s", nextMap );
fclose( file );
}
else
{
//error
}
}
public vote_manageEnd()
{
new secondsLeft = get_timeleft();
// are we ready to start an "end of map" vote?
if( ( secondsLeft < START_VOTEMAP_MIN_TIME )
&& ( secondsLeft > START_VOTEMAP_MAX_TIME )
&& !g_is_maxrounds_vote_map
&& get_pcvar_num( cvar_endOfMapVote ) )
{
vote_startDirector( false );
}
// are we managing the end of the map?
if( secondsLeft < 30
&& secondsLeft > 0
&& !g_is_last_round )
{
map_manageEnd();
}
}
public map_manageEnd()
{
DEBUG_LOGGER( 2, "%32s mp_timelimit: %f", "map_manageEnd(in)", get_cvar_float( "mp_timelimit" ) )
get_cvar_string( "amx_nextmap", g_nextmap, sizeof( g_nextmap ) - 1 );
if( get_pcvar_num( cvar_endOnRound ) == 1 ) // when time runs out, end at the current round end
{
g_is_last_round = true;
g_isTimeToChangeLevel = true;
#if AMXX_VERSION_NUM < 183
get_players( print_colored_players_ids, g_colored_players_number, "ch" );
for( g_colored_current_index = 0; g_colored_current_index < g_colored_players_number;
g_colored_current_index++ )
{
g_colored_player_id = print_colored_players_ids[ g_colored_current_index ]
client_print_color_internal( g_colored_player_id, "^1%L %L %L", g_colored_player_id,
"GAL_CHANGE_TIMEEXPIRED", g_colored_player_id, "GAL_CHANGE_NEXTROUND",
g_colored_player_id, "GAL_NEXTMAP", g_nextmap )
}
#else
client_print_color_internal( 0, "^1%L %L %L", LANG_PLAYER, "GAL_CHANGE_TIMEEXPIRED",
LANG_PLAYER, "GAL_CHANGE_NEXTROUND", LANG_PLAYER, "GAL_NEXTMAP", g_nextmap )
#endif
prevent_map_change()
}
else if( get_pcvar_num( cvar_endOnRound ) == 2 ) // when time runs out, end at the next round end
{
g_is_last_round = true;
// This is to avoid have a extra round at special mods where time limit is equal the
// round timer.
if( get_cvar_float( "mp_roundtime" ) > 8 )
{
g_isTimeToChangeLevel = true;
#if AMXX_VERSION_NUM < 183
get_players( print_colored_players_ids, g_colored_players_number, "ch" );
for( g_colored_current_index = 0; g_colored_current_index < g_colored_players_number;
g_colored_current_index++ )
{
g_colored_player_id = print_colored_players_ids[ g_colored_current_index ]
client_print_color_internal( g_colored_player_id, "^1%L %L %L", g_colored_player_id,
"GAL_CHANGE_TIMEEXPIRED", g_colored_player_id, "GAL_CHANGE_NEXTROUND",
g_colored_player_id, "GAL_NEXTMAP", g_nextmap )
}
#else
client_print_color_internal( 0, "^1%L %L %L", LANG_PLAYER, "GAL_CHANGE_TIMEEXPIRED",
LANG_PLAYER, "GAL_CHANGE_NEXTROUND", LANG_PLAYER, "GAL_NEXTMAP", g_nextmap )
#endif
}
else
{
#if AMXX_VERSION_NUM < 183
get_players( print_colored_players_ids, g_colored_players_number, "ch" );
for( g_colored_current_index = 0; g_colored_current_index < g_colored_players_number;
g_colored_current_index++ )
{
g_colored_player_id = print_colored_players_ids[ g_colored_current_index ]
client_print_color_internal( g_colored_player_id, "^1%L %L", g_colored_player_id,
"GAL_CHANGE_TIMEEXPIRED", g_colored_player_id, "GAL_NEXTMAP", g_nextmap );
}
#else
client_print_color_internal( 0, "^1%L %L", LANG_PLAYER, "GAL_CHANGE_TIMEEXPIRED",
LANG_PLAYER, "GAL_NEXTMAP", g_nextmap );
#endif
}
prevent_map_change()
}
configure_last_round_HUD( bool:get_pcvar_num( cvar_endOnRound_msg ) )
DEBUG_LOGGER( 2, "%32s mp_timelimit: %f", "map_manageEnd(out)", get_cvar_float( "mp_timelimit" ) )
}
public configure_last_round_HUD( bool:is_to_show )
{
if( is_to_show )
{
set_task( 1.0, "show_last_round_HUD", TASKID_SHOW_LAST_ROUND_HUD, _, _, "b" )
}
}
public show_last_round_HUD()
{
set_hudmessage( 255, 255, 255, 0.15, 0.15, 0, 0.0, 1.0, 0.1, 0.1, 1 )
if( g_isTimeToChangeLevel )
{
show_hudmessage( 0, "%L ^n%L", LANG_PLAYER, "GAL_CHANGE_NEXTROUND",
LANG_PLAYER, "GAL_NEXTMAP", g_nextmap )
}
else
{
show_hudmessage( 0, "%L ^n%L", LANG_PLAYER, "GAL_CHANGE_TIMEEXPIRED",
LANG_PLAYER, "GAL_NEXTMAP", g_nextmap )
}
}
stock prevent_map_change()
{
if( get_realplayersnum() >= get_pcvar_num( cvar_endOnRound_players ) )
{
save_time_limit()
// prevent the map from ending automatically
server_cmd( "mp_timelimit 0" );
}
}
public map_loadRecentList()
{
new filename[ 256 ];
formatex( filename, sizeof( filename ) - 1, "%s/recentmaps.dat", DIR_DATA );
new file = fopen( filename, "rt" );
if( file )
{
new buffer[ 32 ];
while( !feof( file ) )
{
fgets( file, buffer, sizeof( buffer ) - 1 );
trim( buffer );
if( buffer[ 0 ] )
{
if( g_cntRecentMap == get_pcvar_num( cvar_banRecent ) )
{
break;
}
copy( g_recentMap[ g_cntRecentMap++ ], sizeof( buffer ) - 1, buffer );
}
}
fclose( file );
}
}
public map_writeRecentList()
{
new filename[ 256 ];
formatex( filename, sizeof( filename ) - 1, "%s/recentmaps.dat", DIR_DATA );
new file = fopen( filename, "wt" );
if( file )
{
fprintf( file, "%s", g_currentMap );
for( new idxMap = 0; idxMap < get_pcvar_num( cvar_banRecent ) - 1; ++idxMap )
{
fprintf( file, "^n%s", g_recentMap[ idxMap ] );
}
fclose( file );
}
}
public map_loadFillerList( filename[] )
{
return map_populateList( g_fillerMap, filename );
}
public cmd_rockthevote( player_id )
{
client_print_color_internal( player_id, "^1%L", player_id, "GAL_CMD_RTV" );
vote_rock( player_id );
return PLUGIN_CONTINUE;
}
public cmd_nominations( player_id )
{
client_print_color_internal( player_id, "^1%L", player_id, "GAL_CMD_NOMS" );
nomination_list( player_id );
return PLUGIN_CONTINUE;
}
public cmd_listrecent( player_id )
{
switch( get_pcvar_num( cvar_banRecentStyle ) )
{
case 1:
{
new msg[ 101 ], msgIdx;
for( new idx = 0; idx < g_cntRecentMap; ++idx )
{
msgIdx += format( msg[ msgIdx ], sizeof( msg ) - 1 - msgIdx, ", %s", g_recentMap[ idx ] );
}
#if AMXX_VERSION_NUM < 183
get_players( print_colored_players_ids, g_colored_players_number, "ch" );
for( new g_colored_current_index = 0; g_colored_current_index < g_colored_players_number;
g_colored_current_index++ )
{
g_colored_player_id = print_colored_players_ids[ g_colored_current_index ]
client_print_color_internal( g_colored_player_id, "^1%L: %s", g_colored_player_id,
"GAL_MAP_RECENTMAPS", msg[ 2 ] );
}
#else
client_print_color_internal( 0, "^1%L: %s", LANG_PLAYER, "GAL_MAP_RECENTMAPS", msg[ 2 ] );
#endif
}
case 2:
{
for( new idx = 0; idx < g_cntRecentMap; ++idx )