77
88#pragma semicolon 1
99
10- # define BLOCK_MAP_COUNT 10
10+ # define get_num (%0 ) get_pcvar_num(g_pCvars[%0 ])
11+
12+ enum Cvars {
13+ BAN_LAST_MAPS
14+ };
15+
16+ new g_pCvars[Cvars];
1117
1218new const FILE_BLOCKED_MAPS[] = " blockedmaps.ini" ; // datadir
1319
@@ -17,6 +23,8 @@ new g_iMaxItems;
1723public plugin_init ()
1824{
1925 register_plugin (PLUGIN, VERSION, AUTHOR);
26+
27+ g_pCvars[BAN_LAST_MAPS] = register_cvar (" mapm_blocklist_ban_last_maps" , " 10" );
2028}
2129public plugin_natives ()
2230{
@@ -64,8 +72,10 @@ load_blocklist()
6472 new file_dir[128 ]; get_localinfo (" amxx_datadir" , file_dir, charsmax (file_dir));
6573 new file_path[128 ]; formatex (file_path, charsmax (file_path), " %s /%s " , file_dir, FILE_BLOCKED_MAPS);
6674
75+ new block_value = get_num (BAN_LAST_MAPS);
76+
6777 new cur_map[MAPNAME_LENGTH]; get_mapname (cur_map, charsmax (cur_map)); strtolower (cur_map);
68- TrieSetCell (g_tBlockedList, cur_map, BLOCK_MAP_COUNT );
78+ TrieSetCell (g_tBlockedList, cur_map, block_value );
6979
7080 new f, temp;
7181
@@ -83,7 +93,7 @@ load_blocklist()
8393
8494 if (! is_map_valid (map) || TrieKeyExists (g_tBlockedList, map)) continue ;
8595
86- count = min (str_to_num (str_count) - 1 , BLOCK_MAP_COUNT );
96+ count = min (str_to_num (str_count) - 1 , block_value );
8797
8898 if (count <= 0 ) continue ;
8999
@@ -92,7 +102,7 @@ load_blocklist()
92102 // server_print("%s", map);
93103 }
94104
95- fprintf (temp, " ^" % s^ " ^" % d^ " ^n" , cur_map, BLOCK_MAP_COUNT );
105+ fprintf (temp, " ^" % s^ " ^" % d^ " ^n" , cur_map, block_value );
96106
97107 fclose (f);
98108 fclose (temp);
@@ -103,7 +113,7 @@ load_blocklist()
103113 else {
104114 f = fopen (file_path, " wt" );
105115 if (f) {
106- fprintf (f, " ^" % s^ " ^" % d^ " ^n" , cur_map, BLOCK_MAP_COUNT );
116+ fprintf (f, " ^" % s^ " ^" % d^ " ^n" , cur_map, block_value );
107117 }
108118 fclose (f);
109119 }
0 commit comments