/[svn]/hlds/cstrike/addons/amxmodx/scripting/deagsmapmanager.sma
ViewVC logotype

Contents of /hlds/cstrike/addons/amxmodx/scripting/deagsmapmanager.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 29 - (hide annotations) (download)
Thu Dec 11 21:59:28 2008 UTC (15 years, 4 months ago) by cstrike
File size: 102178 byte(s)
Fixed localization issues, array dimensions, a minor typo; code tweaks
1 cstrike 9 /********************************************************************************
2     * AMX Mod X script.
3     *
4     * Deagles Map Manager (deagsmapmanager.sma)
5     * Copyright (C) 2006-2007 Deages/AMXX Community
6     * (c) Copyright for original Mapchooser by OLO
7     *
8     * This program is free software; you can redistribute it and/or
9     * modify it under the terms of the GNU General Public License
10     * as published by the Free Software Foundation; either version 2
11     * of the License, or (at your option) any later version.
12     *
13     * This program is distributed in the hope that it will be useful,
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     * GNU General Public License for more details.
17     *
18     * You should have received a copy of the GNU General Public License
19     * along with this program; if not, write to the Free Software
20     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21     *
22     * In addition, as a special exception, the author gives permission to
23     * link the code of this program with the Half-Life Game Engine ("HL
24     * Engine") and Modified Game Libraries ("MODs") developed by Valve,
25     * L.L.C ("Valve"). You must obey the GNU General Public License in all
26     * respects for all of the code used other than the HL Engine and MODs
27     * from Valve. If you modify this file, you may extend this exception
28     * to your version of the file, but you are not obligated to do so. If
29     * you do not wish to do so, delete this exception statement from your
30     * version.
31     *
32     *********************************************************************************
33     *
34 cstrike 17 * Deagles Map Management v3.21
35     * Last Update: 2008-09-17
36 cstrike 9 *
37     * by Deagles/AMXX Community & Posting/Supporting by bmann_420
38     * Link: http://forums.alliedmods.net/showthread.php?t=59535
39     *
40     *
41     * Changelog is in the .txt file
42     *
43     *
44     *********************************************************************************
45     */
46    
47    
48     #pragma semicolon 1
49     #include <amxmodx>
50     #include <amxmisc>
51    
52     new const PLUGIN[] = "DeagsMapManager";
53 cstrike 27 new const VERSION[] = "3.21SVN";
54 cstrike 9 new const AUTHOR[] = "Deags/AMXX Community";
55    
56     // Comment out the following line to disable the dedicated log file
57     #define DEDICATED_LOG_ENABLED
58    
59     #define MAX_MAPS_AMOUNT 600
60     #define ADMIN_DMAP ADMIN_LEVEL_A
61     #define ADMIN_SUPER_DMAP ADMIN_LEVEL_F
62    
63 cstrike 27 #define DMAP_VOTE_TIME 20 // Total time (in seconds) from vote start to checking votes
64    
65     #define DMAP_TASKID_VTR 10000 // Vote Time Remaining
66     // non-DEFINE ids currently used:
67     // 123400, 123450, 123452, 127600(+id), 127600(+idreal),333333, 444444, 454500,
68     // 454510, 459100, 459200, 765100, 986100, 986200, 987111, 987300, 987456
69    
70 cstrike 9 new maps_to_select, isbuytime = 0, isbetween = 0;
71     new ban_last_maps = 0, quiet = 0; //quiet=0 (words and sounds) quiet=1 (words only, no sound) quiet=2 (no sound, no words)
72     new Float:rtvpercent, Float:thespeed, Float:oldtimelimit;
73     new minimum = 1, minimumwait = 10, enabled = 1, cycle = 0, dofreeze = 1, maxnom = 3, maxcustnom = 5, frequency = 3, oldwinlimit = 0, addthiswait = 0;
74     new mapsurl[64], amt_custom = 0;
75     new isend = 0, isspeedset = 0, istimeset = 0, iswinlimitset = 0, istimeset2 = 0, mapssave = 0, atstart;
76     new usestandard = 1, currentplayers = 0, activeplayers = 0, counttovote = 0, countnum = 0;
77     new inprogress = 0, rocks = 0, rocked[33], hasbeenrocked = 0, waited = 0;
78     new pathtomaps[64];
79     new custompath[50];
80     new nmaps[MAX_MAPS_AMOUNT][32];
81     new listofmaps[MAX_MAPS_AMOUNT][32];
82     new totalbanned = 0;
83     new banthesemaps[MAX_MAPS_AMOUNT][32];
84     new totalmaps = 0;
85     new lastmaps[100 + 1][32];
86     new bannedsofar = 0;
87     new standard[50][32];
88     new standardtotal = 0;
89     new nmaps_num = 0; //this is number of nominated maps
90     new nbeforefill;
91     new nmapsfill[MAX_MAPS_AMOUNT][32];
92     new num_nmapsfill; //this is number of maps in users admin.cfg file that are valid
93     new bool:is_cstrike;
94 cstrike 27 new nnextmaps[10];
95     new nvotes[12]; // Holds the number of votes for each map
96     new nmapstoch, before_num_nmapsfill = 0, bool:mselected = false;
97 cstrike 9 #if defined DEDICATED_LOG_ENABLED
98     new logfilename[256];
99     #endif
100     new teamscore[2], last_map[32];
101     new Nominated[MAX_MAPS_AMOUNT]; //?
102     new whonmaps_num[MAX_MAPS_AMOUNT];
103     new curtime = 0, staytime = 0, curplayers = 0, currounds = 0;
104     new dmap_strict, nominations_allowed, emptymap, idletime, emptymap_allowed, weapon_delay;
105 cstrike 27 new g_TotalVotes; // Running total used to calculate percentages
106     new bool:g_AlreadyVoted[33]; // Keep track of who voted in current round
107     new g_VoteTimeRemaining; // Used to set duration of display of vote menu
108 cstrike 9
109     forward public hudtext16(textblock[], colr, colg, colb, posx, posy, screen, time, id);
110     forward bool:isbanned(map[]);
111     forward bool:iscustommap(map[]);
112     forward bool:islastmaps(map[]);
113     forward bool:isnominated(map[]);
114     forward public handle_nominate(id, map[]);
115     forward available_maps();
116     forward public getready();
117     forward public timetovote();
118     forward public messagefifteen();
119     forward public messagenominated();
120     forward public messagemaps();
121     forward public stopperson();
122     forward public countdown();
123     forward public rock_it_now();
124     forward public timedisplay();
125     forward public messagethree();
126    
127     public client_connect(id) {
128     if (!is_user_bot(id)) {
129     currentplayers++;
130     }
131     return PLUGIN_CONTINUE;
132     }
133    
134     public loopmessages() {
135     if (quiet == 2) { //quiet=0 (words and sounds) quiet=1 (words only, no sound) quiet=2 (no sound, no words)
136     return PLUGIN_HANDLED;
137     }
138     new timeleft = get_timeleft();
139     new partialtime = timeleft % 370;
140     new maintime = timeleft % 600;
141     if ((maintime > 122 && maintime < 128) && timeleft > 114) {
142     set_task(1.0, "timedisplay", 454510, "", 0, "a", 5);
143     }
144     if ((partialtime > 320 && partialtime < 326) && !cycle) {
145     set_task(3.0, "messagethree", 987300); //, "", 0, "a", 4)
146     return PLUGIN_HANDLED;
147     }
148     return PLUGIN_HANDLED;
149     }
150    
151     public timedisplay() {
152     new timeleft = get_timeleft();
153     new seconds = timeleft % 60;
154     new minutes = floatround((timeleft - seconds) / 60.0);
155     if (timeleft < 1) {
156     remove_task(454510);
157     remove_task(454500);
158     remove_task(123452);
159     remove_task(123499);
160     return PLUGIN_HANDLED;
161     }
162     if (timeleft > 140) {
163     remove_task(454500);
164     }
165     if (timeleft > 30) {
166     set_hudmessage(255, 255, 220, 0.02, 0.2, 0, 1.0, 1.04, 0.0, 0.05, 3);
167     } else {
168     set_hudmessage(210, 0 ,0, 0.02, 0.15, 0, 1.0, 1.04, 0.0, 0.05, 3);
169     //Flashing red:set_hudmessage(210, 0, 0, 0.02, 0.2, 1, 1.0, 1.04, 0.0, 0.05, 3);
170     }
171     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_TIME_LEFT", minutes, seconds);
172     if (timeleft < 70 && (timeleft % 5) == 1) {
173     new smap[32];
174     get_cvar_string("amx_nextmap", smap, 31);
175     set_hudmessage(0, 132, 255, 0.02, 0.27, 0, 5.0, 5.04, 0.0, 0.5, 4);
176     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_NEXTMAP", smap);
177     }
178     return PLUGIN_HANDLED;
179    
180     }
181    
182     public messagethree() {
183     new timeleft = get_timeleft();
184     new time2 = timeleft - timeleft % 60;
185     new minutesleft = floatround(float(time2) / 60.0);
186     new mapname[32];
187     get_mapname(mapname, 31);
188     new smap[32];
189     get_cvar_string("amx_nextmap", smap, 31);
190     if (minutesleft >= 2 && !mselected) {
191     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NEXTMAP_VOTE_REMAINING",
192     (minutesleft == 3 || minutesleft == 2) ? timeleft -100 : minutesleft - 2, (minutesleft == 3 || minutesleft == 2) ? "seconds" : "minutes");
193     } else {
194     if (mselected) {
195     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NEXTMAP_VOTED", smap, timeleft);
196     } else {
197     if (minutesleft <= 2 && timeleft) {
198     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_CURRENT_MAP", mapname);
199     }
200     }
201     }
202     }
203    
204     public client_putinserver(id) {
205     if (!is_user_bot(id)) {
206     activeplayers++;
207     }
208     return PLUGIN_CONTINUE;
209     }
210    
211     public client_disconnect(id) {
212     remove_task(987600 + id);
213     remove_task(127600 + id);
214     if (is_user_bot(id)) {
215     return PLUGIN_CONTINUE;
216     }
217     currentplayers--;
218     activeplayers--;
219 cstrike 27 g_AlreadyVoted[id] = false;
220 cstrike 9 if (rocked[id]) {
221     rocked[id] = 0;
222     rocks--;
223     }
224     if (get_timeleft() > 160) {
225     if (!mselected && !hasbeenrocked && !inprogress) {
226     check_if_need();
227     }
228     }
229     new kName[32];
230     get_user_name(id, kName, 31);
231    
232     new n = 0;
233     while (Nominated[id] > 0 && n < nmaps_num) {
234     if (whonmaps_num[n] == id) {
235     if (get_timeleft() > 50 && quiet != 2) { //quiet=0 (words and sounds) quiet=1 (words only, no sound) quiet=2 (no sound, no words)
236     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_PLAYER_LEFT", kName, nmaps[n]);
237     #if defined DEDICATED_LOG_ENABLED
238     log_to_file(logfilename, "%s has left; %s is no longer nominated", kName, nmaps[n]);
239     #endif
240     }
241    
242     new j = n;
243     while (j < nmaps_num - 1) {
244     whonmaps_num[j] = whonmaps_num[j + 1];
245     nmaps[j] = nmaps[j + 1];
246     j++;
247     }
248     nmaps_num--;
249     Nominated[id] = Nominated[id] - 1;
250     } else {
251     n++;
252     }
253     }
254     return PLUGIN_CONTINUE;
255     }
256    
257     public timer(id) {
258     if (get_playersnum() == 0) {
259     curtime++;
260     if (curtime >= staytime) {
261     change_maps();
262     }
263     } else {
264     new i, noncounted, players = get_playersnum();
265     for (i = 1; i <= get_maxplayers(); i++) {
266     if ((get_user_time(i, 1) >= (get_pcvar_num(idletime) * 216000)) || is_user_bot(i) || is_user_hltv(i)) {
267     noncounted++;
268     }
269     }
270     if (players == noncounted) {
271     curtime++;
272     if (curtime >= staytime) {
273     change_maps();
274     }
275     } else {
276     curtime = 0;
277     }
278     }
279     return curtime;
280     }
281    
282     public change_maps() {
283    
284     new map[51], curmap[51];
285     get_mapname(curmap,50);
286     get_pcvar_string(emptymap, map, 31);
287    
288     if (get_pcvar_num(emptymap_allowed) == 1 && strlen(map) > 0) {
289     server_cmd("changelevel %s", map);
290     }
291     }
292    
293     public list_maps(id) {
294 cstrike 10 new m, iteration = 0;
295     client_print(id, print_chat, "%L", id, "DMAP_LISTMAPS", totalmaps);
296 cstrike 9 if (totalmaps - (50 * iteration) >= 50) {
297 cstrike 10 console_print(id, "%L", id, "DMAP_LISTMAPS_MAPS", iteration * 50 + 1, iteration * 50 + 50);
298 cstrike 9 } else {
299 cstrike 10 console_print(id, "%L", id, "DMAP_LISTMAPS_MAPS", iteration * 50 + 1, iteration * 50 + (totalmaps - iteration * 50));
300 cstrike 9 }
301    
302     for (m = 50 * iteration; (m < totalmaps && m < 50 * (iteration + 1)); m += 3)
303     if (m + 1 < totalmaps) {
304     if (m + 2 < totalmaps) {
305     console_print(id, " %s %s %s", listofmaps[m], listofmaps[m + 1], listofmaps[m + 2]);
306     } else {
307     console_print(id, " %s %s", listofmaps[m], listofmaps[m + 1]);
308     }
309     } else {
310     console_print(id, " %s", listofmaps[m]);
311     }
312     if (50 * (iteration + 1) < totalmaps) {
313     new kIdfake[32];
314     num_to_str((id + 50 * (iteration + 1)), kIdfake, 31);
315 cstrike 10 client_print(id, print_console, "%L", id, "DMAP_LISTMAPS_MORE");
316 cstrike 9 set_task(4.0, "more_list_maps", 127600 + id, kIdfake, 6);
317     }
318     return PLUGIN_CONTINUE;
319     }
320    
321     public more_list_maps(idfakestr[]) {
322 cstrike 10 new idreal = str_to_num(idfakestr);
323     new m, iteration = 0;
324 cstrike 9 while (idreal >= 50) {
325     idreal -= 50;
326     iteration++;
327     } //Now idreal is the real id of client
328    
329     if (totalmaps - (50 * iteration) >= 50) {
330 cstrike 10 console_print(idreal, "%L", idreal, "DMAP_LISTMAPS_MAPS", iteration * 50 + 1, iteration * 50 + 50);
331 cstrike 9 } else {
332 cstrike 10 console_print(idreal, "%L", idreal, "DMAP_LISTMAPS_MAPS", iteration * 50 + 1, iteration * 50 + (totalmaps - iteration * 50));
333 cstrike 9 }
334    
335     for (m = 50 * iteration; (m < totalmaps && m < 50 * (iteration + 1)); m += 3) {
336     if (m + 1 < totalmaps) {
337     if (m + 2 < totalmaps) {
338     console_print(idreal, " %s %s %s", listofmaps[m], listofmaps[m + 1], listofmaps[m + 2]);
339     } else {
340     console_print(idreal, " %s %s", listofmaps[m], listofmaps[m + 1]);
341     }
342     } else {
343     console_print(idreal, " %s", listofmaps[m]);
344     }
345     }
346    
347     if (50 * (iteration + 1) < totalmaps) {
348     new kIdfake[32];
349     num_to_str((idreal + 50 * (iteration + 1)), kIdfake, 31);
350 cstrike 10 client_print(idreal, print_console, "%L", idreal, "DMAP_LISTMAPS_MORE");
351 cstrike 9 set_task(2.0, "more_list_maps", 127600 + idreal, kIdfake, 6);
352     } else { //Base case has been reached
353 cstrike 10 client_print(idreal, print_console, "%L", idreal, "DMAP_LISTMAPS_FINISHED", totalmaps);
354 cstrike 9 }
355     }
356    
357     public say_nextmap(id) {
358     new timeleft = get_timeleft();
359     new time2 = timeleft - timeleft % 60;
360     new minutesleft = floatround(float(time2) / 60.0);
361     new mapname[32];
362     get_mapname(mapname,31);
363     new smap[32];
364     get_cvar_string("amx_nextmap", smap, 31);
365     if (minutesleft >= 2 && !mselected)
366     if (get_pcvar_num(nominations_allowed) == 1) {
367     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_SAY_NOMINATIONS",
368     (minutesleft == 3 || minutesleft == 2) ? timeleft - 100 : minutesleft - 2, (minutesleft == 3 || minutesleft == 2) ? "sec." : "min.");
369     } else {
370     if (mselected) {
371     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NEXTMAP_VOTED", smap, timeleft);
372     } else {
373     if (inprogress) {
374     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_CURRENT_MAP", mapname);
375     }
376     }
377     }
378     return PLUGIN_HANDLED;
379     }
380    
381     public check_if_need() {
382     new Float:ratio = rtvpercent;
383     new needed = floatround(float(activeplayers) * ratio + 0.49);
384     new timeleft = get_timeleft();
385     new Float:minutesleft = float(timeleft) / 60.0;
386     new Float:currentlimit = get_cvar_float("mp_timelimit");
387     new Float:minutesplayed = currentlimit - minutesleft;
388     new wait;
389     wait = minimumwait;
390     if ((minutesplayed + 0.5) >= (float(wait))) {
391     if (rocks >= needed && rocks >= minimum) {
392     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_RTV_STARTING", rocks);
393     set_hudmessage(222, 70, 0, -1.0, 0.3, 1, 10.0, 10.0, 2.0, 4.0, 4);
394     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_RTV_START", rocks);
395     hasbeenrocked = 1;
396     inprogress = 1;
397     mselected = false;
398     set_task(10.0, "rock_it_now", 765100);
399     }
400     }
401     }
402    
403     public rock_the_vote(id) {
404     new Float:ratio = rtvpercent;
405     new needed = floatround(float(activeplayers) * ratio + 0.49);
406     new kName[32];
407     get_user_name(id, kName, 31);
408     new timeleft = get_timeleft();
409     new Float:minutesleft = float(timeleft) / 60.0;
410     new Float:currentlimit = get_cvar_float("mp_timelimit");
411     new Float:minutesplayed = currentlimit - minutesleft;
412     new wait;
413     wait = minimumwait;
414     if (cycle) {
415 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_VOTING_DISABLED");
416 cstrike 9 return PLUGIN_CONTINUE;
417     }
418     if (!enabled) {
419 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_RTV_DISABLED");
420 cstrike 9 return PLUGIN_CONTINUE;
421     }
422     if (inprogress) {
423 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_VOTE_BEGINNING");
424 cstrike 9 return PLUGIN_CONTINUE;
425     }
426     if (mselected) {
427     new smap[32];
428     get_cvar_string("amx_nextmap", smap, 31);
429 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_VOTING_COMPLETED", smap, get_timeleft());
430 cstrike 9 return PLUGIN_CONTINUE;
431     }
432     if (hasbeenrocked) {
433 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_MAP_ALREADY_ROCKED", kName);
434 cstrike 9 return PLUGIN_CONTINUE;
435     }
436     if (timeleft < 120) {
437     if (timeleft > 1) {
438 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_NOT_ENOUGH_TIME");
439 cstrike 9 } else {
440 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_NO_TIMELIMIT");
441 cstrike 9 }
442     return PLUGIN_CONTINUE;
443     }
444     if ((minutesplayed + 0.5) < (float(wait))) {
445     if (float(wait) - 0.5 - minutesplayed > 0.0) {
446 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_RTV_WAIT",
447 cstrike 9 kName, (floatround(float(wait) + 0.5-minutesplayed) > 0) ? (floatround(float(wait) + 0.5 - minutesplayed)) : (1));
448     } else {
449 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_RTV_1MIN");
450 cstrike 9 }
451     if ((get_user_flags(id) & ADMIN_MAP)) {
452 cstrike 10 console_print(id, "%L", id, "DMAP_RTV_ADMIN_FORCE", kName);
453 cstrike 9 }
454     return PLUGIN_CONTINUE;
455     }
456     if (!rocked[id]) {
457     rocked[id] = 1;
458     rocks++;
459     } else {
460 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_ALREADY_ROCKED", kName);
461 cstrike 9 return PLUGIN_CONTINUE;
462     }
463     if (rocks >= needed && rocks >= minimum) {
464     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_RTV_STARTING", rocks);
465     set_hudmessage(222, 70,0, -1.0, 0.3, 1, 10.0, 10.0, 2.0, 4.0, 4);
466     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_RTV_START", rocks);
467     hasbeenrocked = 1;
468     inprogress = 1;
469     mselected = false;
470     set_task(15.0, "rock_it_now", 765100);
471     } else {
472     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_RTV_NEEDED", ((needed-rocks) > (minimum-needed)) ? (needed-rocks) : (minimum-rocks));
473     }
474     return PLUGIN_CONTINUE;
475     }
476    
477     public rock_it_now() {
478     new temprocked = hasbeenrocked;
479     hasbeenrocked = 1;
480     new timeleft = get_timeleft();
481     new Float:minutesleft=float(timeleft) / 60.0;
482     new Float:currentlimit = get_cvar_float("mp_timelimit");
483     new Float:minutesplayed = currentlimit-minutesleft;
484     new Float:timelimit;
485     counttovote = 0;
486     remove_task(459200);
487     remove_task(459100);
488     timelimit = float(floatround(minutesplayed + 1.5));
489     if (timelimit > 0.4) {
490     oldtimelimit = get_cvar_float("mp_timelimit");
491     istimeset = 1;
492     set_cvar_float("mp_timelimit", timelimit);
493     if (quiet != 2) {
494     console_print(0, "%L", LANG_PLAYER, "DMAP_TIMELIMIT_CHANGED", floatround(get_cvar_float("mp_timelimit")));
495     }
496     #if defined DEDICATED_LOG_ENABLED
497 cstrike 29 log_to_file(logfilename, "Time limit changed to %d to enable vote to occur now", floatround(get_cvar_float("mp_timelimit")));
498 cstrike 9 #endif
499     } else {
500     console_print(0, "%L", LANG_PLAYER, "DMAP_TIMELIMIT_NOTCHANGED");
501     #if defined DEDICATED_LOG_ENABLED
502     log_to_file(logfilename, "Will not set a timelimit of %d, vote is not rocked, seconds left on map:%d", floatround(timelimit), timeleft);
503     #endif
504     new inum, players[32], i;
505     get_players(players, inum, "c");
506     for (i = 0; i < inum; ++i) {
507     rocked[i] = 0;
508     }
509     rocks = 0;
510     hasbeenrocked = temprocked;
511     return PLUGIN_HANDLED;
512     }
513     timeleft = get_timeleft();
514     inprogress = 1;
515     mselected = false;
516     if (quiet != 2) {
517     set_hudmessage(0, 222,50, -1.0, 0.23, 1, 6.0, 6.0, 1.0, 1.0, 4);
518     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_START_MAPVOTE");
519     } else {
520     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_START_MAPVOTE");
521     }
522     if (quiet == 0) {
523     client_cmd(0, "spk ^"get red(e80) ninety(s45) to check(e20) use _comma(e10) bay(s18) mass(e42) cap(s50)^"");
524     }
525     set_task(3.5, "getready", 459100);
526     set_task(10.0, "startthevote");
527     remove_task(454500);
528     remove_task(123452);
529     rocks = 0;
530     new inum, players[32], i;
531     get_players(players, inum, "c");
532     for (i = 0; i < inum; ++i) {
533     rocked[i] = 0;
534     }
535     set_task(2.18, "calculate_custom");
536     return PLUGIN_HANDLED;
537     }
538    
539     public admin_rockit(id, level, cid) {
540     if (!cmd_access(id, level, cid, 1)) {
541     return PLUGIN_HANDLED;
542     }
543    
544     new arg[32];
545     read_argv(1, arg, 31);
546     new kName[32], timeleft = get_timeleft();
547     get_user_name(id, kName, 31);
548    
549     if (timeleft < 180.0) {
550 cstrike 10 console_print(id, "%L", id, "DMAP_NOT_ENOUGH_TIME");
551 cstrike 9 return PLUGIN_HANDLED;
552     }
553     if (inprogress || hasbeenrocked || isend) {
554 cstrike 10 console_print(id, "%L", id, "DMAP_ALREADY_VOTING");
555 cstrike 9 return PLUGIN_HANDLED;
556     }
557     if (cycle) {
558 cstrike 10 console_print(id, "%L", id, "DMAP_ENABLE_VOTEMODE");
559 cstrike 9 return PLUGIN_HANDLED;
560     }
561     if (!mselected) {
562     switch(get_cvar_num("amx_show_activity")) {
563     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_VOTE_ROCKED_BY_ADMIN", kName);
564     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_RTV_USED_BY_ADMIN");
565     }
566     } else {
567     switch(get_cvar_num("amx_show_activity")) {
568     case 2: client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_REVOTE_BY_ADMIN", kName);
569     case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_REVOTE");
570     }
571     }
572     remove_task(123450);
573     remove_task(123400);
574     remove_task(123452);
575     remove_task(123499);
576     counttovote = 0;
577     remove_task(459200);
578     remove_task(459100);
579     #if defined DEDICATED_LOG_ENABLED
580     log_to_file(logfilename, "Admin: <%s> calls rockthevote with %d seconds left on map", kName, timeleft);
581     #endif
582     inprogress = 1;
583     mselected = false;
584     set_task(15.0, "rock_it_now", 765100);
585     set_task(0.18, "calculate_custom");
586     return PLUGIN_HANDLED;
587     }
588    
589     public check_votes() {
590     new timeleft = get_timeleft();
591     new b = 0, a;
592     for (a = 0; a < nmapstoch; ++a) {
593     if (nvotes[b] < nvotes[a]) {
594     b = a;
595     }
596     }
597     if (nvotes[maps_to_select] > nvotes[b]) {
598     new mapname[32];
599     get_mapname(mapname, 31);
600     new Float:steptime = get_cvar_float("amx_extendmap_step");
601     set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime);
602     //oldtimelimit = get_cvar_float("mp_timelimit");
603     istimeset = 1;
604    
605     if (quiet != 2) {
606     set_hudmessage(222, 70,0, -1.0, 0.4, 0, 4.0, 10.0, 2.0, 2.0, 4);
607     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_MAP_EXTENDED", steptime);
608     if (quiet != 1) {
609     client_cmd(0, "speak ^"barney/waitin^"");
610     }
611     }
612     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_MAP_EXTENDED2", steptime);
613     #if defined DEDICATED_LOG_ENABLED
614     log_to_file(logfilename, "Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes", mapname, steptime);
615     #endif
616     inprogress = isend = 0;
617     nmaps_num = nbeforefill;
618     num_nmapsfill = before_num_nmapsfill;
619     return PLUGIN_HANDLED;
620     }
621     if (nvotes[b] && nvotes[maps_to_select+1] <= nvotes[b]) {
622     set_cvar_string("amx_nextmap", nmaps[nnextmaps[b]]);
623     new smap[32];
624     get_cvar_string("amx_nextmap", smap, 31);
625     new players[32], inum;
626     get_players(players, inum, "c");
627     if (quiet != 2) {
628     if (timeleft <= 0 || timeleft > 300) {
629 cstrike 29 set_hudmessage(222, 70,0, -1.0, 0.36, 0, 4.0, 10.0, 2.0, 2.0, 4);
630 cstrike 9 show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_MAP_WINS", nmaps[nnextmaps[b]], nvotes[b], timeleft);
631     } else {
632 cstrike 29 set_hudmessage(0, 152, 255, -1.0, 0.22, 0, 4.0, 7.0, 2.1, 1.5, 4);
633     if (get_cvar_float("enforce_timelimit") == 1.0 && is_cstrike) {
634     show_hudmessage(0, "%L %L", LANG_PLAYER, "DMAP_MAP_WINS2", nmaps[nnextmaps[b]], nvotes[b], LANG_PLAYER, "DMAP_IN_SECONDS", timeleft);
635     } else {
636     show_hudmessage(0, "%L %L", LANG_PLAYER, "DMAP_MAP_WINS2", nmaps[nnextmaps[b]], nvotes[b], LANG_PLAYER, "DMAP_SHORTLY");
637     }
638 cstrike 9 if (iscustommap(nmaps[nnextmaps[b]]) && usestandard) {
639     client_print(0, print_notify, "%L", LANG_PLAYER, "DMAP_DOWNLOAD_CUSTOM_MAP");
640     }
641     }
642     if ((containi(mapsurl, "www") != -1 || containi(mapsurl, "http") != -1) && iscustommap(nmaps[nnextmaps[b]])) {
643     //set_hudmessage(0, 152, 255, -1.0, 0.70, 1, 4.0, 12.0, 2.1, 1.5, 7);
644     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_DOWNLOAD_MAPS_URL", mapsurl);
645     }
646     if (quiet != 1) {
647     client_cmd(0, "speak ^"barney/letsgo^""); //quiet=0 (words and sounds) quiet=1 (words only, no sound) quiet=2 (no sound, no words)
648     }
649     }
650     }
651    
652     new smap[32];
653     get_cvar_string("amx_nextmap", smap, 31);
654     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_CHOOSING_FINISHED", smap);
655     #if defined DEDICATED_LOG_ENABLED
656     log_to_file(logfilename, "Vote: Voting for the nextmap finished. The nextmap will be %s", smap);
657     #endif
658     inprogress = waited = 0;
659     isend = 1;
660     //WE ARE near END OF MAP; time to invoke Round mode ALgorithm
661     //set_task(2.0, "endofround", 123452, "", 0, "b");
662     new waituntilready = timeleft - 60;
663     if (waituntilready > 30) {
664     waituntilready = 30;
665     }
666     if (waituntilready <= 0 || get_cvar_num("mp_winlimit")) {
667     addthiswait = 4;
668     set_task(4.0, "RoundMode", 333333);
669     } else {
670     set_task(float(waituntilready), "RoundMode", 333333);
671     addthiswait = waituntilready;
672     }
673     nmaps_num = nbeforefill;
674     num_nmapsfill = before_num_nmapsfill;
675     set_task(2.18, "calculate_custom");
676     return PLUGIN_HANDLED;
677     }
678    
679     public show_timer() {
680     set_task(1.0, "timedis2", 454500, "", 0, "b");
681     }
682    
683     public timedis2() {
684     new timeleft = get_timeleft();
685     if ((timeleft % 5) == 1) {
686     new smap[32];
687     get_cvar_string("amx_nextmap", smap, 31);
688     set_hudmessage(0, 132, 255, 0.02, 0.27, 0, 5.0, 5.04, 0.0, 0.5, 4);
689     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_NEXTMAP", smap);
690     if (waited < 90) {
691     set_hudmessage(255, 215, 190, 0.02, 0.2, 0, 5.0, 5.04, 0.0, 0.5, 3);
692     } else {
693     set_hudmessage(210, 0 ,0, 0.02, 0.15, 0, 5.0, 5.04, 0.0, 0.5, 3);
694     //Flashing red:set_hudmessage(210, 0 ,0, 0.02, 0.2, 1, 1.0, 1.04, 0.0, 0.05, 3);
695     }
696     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_LAST_ROUND");
697     }
698     return PLUGIN_HANDLED;
699     }
700    
701     public timedis3() {
702     new timeleft = get_timeleft();
703     if ((timeleft % 5) == 1) {
704     new smap[32];
705     get_cvar_string("amx_nextmap", smap, 31);
706     set_hudmessage(0, 132, 255, 0.02, 0.27, 0, 5.0, 5.04, 0.0, 0.5, 4);
707     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_NEXTMAP", smap);
708     if (timeleft > 30) {
709     set_hudmessage(255, 215, 190, 0.02, 0.2, 0, 5.0, 5.04, 0.0, 0.5, 3);
710     } else {
711     set_hudmessage(210, 0 ,0, 0.02, 0.15, 0, 5.0, 5.04, 0.0, 0.5, 3);
712     //Flashing red:set_hudmessage(210, 0, 0, 0.02, 0.2, 1, 5.0, 5.04, 0.0, 0.5, 3);
713     }
714     //countdown when "Enforcing timelimit"
715     new seconds = timeleft % 60;
716     new minutes = floatround((timeleft - seconds) / 60.0);
717     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_TIME_LEFT", minutes, seconds);
718     }
719     return PLUGIN_HANDLED;
720     }
721    
722     public RoundMode() {
723     if (get_cvar_float("mp_timelimit") > 0.1 && get_cvar_num("enforce_timelimit")) {
724     remove_task(333333);
725     remove_task(454500);
726     new timeleft = get_timeleft();
727     if (timeleft < 200) {
728     set_task(float(timeleft) - 5.8, "endofround");
729     set_task(1.0, "timedis3", 454500, "", 0, "b");
730     }
731     return PLUGIN_HANDLED;
732     } else {
733     if (waited == 0) {
734     set_task(1.0, "show_timer");
735     }
736     if (isbetween || isbuytime || (waited + addthiswait) > 190 || (!is_cstrike && (waited + addthiswait) >= 30) || activeplayers < 2) { //Time to switch maps!!!!!!!!
737     remove_task(333333);
738     remove_task(454500);
739     if (isbetween) {
740     set_task(3.9, "endofround");
741     } else {
742     endofround(); //switching very soon!
743     }
744     } else {
745     waited += 5;
746     //if (waited >= 15 && waited <= 150 && get_timeleft() < 7) {
747     if ((waited + addthiswait) <= 190 && get_timeleft() >= 0 && get_timeleft() <= 15) {
748     istimeset2 = 1;
749     set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + 2.0);
750     if (is_cstrike) {
751     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_FINISHING_CUR_ROUND");
752     }
753     }
754     set_task(5.0, "RoundMode", 333333);
755     }
756     }
757     return PLUGIN_HANDLED;
758     }
759    
760     public vote_count(id, key) {
761     if (get_cvar_float("amx_vote_answers")) {
762     new name[32];
763     get_user_name(id, name, 31);
764     if (key == maps_to_select) {
765     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_CHOSE_MAPEXTENDING", name);
766     } else if (key < maps_to_select) {
767     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_CHOSE_MAP", name, nmaps[nnextmaps[key]]);
768     }
769     }
770 cstrike 27 nvotes[key] += 1;
771     g_TotalVotes += 1;
772     g_AlreadyVoted[id] = true;
773     show_vote_menu(false);
774    
775 cstrike 9 return PLUGIN_HANDLED;
776     }
777    
778     bool:isinmenu(id) {
779     new a;
780     for (a = 0; a < nmapstoch; ++a) {
781     if (id == nnextmaps[a]) {
782     return true;
783     }
784     }
785     return false;
786     }
787    
788     public dmapcancelvote(id, level, cid) {
789     if (!cmd_access(id, level, cid, 0)) {
790     return PLUGIN_HANDLED ;
791     }
792     if (task_exists(765100, 1)) {
793     new authid[32], name[32];
794    
795     get_user_authid(id, authid, 31) ;
796     get_user_name(id, name, 31);
797     #if defined DEDICATED_LOG_ENABLED
798 cstrike 13 log_to_file(logfilename, "ADMIN <%s> cancelled the map vote.", name);
799 cstrike 9 #endif
800 cstrike 13 client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_ADMIN_CANCELLED", name);
801 cstrike 9 remove_task(765100, 1);
802     set_hudmessage(222, 70,0, -1.0, 0.3, 1, 10.0, 10.0, 2.0, 4.0, 8);
803 cstrike 13 show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_ADMIN_CANCELLED", name);
804 cstrike 9 hasbeenrocked = 0;
805     inprogress = 0;
806     mselected = true;
807    
808     return PLUGIN_CONTINUE;
809     } else {
810 cstrike 13 client_print(id, print_chat, "%L", id, "DMAP_NO_CURRENT_VOTE");
811 cstrike 9 }
812     return PLUGIN_HANDLED;
813     }
814    
815 cstrike 27 public dmapnominate(id, level, cid) {
816     if (!cmd_access(id, level, cid, 1)) {
817     return PLUGIN_HANDLED;
818     }
819     //
820     // TODO: Add some code..
821     //
822     return PLUGIN_HANDLED;
823     }
824    
825 cstrike 9 public levelchange() {
826     if (istimeset2 == 1) { //Allow automatic map change to take place.
827     set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") - 2.0);
828     istimeset2 = 0;
829     } else {
830     if (get_cvar_float("mp_timelimit") >= 4.0) { //Allow automatic map change to take place.
831     if (!istimeset) {
832     oldtimelimit = get_cvar_float("mp_timelimit");
833     }
834     set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") - 3);
835     istimeset = 1;
836     } else {
837     if (get_cvar_num("mp_winlimit")) { //Allow automatic map change based on teamscores
838     new largerscore;
839     largerscore = (teamscore[0] > teamscore[1]) ? teamscore[0] : teamscore[1];
840     iswinlimitset = 1;
841     oldwinlimit = get_cvar_num("mp_winlimit");
842     set_cvar_num("mp_winlimit", largerscore);
843     }
844     }
845     }
846     //If we are unable to achieve automatic level change, FORCE it.
847     set_task(2.1, "DelayedChange", 444444);
848     }
849    
850     public changeMap() { //Default event copied from nextmap.amx, and changed around.
851     set_cvar_float("mp_chattime", 3.0); // make sure mp_chattime is long
852     remove_task(444444);
853     set_task(1.85, "DelayedChange");
854     }
855    
856     public DelayedChange() {
857     new smap[32];
858     get_cvar_string("amx_nextmap", smap, 31);
859     server_cmd("changelevel %s", smap);
860     }
861    
862     public endofround() { //Call when ready to switch maps in (?) seconds
863     remove_task(123452);
864     remove_task(987111);
865     remove_task(333333);
866     remove_task(454510);
867     remove_task(454500);
868     remove_task(123499);
869     new smap[32];
870     get_cvar_string("amx_nextmap", smap, 31);
871     set_task(6.0, "levelchange"); //used to be 7.0
872     if (quiet != 2) {
873     countnum = 0;
874     set_task(1.0, "countdown", 123400, "", 0, "a", 6);
875     if (quiet != 1) {
876     client_cmd(0, "speak ^"loading environment on to your computer^"");
877     }
878     } else {
879     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_MAP_ABOUT_CHANGE");
880     }
881     ///////////////////////////////////////////////
882     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NEXTMAP2", smap);
883     if ((containi(mapsurl, "www") != -1 || containi(mapsurl, "http") != -1) && iscustommap(smap)) {
884     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_DOWNLOAD_MAPS_URL2", smap, mapsurl);
885     }
886     ///////////////////////////////////////////////
887     if (dofreeze) {
888     isspeedset = 1;
889     thespeed = get_cvar_float("sv_maxspeed");
890     set_cvar_float("sv_maxspeed", 0.0);
891     new players[32], inum, i;
892     get_players(players, inum, "c");
893     for (i = 0; i < inum; ++i) {
894     client_cmd(players[i], "drop");
895     client_cmd(players[i], "+showscores");
896     }
897     }
898     if (dofreeze) {
899     set_task(1.1, "stopperson", 123450, "", 0, "a", 2);
900     }
901     return PLUGIN_HANDLED;
902     }
903    
904     public countdown() {
905     new smap[32];
906     get_cvar_string("amx_nextmap", smap, 31);
907     countnum++;
908     set_hudmessage(150, 120, 0, -1.0, 0.3, 0, 0.5, 1.1, 0.1, 0.1, 4);
909     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_MAP_CHANGING_IN", smap, 7 - countnum);
910     return PLUGIN_HANDLED;
911     }
912    
913     public stopperson() {
914     new players[32], inum, i;
915     get_players(players, inum, "c");
916     if (isspeedset >= 0 && isspeedset < 2) {
917     thespeed = get_cvar_float("sv_maxspeed");
918     isspeedset++;
919     set_cvar_float("sv_maxspeed", 0.0);
920     }
921     for (i = 0; i < inum; ++i) {
922     client_cmd(players[i], "drop");
923     }
924     return PLUGIN_HANDLED;
925     }
926    
927     public display_message() {
928     new timeleft = get_timeleft();
929     new parttime = timeleft % (frequency * 60 * 2); //460//period(minutes/cycle) * 60 seconds/minute = period in seconds
930     //if frequency = 2 (every 2 minutes one message will appear) THIS FUNCTION COVERS 2 MESSAGES WHICH MAKES ONE CYCLE
931     //parttime=timeleft%240;
932     new addition = frequency * 60;
933     if (mselected || inprogress || cycle) {
934     return PLUGIN_CONTINUE;
935     }
936     //if (parttime > 310 && parttime < 326 && timeleft > 132)
937     if (parttime > (40 + addition) && parttime < (56 + addition) && timeleft > 132) {
938     set_task(3.0, "messagenominated", 986100); //, "", 0, "a", 4)
939     } else {
940     //if (parttime > 155 && parttime < 171 && timeleft > 132)
941     if (parttime > 30 && parttime < 46 && timeleft > 132) {
942     set_task(10.0, "messagemaps", 986200, "", 0, "a", 1);
943     } else if (timeleft >= 117 && timeleft < 132) {
944     messagefifteen();
945     }
946     }
947     return PLUGIN_CONTINUE;
948     }
949    
950     // THIS IS UNTESTED, BUT SHOULD WORK
951     /* 1.6 hudtext function
952     Arguments:
953     textblock: a string containing the text to print, not more than 512 chars (a small calc shows that the max number of letters to be displayed is around 270 btw)
954     colr, colg, colb: color to print text in (RGB format)
955     posx, posy: position on screen * 1000 (if you want text to be displayed centered, enter -1000 for both, text on top will be posx=-1000 & posy=20
956     screen: the screen to write to, hl supports max 4 screens at a time, do not use screen+0 to screen+3 for other hudstrings while displaying this one
957     time: how long the text shoud be displayed (in seconds)
958     */
959    
960     public hudtext16(textblock[] ,colr, colg, colb, posx, posy, screen, time, id) {
961     new y;
962     if (contain(textblock, "^n") == -1) { // if there is no linebreak in the text, we can just show it as it is
963     set_hudmessage(colr, colg, colb, float(posx) / 1000.0, float(posy) / 1000.0, 0, 6.0, float(time), 0.2, 0.2, screen);
964     show_hudmessage(id, textblock);
965     } else { // more than one line
966     new out[128], rowcounter = 0, tmp[512], textremain = true;
967     y = screen;
968     new i = contain(textblock, "^n");
969     copy(out, i, textblock); // we need to get the first line of text before the loop
970     do { // this is the main print loop
971     setc(tmp, 511, 0); // reset string
972     copy(tmp, 511, textblock[i + 1]); // copy everything AFTER the first linebreak (hence the +1, we don't want the linebreak in our new string)
973     setc(textblock, 511, 0); // reset string
974     copy(textblock, 511, tmp); // copy back remaining text
975     i = contain(textblock, "^n"); // get next linebreak position
976     if ((strlen(out) + i < 64) && (i != -1)) { // we can add more lines to the outstring if total letter count don't exceed 64 chars (decrease if you have a lot of short lines since the leading linbreaks for following lines also take up one char in the string)
977     add(out, 127, "^n"); // add a linebreak before next row
978     add(out, strlen(out) + i, textblock);
979     rowcounter++; // we now have one more row in the outstring
980     } else { // no more lines can be added
981     set_hudmessage(colr, colg, colb, float(posx) / 1000.0, float(posy) / 1000.0, 0, 6.0, float(time), 0.2, 0.2, screen); // format our hudmsg
982     if ((i == -1) && (strlen(out) + strlen(textblock) < 64)) {
983     add(out, 127, "^n"); // if i == -1 we are on the last line, this line is executed if the last line can be added to the current string (total chars < 64)
984     } else { // not the last line or last line must have it's own screen
985     if (screen-y < 4) {
986     show_hudmessage(id, out); // we will only print the hudstring if we are under the 4 screen limit
987     }
988     screen++; // go to next screen after printing this one
989     rowcounter++; // one more row
990     setc(out, 127, 0); // reset string
991     for (new j = 0; j < rowcounter; j++) {
992     add(out, 127, "^n"); // add leading linebreaks equal to the number of rows we already printed
993     }
994     if (i == -1) {
995     set_hudmessage(colr, colg, colb, float(posx) / 1000.0, float(posy) / 1000.0, 0, 6.0, float(time), 0.2, 0.2, screen); // format our hudmsg if we are on the last line
996     } else {
997     add(out, strlen(out) + i, textblock); // else add the next line to the outstring, before this, out is empty (or have some leading linebreaks)
998     }
999     }
1000     if (i == -1) { // apparently we are on the last line here
1001     add(out, strlen(out) + strlen(textblock), textblock); // add the last line to out
1002     if (screen - y < 4) show_hudmessage(id, out); // we will only print the hudstring if we are under the 4 screen limit
1003     textremain = false; // we have no more text to print
1004     }
1005     }
1006     } while (textremain);
1007     }
1008     return screen - y; // we will return how many screens of text we printed
1009     }
1010    
1011     public messagenominated() {
1012     if (quiet == 2) {
1013     return PLUGIN_CONTINUE;
1014     }
1015    
1016     new string[256], string2[256], string3[512];
1017     if (nmaps_num < 1) {
1018 cstrike 29 formatex(string3, 511, "%L", LANG_SERVER, "DMAP_NO_MAPS_NOMINATED");
1019 cstrike 9 } else {
1020     new n = 0, foundone = 0;
1021 cstrike 29 formatex(string, 255, "%L", LANG_SERVER, "DMAP_NOMINATIONS");
1022 cstrike 9 while (n < 3 && n < nmaps_num) {
1023 cstrike 27 formatex(string, 255, "%s %s", string, nmaps[n++]);
1024 cstrike 9 }
1025     while (n < 6 && n < nmaps_num) {
1026     foundone = 1;
1027     format(string2, 255, "%s %s", string2, nmaps[n++]);
1028     }
1029     if (foundone) {
1030 cstrike 27 formatex(string3, 511, "%s^n%s", string, string2);
1031 cstrike 9 } else {
1032 cstrike 27 formatex(string3, 511, "%s", string);
1033 cstrike 9 }
1034     }
1035     hudtext16(string3, random_num(0, 222), random_num(0, 111), random_num(111, 222), -1000, 50, random_num(1, 4), 10, 0);
1036     return PLUGIN_CONTINUE;
1037     }
1038    
1039     public listnominations(id) {
1040     if (get_pcvar_num(nominations_allowed) == 1) {
1041 cstrike 29 new a = 0, string3[512], string1[96], name1[33];
1042 cstrike 9 if (a < nmaps_num) {
1043     //show_hudmessage(id, "The following maps have been nominated for the next map vote:");
1044 cstrike 29 formatex(string3, 255, "%L", id, "DMAP_NOMINATED_MAPS");
1045 cstrike 9 }
1046     while (a < nmaps_num) {
1047     get_user_name(whonmaps_num[a], name1, 32);
1048     //set_hudmessage(255, 0, 0, 0.12, 0.3 + 0.08 * float(a), 0, 15.0, 15.04, 1.5, 3.75, 2 + a);
1049     //show_hudmessage(id, "%s by: %s", nmaps[a], name1);
1050 cstrike 29 formatex(string1, 95, "%L", id, "DMAP_MAP_BY", nmaps[a], name1);
1051     add(string3, 511, string1, 95);
1052 cstrike 9 a++;
1053     }
1054     hudtext16(string3, random_num(0, 222), random_num(0, 111), random_num(111, 222), 300, 10, random_num(1, 4), 15, id);
1055     }
1056     }
1057    
1058     public messagemaps() {
1059     if (quiet == 2) {
1060     return PLUGIN_CONTINUE;
1061     }
1062    
1063     new string[256], string2[256], string3[512];
1064     new n = 0;
1065     new total = 0;
1066    
1067     if ((totalmaps - 6) > 0) {
1068     n = random_num(0, totalmaps - 6);
1069     }
1070     while (total < 3 && total < totalmaps && is_map_valid(listofmaps[n]) && n < totalmaps) {
1071     if (!islastmaps(listofmaps[n]) && !isbanned(listofmaps[n]) && !isnominated(listofmaps[n])) {
1072     format(string, 255, "%s %s", string, listofmaps[n]);
1073     total++;
1074     }
1075     n++;
1076     }
1077     while (total < 6 && n < totalmaps && is_map_valid(listofmaps[n]) && !isnominated(listofmaps[n])) {
1078     if (!islastmaps(listofmaps[n]) && !isbanned(listofmaps[n])) {
1079     format(string2, 255, "%s %s", string2, listofmaps[n]);
1080     total++;
1081     }
1082     n++;
1083     }
1084     if (total > 0) {
1085     //show_hudmessage(0, "The following maps are available to nominate:^n%s", string);
1086     new temp[256];
1087 cstrike 29 formatex(temp, 255, "%L", LANG_SERVER, "DMAP_AVAILABLE_MAPS");
1088 cstrike 9 add(string3, 511, temp, 100);
1089     add(string3, 511, string, 100);
1090     add(string3, 511, "^n");
1091     }
1092     if (total > 3) {
1093     add(string3, 511, string2, 100);
1094     }
1095    
1096     hudtext16(string3, random_num(0, 222), random_num(0, 111), random_num(111, 222), -1000, 50, random_num(1, 4), 10, 0);
1097     return PLUGIN_CONTINUE;
1098     }
1099    
1100     public messagefifteen() {
1101     if (quiet == 2) {
1102     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_VOTING_IN_15SEC");
1103     return PLUGIN_HANDLED;
1104     }
1105     set_hudmessage(0, 222, 50, -1.0, 0.23, 1, 6.5, 6.5, 1.0, 3.0, 4);
1106     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_VOTING_IN_15SEC");
1107     if (quiet == 0) {
1108     client_cmd(0, "spk ^"get red(e80) ninety(s45) to check(e20) use bay(s18) mass(e42) cap(s50)^"");
1109     }
1110     set_task(8.7, "getready", 459100);
1111     return PLUGIN_HANDLED;
1112     }
1113    
1114     public getready() {
1115     if (!cycle) {
1116     set_task(0.93, "timetovote", 459200, "", 0, "a", 5);
1117     }
1118     }
1119    
1120     public timetovote() {
1121     counttovote++;
1122     new speak[5][] = {"one", "two", "three", "four", "five"};
1123    
1124     if (get_timeleft() > 132 || counttovote > 5 || cycle || isbuytime) {
1125     counttovote = 0;
1126     remove_task(459200);
1127     remove_task(459100);
1128     return PLUGIN_HANDLED;
1129     } else {
1130     if (counttovote > 0 && counttovote <= 5) {
1131     set_hudmessage(0, 222, 50, -1.0, 0.13, 0, 1.0, 0.94, 0.0, 0.0, 4);
1132     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_VOTING_IN_XSEC", 6 - counttovote);
1133     if (quiet != 1) {
1134     client_cmd(0, "spk ^"fvox/%s^"", speak[5 - counttovote]);
1135     }
1136     }
1137     }
1138     return PLUGIN_HANDLED;
1139     }
1140    
1141     available_maps() { //return number of maps that havent that have been added yet
1142     new num = 0, isinlist;
1143     new current_map[32], a, i;
1144     get_mapname(current_map, 31);
1145     for (a = 0; a < num_nmapsfill; a++) {
1146     if (is_map_valid(nmapsfill[a])) {
1147     isinlist = 0;
1148     for (i = 0; i < nmaps_num; i++) {
1149     if (equali(nmapsfill[a], nmaps[i])) {
1150     isinlist = 1;
1151     }
1152     }
1153     if (!isinlist) {
1154     num++;
1155     }
1156     }
1157     }
1158     return num;
1159     }
1160    
1161     public askfornextmap() {
1162     display_message();
1163     new timeleft = get_timeleft();
1164    
1165     if (isspeedset && timeleft > 30) {
1166     isspeedset = 0;
1167     set_cvar_float("sv_maxspeed", thespeed);
1168     }
1169     if (waited > 0) {
1170     return PLUGIN_HANDLED;
1171     }
1172     if (timeleft > 300) {
1173     isend = 0;
1174     remove_task(123452);
1175     }
1176     new mp_winlimit = get_cvar_num("mp_winlimit");
1177     if (mp_winlimit) {
1178     new s = mp_winlimit - 2;
1179     if ((s > teamscore[0] && s > teamscore[1]) && (timeleft > 114 || timeleft < 1)) {
1180     remove_task(454500);
1181     mselected = false;
1182     return PLUGIN_HANDLED;
1183     }
1184     } else {
1185     if (timeleft > 114 || timeleft < 1) {
1186     if (timeleft > 135) {
1187     remove_task(454510);
1188     remove_task(454500);
1189     remove_task(123499);
1190     } else {
1191     remove_task(454500);
1192     }
1193     mselected = false;
1194     return PLUGIN_HANDLED;
1195     }
1196     }
1197     if (inprogress || mselected || cycle) {
1198     return PLUGIN_HANDLED;
1199     }
1200     mselected = false;
1201     inprogress = 1;
1202     if (mp_winlimit && !(timeleft >= 115 && timeleft < 134)) {
1203     if (quiet != 2) {
1204     set_hudmessage(0, 222, 50, -1.0, 0.13, 1, 6.0, 6.0, 1.0, 1.0, 4);
1205     show_hudmessage(0, "%L", LANG_PLAYER, "DMAP_START_MAPVOTE");
1206     if (quiet != 1) {
1207     client_cmd(0, "spk ^"get red(e80) ninety(s45) to check(e20) use bay(s18) mass(e42) cap(s50)^"");
1208     }
1209     set_task(4.2, "getready", 459100);
1210     set_task(10.0, "startthevote");
1211     } else {
1212     set_task(1.0, "startthevote");
1213     }
1214     } else {
1215     set_task(0.5, "startthevote");
1216     }
1217     return PLUGIN_HANDLED;
1218     }
1219    
1220     public startthevote() {
1221 cstrike 27 new j;
1222 cstrike 9 if (cycle) {
1223     inprogress = 0;
1224     mselected = false;
1225     remove_task(459200);
1226     remove_task(459100);
1227     new smap[32];
1228     get_cvar_string("amx_nextmap", smap, 31);
1229     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NEXTMAP2", smap);
1230     return PLUGIN_HANDLED;
1231     }
1232     for (j = 0; j < maps_to_select + 2; j++) {
1233     nvotes[j] = 0;
1234     }
1235     mselected = true;
1236     inprogress = 1;
1237     counttovote = 0;
1238     if ((isbuytime || isbetween) && get_timeleft() && get_timeleft() > 54 && get_pcvar_num(weapon_delay)) {
1239     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_VOTING_DELAYED");
1240     if (isbetween) {
1241     set_task(15.0, "getready", 459100);
1242     set_task(21.0, "startthevote");
1243     } else {
1244     set_task(8.0, "getready", 459100);
1245     set_task(14.0, "startthevote");
1246     }
1247     return PLUGIN_HANDLED;
1248     } //else startthevote anyways..., regardless of buytime
1249    
1250     remove_task(459200);
1251     remove_task(459100);
1252    
1253     if (quiet != 2) {
1254     if (is_cstrike) {
1255     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_POSSIBLE_NOMINATIONS", nmaps_num, maps_to_select);
1256     }
1257     }
1258    
1259     #if defined DEDICATED_LOG_ENABLED
1260     log_to_file(logfilename, "Nominations for the map vote: %d out of %d possible nominations", nmaps_num, maps_to_select);
1261     #endif
1262    
1263     before_num_nmapsfill = num_nmapsfill;
1264     new available = available_maps();
1265    
1266     if ((nmaps_num + available) < (maps_to_select + 1)) { //Loads maps from mapcycle.txt/allmaps.txt if not enough are in in mapchoice.ini
1267    
1268     new current_map[32];
1269     get_mapname(current_map,31);
1270     new overflowprotect = 0;
1271     new used[MAX_MAPS_AMOUNT];
1272     new k = num_nmapsfill;
1273     new totalfilled = 0;
1274     new alreadyused;
1275     new tryfill, custfill = 0;
1276     new q;
1277     new listpossible = totalmaps;
1278     while (((available_maps() + nmaps_num - custfill) < (maps_to_select + 7)) && listpossible > 0) {
1279     alreadyused = 0;
1280     q = 0;
1281     tryfill = random_num(0, totalmaps - 1);
1282     overflowprotect = 0;
1283     while (used[tryfill] && overflowprotect++ <= totalmaps * 15) {
1284     tryfill = random_num(0, totalmaps - 1);
1285     }
1286     if (overflowprotect >= totalmaps * 15) {
1287     alreadyused = 1;
1288     #if defined DEDICATED_LOG_ENABLED
1289     log_to_file(logfilename, "Overflow detected in Map Nominate plugin, there might not be enough maps in the current vote");
1290     #endif
1291     listpossible -= 1;
1292     } else {
1293     while (q < num_nmapsfill && !alreadyused) {
1294     if (equali(listofmaps[tryfill], nmapsfill[q])) {
1295     alreadyused = used[tryfill] = 1;
1296     listpossible--;
1297     }
1298     q++;
1299     }
1300     q = 0;
1301     while (q < nmaps_num && !alreadyused) {
1302     if (equali(listofmaps[tryfill], nmaps[q])) {
1303     alreadyused = used[tryfill] = 1;
1304     listpossible--;
1305     }
1306     q++;
1307     }
1308     }
1309    
1310     if (!alreadyused) {
1311     if (equali(listofmaps[tryfill], current_map) || equali(listofmaps[tryfill], last_map)||
1312     islastmaps(listofmaps[tryfill]) || isbanned(listofmaps[tryfill])) {
1313     listpossible--;
1314     used[tryfill] = 1;
1315     } else {
1316     if (iscustommap(listofmaps[tryfill])) {
1317     custfill++;
1318     }
1319     nmapsfill[k] = listofmaps[tryfill];
1320     num_nmapsfill++;
1321     listpossible--;
1322     used[tryfill] = 1;
1323     k++;
1324     totalfilled++;
1325     }
1326     }
1327     }
1328     #if defined DEDICATED_LOG_ENABLED
1329     log_to_file(logfilename, "Filled %d slots in the fill maps array with maps from mapcycle.txt, %d are custom", totalfilled, custfill);
1330     #endif
1331     }
1332    
1333     nbeforefill = nmaps_num; //extra maps do not act as "nominations" they are additions
1334    
1335     if (nmaps_num < maps_to_select) {
1336    
1337     new need = maps_to_select - nmaps_num;
1338     console_print(0, "%L", LANG_PLAYER, "DMAP_RANDOM_MAPSELECTION", need);
1339     #if defined DEDICATED_LOG_ENABLED
1340     log_to_file(logfilename, "Randomly Filling slots for the vote with %d out of %d", need, num_nmapsfill);
1341     #endif
1342     new fillpossible = num_nmapsfill;
1343     new k = nmaps_num;
1344     new overflowprotect = 0;
1345     new used[MAX_MAPS_AMOUNT];
1346     new totalfilled = 0, custchoice = 0, full = ((amt_custom + custchoice) >= maxcustnom);
1347     new alreadyused;
1348     new tryfill;
1349     if (num_nmapsfill < 1) {
1350     if (quiet != 2) {
1351     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NOMORE_RANDOM_DEFINED");
1352     }
1353     #if defined DEDICATED_LOG_ENABLED
1354     log_to_file(logfilename, "ERROR: Unable to fill any more voting slots with random maps, none defined in mapchoice.ini/allmaps.txt/mapcycle.txt");
1355     #endif
1356     } else {
1357     while (fillpossible > 0 && k < maps_to_select) {
1358     alreadyused = 0;
1359     new q = 0;
1360     tryfill = random_num(0, num_nmapsfill - 1);
1361     overflowprotect = 0;
1362     while (used[tryfill] && overflowprotect++ <= num_nmapsfill * 10) {
1363     tryfill = random_num(0, num_nmapsfill - 1);
1364     }
1365     if (overflowprotect >= num_nmapsfill * 15) {
1366     alreadyused = 1;
1367     #if defined DEDICATED_LOG_ENABLED
1368     log_to_file(logfilename, "Overflow detected in Map Nominate plugin, there might not be enough maps in the current vote");
1369     #endif
1370     fillpossible -= 2;
1371     } else {
1372     while (q < nmaps_num && !alreadyused) {
1373     if (equali(nmapsfill[tryfill], nmaps[q])) {
1374     alreadyused = used[tryfill] = 1;
1375     fillpossible--;
1376     }
1377     q++;
1378     }
1379     if (!alreadyused) {
1380     if (iscustommap(nmapsfill[tryfill]) && full) {
1381     alreadyused = used[tryfill] = 1;
1382     fillpossible--;
1383     }
1384     }
1385     }
1386    
1387     if (!alreadyused) {
1388     if (iscustommap(nmapsfill[tryfill])) {
1389     custchoice++;
1390     full = ((amt_custom + custchoice) >= maxcustnom);
1391     }
1392     nmaps[k] = nmapsfill[tryfill];
1393     nmaps_num++;
1394     fillpossible--;
1395     used[tryfill] = 1;
1396     k++;
1397     totalfilled++;
1398     }
1399     }
1400    
1401     if (totalfilled == 0) {
1402     console_print(0, "%L", LANG_PLAYER, "DMAP_NO_DEFAULTMAPS_FOUND");
1403     } else {
1404     if (quiet != 2) {
1405     console_print(0, "%L", LANG_PLAYER, "DMAP_FILLED_RANDOM_MAPS", totalfilled);
1406     }
1407     }
1408     #if defined DEDICATED_LOG_ENABLED
1409     log_to_file(logfilename, "Filled %d vote slots with random maps, %d are custom", totalfilled, custchoice);
1410     #endif
1411     }
1412     }
1413    
1414 cstrike 27 show_vote_menu(true);
1415     return PLUGIN_HANDLED;
1416     }
1417    
1418     show_vote_menu(bool:bFirstTime) {
1419    
1420 cstrike 9 new menu[512], a, mkeys = (1 << maps_to_select + 1);
1421     new Float:steptime = get_cvar_float("amx_extendmap_step");
1422     new extendint = floatround(steptime);
1423    
1424     new pos;
1425    
1426 cstrike 27 new mp_winlimit = get_cvar_num("mp_winlimit");
1427     if (bFirstTime == true) {
1428     g_TotalVotes = 0;
1429     for (a = 0; a <= 32; a++) {
1430     g_AlreadyVoted[a] = false;
1431     }
1432     }
1433    
1434 cstrike 9 if (cstrike_running() == 1) {
1435 cstrike 29 pos = formatex(menu, 511, "%L", LANG_SERVER, "DMAP_CS_MENU_TITLE");
1436 cstrike 9 } else {
1437 cstrike 29 pos = formatex(menu, 511, "%L", LANG_SERVER, "DMAP_MENU_TITLE");
1438 cstrike 9 }
1439    
1440     new dmax = (nmaps_num > maps_to_select) ? maps_to_select : nmaps_num;
1441    
1442 cstrike 27 new tagpath[64], sMenuOption[64]; // If size of sMenuOption is changed, change maxlength in append_vote_percent as well
1443     formatex(tagpath, 63, "%s/dmaptags.ini", custompath);
1444    
1445 cstrike 9 for (nmapstoch = 0; nmapstoch < dmax; ++nmapstoch) {
1446 cstrike 27 if (bFirstTime == true) {
1447     a = random_num(0, nmaps_num - 1); // Randomize order of maps in vote
1448     while (isinmenu(a)) {
1449     if (++a >= nmaps_num) {
1450     a = 0;
1451     }
1452 cstrike 9 }
1453 cstrike 27 nnextmaps[nmapstoch] = a;
1454     nvotes[nmapstoch] = 0; // Reset votes for each map
1455 cstrike 9 }
1456 cstrike 16
1457 cstrike 27 if (iscustommap(nmaps[nnextmaps[nmapstoch]]) && usestandard) {
1458 cstrike 9 if (cstrike_running() == 1) {
1459 cstrike 29 formatex(sMenuOption, 63, "%L", LANG_SERVER, "DMAP_CS_MENU_CUSTOM", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]]);
1460 cstrike 9 } else {
1461 cstrike 29 formatex(sMenuOption, 63, "%L", LANG_SERVER, "DMAP_MENU_CUSTOM", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]]);
1462 cstrike 9 }
1463 cstrike 16 } else { // Don't show (Custom)
1464 cstrike 27 formatex(sMenuOption, 63, "%d. %s", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]]);
1465 cstrike 9 }
1466 cstrike 16
1467     if (file_exists(tagpath)) { // If the tag file is there, check for the extra tag
1468     new iLine, sFullLine[64], sTagMap[32], sTagText[32], txtLen;
1469    
1470 cstrike 27 while (read_file(tagpath, iLine, sFullLine, 63, txtLen)) {
1471 cstrike 16 if (sFullLine[0] == ';') {
1472     iLine++;
1473     continue; // Ignore comments
1474     }
1475    
1476 cstrike 27 strbreak(sFullLine, sTagMap, 31, sTagText, 31); // Split the map name and tag apart
1477 cstrike 16
1478 cstrike 27 if (equali(nmaps[nnextmaps[nmapstoch]], sTagMap)) {
1479     format(sMenuOption, 63, "%s [%s]", sMenuOption, sTagText);
1480 cstrike 16 break; // Quit reading the file
1481     }
1482     iLine++;
1483     }
1484     }
1485    
1486 cstrike 27 append_vote_percent(sMenuOption, nmapstoch, true);
1487 cstrike 16 pos += formatex(menu[pos], 511, sMenuOption);
1488    
1489 cstrike 9 mkeys |= (1 << nmapstoch);
1490     }
1491    
1492     menu[pos++] = '^n';
1493 cstrike 27 if (bFirstTime == true) {
1494     nvotes[maps_to_select] = 0;
1495     nvotes[maps_to_select + 1] = 0;
1496     }
1497 cstrike 9 new mapname[32];
1498     get_mapname(mapname, 31);
1499     if (!mp_winlimit && get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max")) {
1500 cstrike 29 formatex(sMenuOption, 63, "%L", LANG_SERVER, "DMAP_MENU_EXTEND", maps_to_select + 1, mapname, extendint);
1501 cstrike 27 append_vote_percent(sMenuOption, maps_to_select, true);
1502     pos += formatex(menu[pos], 511, sMenuOption);
1503    
1504 cstrike 9 mkeys |= (1 << maps_to_select);
1505     }
1506    
1507 cstrike 29 formatex(sMenuOption, 63, "%L", LANG_SERVER, "DMAP_MENU_NONE", maps_to_select + 2);
1508 cstrike 27 append_vote_percent(sMenuOption, maps_to_select + 1);
1509     formatex(menu[pos], 511, sMenuOption);
1510    
1511     if (bFirstTime == true) {
1512     g_VoteTimeRemaining = DMAP_VOTE_TIME;
1513     set_task(float(g_VoteTimeRemaining), "check_votes");
1514     show_menu(0, mkeys, menu, --g_VoteTimeRemaining);
1515     set_task(1.0, "update_vote_time_remaining", DMAP_TASKID_VTR, "", 0, "a", g_VoteTimeRemaining);
1516     if (is_cstrike) {
1517     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_TIME_TO_CHOOSE");
1518     }
1519     if (quiet == 0) {
1520     client_cmd(0, "spk Gman/Gman_Choose%d", random_num(1, 2));
1521     }
1522 cstrike 9 #if defined DEDICATED_LOG_ENABLED
1523 cstrike 27 log_to_file(logfilename, "Vote: Voting for the nextmap started");
1524 cstrike 9 #endif
1525 cstrike 27 } else {
1526     new players[32], iNum, id;
1527     get_players(players, iNum, "ch");
1528     for (new iPlayer = 0; iPlayer < iNum; iPlayer++) {
1529     id = players[iPlayer];
1530     if (g_AlreadyVoted[id] == false) {
1531     show_menu(players[iPlayer], mkeys, menu, g_VoteTimeRemaining);
1532     }
1533     }
1534    
1535     }
1536     return PLUGIN_HANDLED;
1537 cstrike 9 }
1538    
1539 cstrike 27 stock percent(iIs, iOf) {
1540     return (iOf != 0) ? floatround(floatmul(float(iIs) / float(iOf), 100.0)) : 0;
1541     }
1542    
1543     append_vote_percent(sMenuOption[], iChoice, bool:bNewLine = false) {
1544    
1545     new iPercent = percent(nvotes[iChoice], g_TotalVotes);
1546     new sPercent[16];
1547     if (iPercent > 0) { // Don't show 0%
1548     if (cstrike_running() == 1) {
1549     formatex(sPercent, 15, " \d(%d%s)\w", iPercent, "%%");
1550     } else {
1551     formatex(sPercent, 15, " (%d%s)", iPercent, "%%");
1552     }
1553     strcat(sMenuOption, sPercent, 63);
1554     }
1555    
1556     if (bNewLine == true) { // Do this even if vote is 0%
1557     strcat(sMenuOption, "^n", 63);
1558     }
1559    
1560     return PLUGIN_HANDLED;
1561     }
1562    
1563     public update_vote_time_remaining() {
1564     if (--g_VoteTimeRemaining <= 0) {
1565     remove_task(DMAP_TASKID_VTR);
1566     }
1567     return PLUGIN_HANDLED;
1568     }
1569    
1570 cstrike 9 public handle_andchange(id, map2[]) {
1571 cstrike 27 new tester[32];
1572 cstrike 9 if (is_map_valid(map2) == 1) {
1573     handle_nominate(id, map2);
1574     } else {
1575 cstrike 27 formatex(tester, 31, "cs_%s", map2);
1576 cstrike 9 if (is_map_valid(tester) == 1) {
1577     handle_nominate(id, tester);
1578     } else {
1579 cstrike 27 formatex(tester, 31, "de_%s", map2);
1580 cstrike 9 if (is_map_valid(tester) == 1) {
1581     handle_nominate(id, tester);
1582     } else {
1583 cstrike 27 formatex(tester, 31, "as_%s", map2);
1584 cstrike 9 if (is_map_valid(tester) == 1) {
1585     handle_nominate(id, tester);
1586     } else {
1587 cstrike 27 formatex(tester, 31, "dod_%s", map2);
1588 cstrike 9 if (is_map_valid(tester) == 1) {
1589     handle_nominate(id, tester);
1590     } else {
1591 cstrike 27 formatex(tester, 31, "fy_%s", map2);
1592 cstrike 9 if (is_map_valid(tester) == 1) {
1593     handle_nominate(id, tester);
1594     } else {
1595     handle_nominate(id, map2);
1596     }
1597     }
1598     }
1599     }
1600     }
1601     }
1602     }
1603    
1604     public HandleSay(id) {
1605    
1606     new chat[256];
1607 cstrike 27 read_args(chat, 255);
1608 cstrike 9 new saymap[256];
1609     saymap = chat;
1610     remove_quotes(saymap);
1611 cstrike 27 new saymap2[29];
1612     read_args(saymap2, 28);
1613 cstrike 9 remove_quotes(saymap2);
1614     new chat2[32];
1615 cstrike 27
1616 cstrike 9 if (containi(chat, "<") != -1 || containi(chat, "?") != -1 || containi(chat, ">") != -1 || containi(chat, "*") != -1 || containi(chat, "&") != -1 || containi(chat, ".") != -1) {
1617     return PLUGIN_CONTINUE;
1618     }
1619     if (containi(chat, "nominations") != -1) {
1620     if (get_pcvar_num(nominations_allowed) == 0) {
1621 cstrike 13 client_print(id, print_chat, "%L", id, "DMAP_NOMINATIONS_DISABLED");
1622 cstrike 9 return PLUGIN_HANDLED;
1623     }
1624     if (mselected) {
1625 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_VOTE_IN_PROGRESS");
1626 cstrike 9 } else {
1627     if (nmaps_num == 0) {
1628 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_NO_NOMINATIONS");
1629 cstrike 9 } else {
1630     listnominations(id);
1631     }
1632     }
1633     } else {
1634     if (containi(chat, "nominate ") == 1) {
1635     new mycommand[32];
1636     read_args(mycommand, 32);
1637     remove_quotes(mycommand);
1638     handle_andchange(id, mycommand[9]);
1639     } else {
1640     if (containi(chat, "vote ") == 1) {
1641     new mycommand[32];
1642     read_args(mycommand, 32);
1643     remove_quotes(mycommand);
1644     handle_andchange(id, mycommand[5]);
1645     } else {
1646     if (is_map_valid(saymap) == 1) {
1647     handle_nominate(id, saymap);
1648     } else {
1649 cstrike 27 formatex(chat2, 31, "cs_%s", saymap2);
1650 cstrike 9 if (is_map_valid(chat2) == 1) {
1651     handle_nominate(id, chat2);
1652     } else {
1653 cstrike 27 formatex(chat2, 31, "de_%s", saymap2);
1654 cstrike 9 if (is_map_valid(chat2) == 1) {
1655     handle_nominate(id, chat2);
1656     } else {
1657 cstrike 27 formatex(chat2, 31, "as_%s", saymap2);
1658 cstrike 9 if (is_map_valid(chat2) == 1) {
1659     handle_nominate(id, chat2);
1660     } else {
1661 cstrike 27 formatex(chat2, 31, "dod_%s", saymap2);
1662 cstrike 9 if (is_map_valid(chat2) == 1) {
1663     handle_nominate(id, chat2);
1664     } else {
1665 cstrike 27 formatex(chat2, 31, "fy_%s", saymap2);
1666 cstrike 9 if (is_map_valid(chat2) == 1) {
1667     handle_nominate(id, chat2);
1668     }
1669     }
1670     }
1671     }
1672     }
1673     }
1674     }
1675     }
1676     }
1677     return PLUGIN_CONTINUE;
1678     }
1679    
1680     public calculate_custom() {
1681     //New optional protection against "too many" custom maps being nominated.
1682     amt_custom = 0;
1683     new i;
1684     for (i = 0; i < nmaps_num; i++) {
1685     if (iscustommap(nmaps[i])) {
1686     amt_custom++;
1687     }
1688     }
1689     }
1690    
1691     public handle_nominate(id, map[]) {
1692     if (get_pcvar_num(nominations_allowed) == 0) {
1693 cstrike 13 client_print(id, print_chat, "%L", id, "DMAP_NOMINATIONS_DISABLED");
1694 cstrike 9 return PLUGIN_HANDLED;
1695     }
1696     strtolower(map);
1697     new current_map[32], iscust = 0, iscust_t = 0, full;
1698     full = (amt_custom >= maxcustnom);
1699     new n = 0, i, done = 0, isreplacement = 0; //0: (not a replacement), 1: (replacing his own), 2: (replacing others)
1700     new tempnmaps = nmaps_num;
1701     get_mapname(current_map, 31);
1702     if (maxnom == 0) {
1703 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_NOMINATIONS_DISABLED");
1704 cstrike 9 return PLUGIN_HANDLED;
1705     }
1706     if (inprogress && mselected) {
1707 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_VOTING_IN_PROGRESS");
1708 cstrike 9 return PLUGIN_HANDLED;
1709     }
1710     if (mselected) {
1711     new smap[32];
1712     get_cvar_string("amx_nextmap", smap, 31);
1713 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_VOTING_OVER", smap);
1714 cstrike 9 return PLUGIN_HANDLED;
1715     }
1716     if (!is_map_valid(map) || is_map_valid(map[1])) {
1717 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_MAP_NOTFOUND", map);
1718 cstrike 9 return PLUGIN_HANDLED;
1719     }
1720     if (isbanned(map)) {
1721 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_MAPVOTE_NOT_AVAILABLE");
1722 cstrike 9 return PLUGIN_HANDLED;
1723     }
1724     if (islastmaps(map) && !equali(map, current_map)) {
1725 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_CANT_NOMINATE_LASTMAP", ban_last_maps);
1726 cstrike 9 return PLUGIN_HANDLED;
1727     }
1728     if (equali(map, current_map)) {
1729 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_EXTEND_MAP", map);
1730 cstrike 9 return PLUGIN_HANDLED;
1731     }
1732     //Insert Strict Style code here, for pcvar dmap_strict 1
1733     if (get_pcvar_num(dmap_strict)) {
1734     new isinthelist = 0;
1735     for (new a = 0; a < totalmaps; a++) {
1736     if (equali(map, listofmaps[a]))
1737     isinthelist = 1;
1738     }
1739     if (!isinthelist) {
1740 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_ALLOWED_MAPS");
1741 cstrike 9 return PLUGIN_HANDLED;
1742     }
1743     }
1744     iscust = iscustommap(map);
1745     if (nmaps_num >= maps_to_select || Nominated[id] >= maxnom) { //3 (1,2,3)
1746     if (Nominated[id] > maxnom) { //3
1747 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_MAX_MAPS_REACHED"); //Possible to reach here!
1748 cstrike 9 //only if the command dmap_nominations is used to lower amount of maps that can be nominated
1749     return PLUGIN_HANDLED;
1750     }
1751    
1752     for (i = 0; i < nmaps_num; i++) {
1753     if (equali(map, nmaps[i])) {
1754    
1755     new name[32];
1756     get_user_name(whonmaps_num[i], name, 32);
1757     if (quiet == 2) {
1758 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_ALREADY_NOMINATED", map, name);
1759 cstrike 9 } else {
1760     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_ALREADY_NOMINATED", map, name);
1761     }
1762     return PLUGIN_HANDLED;
1763     }
1764     }
1765    
1766     while (n < nmaps_num && !done && Nominated[id] > 1) { //If the person has nominated 2 or 3 maps, he can replace his own
1767     if (whonmaps_num[n] == id) { //If a map is found that he has nominated, replace his own nomination.
1768     iscust_t = iscustommap(nmaps[n]);
1769     if (!(full && iscust && !iscust_t)) {
1770     Nominated[id] = Nominated[id] - 1;
1771     nmaps_num = n;
1772     done = 1;
1773     isreplacement = 1;
1774     }
1775     }
1776     n++;
1777     }
1778    
1779     if (!done) {
1780     n = 0;
1781     while (n < nmaps_num && !done && Nominated[id] < 2) { //If the person has nom only 1 or no maps, he can replace ppl who nominated 3
1782     if (Nominated[whonmaps_num[n]] > 2) { //Replace the "greedy person's" nomination
1783     iscust_t = iscustommap(nmaps[n]);
1784     if (!(full && iscust && !iscust_t)) {
1785     done = 1;
1786     Nominated[whonmaps_num[n]] = Nominated[whonmaps_num[n]] - 1;
1787     nmaps_num = n;
1788     isreplacement = 2;
1789     }
1790     }
1791     n++;
1792     }
1793     }
1794     if (!done) {
1795     n = 0;
1796    
1797     while (n < nmaps_num && !done && Nominated[id] < 1) { //If the person has not nom any maps, he can replace those with more than one
1798     //he cannot replace those with only one nomination, that would NOT be fair
1799    
1800     if (Nominated[whonmaps_num[n]] > 1) { //Replace the "greedy person's" nomination
1801     iscust_t = iscustommap(nmaps[n]);
1802     if (!(full && iscust && !iscust_t)) {
1803     done = 1;
1804     Nominated[whonmaps_num[n]] = Nominated[whonmaps_num[n]] - 1;
1805     nmaps_num = n;
1806     isreplacement = 2;
1807     }
1808     }
1809     n++;
1810     }
1811     }
1812    
1813     if (!done) {
1814     n = 0;
1815    
1816     while (n < nmaps_num && !done && Nominated[id] > 0) { //If the person has nominated a map, he can replace his own
1817     if (whonmaps_num[n] == id) { //If a map is found that he has nominated, replace his own nomination.
1818     iscust_t = iscustommap(nmaps[n]);
1819     if (!(full && iscust && !iscust_t)) { //Check to see if too many custom maps are nominated
1820     Nominated[id] = Nominated[id] - 1;
1821     nmaps_num = n;
1822     done = 1;
1823     isreplacement = 1;
1824     }
1825     }
1826     n++;
1827     }
1828     }
1829     if (!done) {
1830 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_MAX_NOMINATIONS_REACHED", nmaps_num);
1831 cstrike 9 return PLUGIN_HANDLED;
1832     }
1833     }
1834    
1835     for (i = 0; i < nmaps_num; i++) {
1836     if (equali(map, nmaps[i])) {
1837     new name[32];
1838     get_user_name(whonmaps_num[i], name, 32);
1839    
1840 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_ALREADY_NOMINATED", map, name);
1841 cstrike 9
1842     nmaps_num = tempnmaps;
1843    
1844     return PLUGIN_HANDLED;
1845     }
1846     }
1847    
1848     if (!isreplacement && iscust && full) {
1849 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_MAX_CUSTOMMAPS_REACHED", maxcustnom);
1850 cstrike 9 return PLUGIN_HANDLED;
1851     }
1852    
1853     new name[32];
1854     get_user_name(id, name, 21);
1855     if (isreplacement == 1) { //They are replacing their old map
1856     if (quiet == 2) {
1857 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_REPLACE_PREVIOUS_NOMINATION", nmaps[nmaps_num]);
1858 cstrike 9 } else {
1859     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_PLAYER_REPLACED_NOMINATION", name, nmaps[nmaps_num]);
1860     }
1861     } else {
1862     if (isreplacement == 2) {
1863     if (quiet == 2) {
1864     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NOMINATION_REPLACED", nmaps[nmaps_num]);
1865     } else {
1866     new name21[32];
1867     get_user_name(whonmaps_num[nmaps_num], name21, 31);
1868     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NOMINATION_REPLACED2", name21, nmaps[nmaps_num]);
1869     }
1870     }
1871     }
1872    
1873     Nominated[id]++;
1874    
1875 cstrike 10 console_print(id, "%L", id, "DMAP_ADD_NOMINATION", map, nmaps_num + 1);
1876 cstrike 9
1877     set_task(0.18, "calculate_custom");
1878     copy(nmaps[nmaps_num], 31, map);
1879     whonmaps_num[nmaps_num] = id;
1880    
1881     if (isreplacement) {
1882     nmaps_num = tempnmaps;
1883     } else {
1884     nmaps_num = tempnmaps + 1;
1885     }
1886     client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NOMINATED_MAP", name, map);
1887    
1888     return PLUGIN_HANDLED;
1889     }
1890    
1891     public team_score() {
1892    
1893     new team[2];
1894     read_data(1, team, 1);
1895     teamscore[(team[0] == 'C') ? 0 : 1] = read_data(2);
1896    
1897     return PLUGIN_CONTINUE;
1898     }
1899    
1900     public plugin_end() {
1901     new current_map[32];
1902     get_mapname(current_map, 31);
1903     set_localinfo("amx_lastmap", current_map);
1904    
1905     if (istimeset) {
1906     set_cvar_float("mp_timelimit", oldtimelimit);
1907     } else {
1908     if (istimeset2) {
1909     set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") - 2.0);
1910     }
1911     }
1912     if (isspeedset) {
1913     set_cvar_float("sv_maxspeed", thespeed);
1914     }
1915     if (iswinlimitset) {
1916     set_cvar_num("mp_winlimit", oldwinlimit);
1917     }
1918     return PLUGIN_CONTINUE;
1919     }
1920    
1921     public get_listing() {
1922     new i = 0, iavailable = 0;
1923     new line = 0, p;
1924     new stextsize = 0, isinthislist = 0, found_a_match = 0, done = 0;
1925     new linestr[256];
1926     new maptext[32];
1927     new current_map[32];
1928     get_mapname(current_map, 31);
1929     //pathtomaps = "mapcycle.txt";
1930     get_cvar_string("mapcyclefile", pathtomaps, 63);
1931     new smap[32];
1932     get_cvar_string("amx_nextmap", smap, 31);
1933     if (file_exists(pathtomaps)) {
1934     while (read_file(pathtomaps, line, linestr, 255, stextsize) && !done) {
1935 cstrike 27 formatex(maptext, 31, "%s", linestr);
1936 cstrike 9 if (is_map_valid(maptext) && !is_map_valid(maptext[1]) && equali(maptext, current_map)) {
1937     done = found_a_match = 1;
1938     line++;
1939     if (read_file(pathtomaps, line, linestr, 255, stextsize)) {
1940 cstrike 27 formatex(maptext, 31, "%s", linestr);
1941 cstrike 9 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
1942     //////////////////////////////////////////
1943     if (equali(smap, "")) {
1944     register_cvar("amx_nextmap", "", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY);
1945     }
1946     set_cvar_string("amx_nextmap", maptext);
1947     } else {
1948     found_a_match = 0;
1949     }
1950     } else {
1951     found_a_match = 0;
1952     }
1953     } else {
1954     line++;
1955     }
1956     }
1957     /*
1958     if (!found_a_match) {
1959     line = 0;
1960     while (read_file(pathtomaps, line, linestr, 255, stextsize) && !found_a_match && line < 1024) {
1961 cstrike 27 formatex(maptext, 31, "%s", linestr);
1962 cstrike 9 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
1963     if (equali(smap, "")) {
1964     register_cvar("amx_nextmap", "", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY);
1965     }
1966     set_cvar_string("amx_nextmap", maptext);
1967     found_a_match = 1;
1968     } else {
1969     line++;
1970     }
1971     }
1972     }
1973     */
1974     /* CODE TO RANDOMIZE NEXTMAP VARIABLE!*/
1975     if (!found_a_match) {
1976     line = random_num(0, 50);
1977     new tries = 0;
1978    
1979     while ((read_file(pathtomaps, line, linestr, 255, stextsize) || !found_a_match) && (tries < 1024 && !found_a_match)) {
1980 cstrike 27 formatex(maptext, 31, "%s", linestr);
1981 cstrike 9 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
1982     if (equali(smap, "")) {
1983     register_cvar("amx_nextmap", "", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY);
1984     }
1985     set_cvar_string("amx_nextmap", maptext);
1986     found_a_match = 1;
1987     } else {
1988     line = random_num(0, 50);
1989     tries++;
1990     }
1991     }
1992     }
1993     }
1994    
1995     line = 0;
1996 cstrike 27 formatex(pathtomaps, 63, "%s/allmaps.txt", custompath);
1997 cstrike 9 if (!file_exists(pathtomaps)) {
1998     new mapsadded = 0;
1999     while ((line = read_dir("maps", line, linestr, 255, stextsize)) != 0) {
2000     stextsize -= 4;
2001    
2002     if (stextsize > 0) {
2003     if (!equali(linestr[stextsize], ".bsp")) {
2004     continue; // skip non map files
2005     }
2006     linestr[stextsize] = 0; // remove .bsp
2007     }
2008    
2009     if (is_map_valid(linestr)) {
2010     write_file(pathtomaps, linestr);
2011     mapsadded++;
2012     }
2013     }
2014     #if defined DEDICATED_LOG_ENABLED
2015     log_to_file(logfilename, "Found %d maps in your <mod>/MAPS folder, and added these to the addons/amxmodx/allmaps.txt file", mapsadded);
2016     #endif
2017     line = 0;
2018     }
2019    
2020     if (get_pcvar_float(dmap_strict) == 1.0) {
2021     get_cvar_string("mapcyclefile", pathtomaps, 63);
2022     //pathtomaps = "mapcycle.txt";
2023     }
2024    
2025     if (file_exists(pathtomaps)) {
2026     while (read_file(pathtomaps, line, linestr, 255, stextsize) && i < MAX_MAPS_AMOUNT) {
2027 cstrike 27 formatex(maptext, 31, "%s", linestr);
2028 cstrike 9 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
2029     isinthislist = 0;
2030     for (p = 0; p < i; p++) {
2031     if (equali(maptext, listofmaps[p])) {
2032     isinthislist = 1;
2033     }
2034     }
2035     if (!isinthislist) {
2036     listofmaps[i++] = maptext;
2037     }
2038     }
2039     line++;
2040     }
2041     }
2042    
2043     line = 0;
2044     for (p = 0; p < i; p++) {
2045     if (!isbanned(listofmaps[p]) && !islastmaps(listofmaps[p])) {
2046     iavailable++;
2047     }
2048     }
2049     new dummy_str[64];
2050     get_cvar_string("mapcyclefile", dummy_str, 63);
2051     //if (iavailable < maps_to_select && !equali(pathtomaps, "mapcycle.txt"))
2052     if (iavailable < maps_to_select && !equali(pathtomaps, dummy_str)) {
2053     //pathtomaps = "mapcycle.txt";
2054     get_cvar_string("mapcyclefile", pathtomaps, 63);
2055     if (file_exists(pathtomaps)) {
2056     while (read_file(pathtomaps, line, linestr, 255, stextsize) && i < MAX_MAPS_AMOUNT) {
2057 cstrike 27 formatex(maptext, 31, "%s", linestr);
2058 cstrike 9 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
2059     isinthislist = 0;
2060     for (p = 0; p < i; p++)
2061     if (equali(maptext, listofmaps[p])) {
2062     isinthislist = 1;
2063     }
2064     if (!isinthislist) {
2065     listofmaps[i++] = maptext;
2066     }
2067     }
2068     line++;
2069     }
2070     }
2071     }
2072     totalmaps = i;
2073     iavailable = 0;
2074     for (p = 0; p < i; p++) {
2075     if (!isbanned(listofmaps[p]) && !islastmaps(listofmaps[p])) {
2076     iavailable++;
2077     }
2078     }
2079     #if defined DEDICATED_LOG_ENABLED
2080     log_to_file(logfilename, "Found %d Maps in your mapcycle.txt/allmaps.txt file, %d are available for filling slots", i, iavailable);
2081     #endif
2082     }
2083    
2084     public ban_some_maps() {
2085     //BAN MAPS FROM CONFIG FILE
2086     new banpath[64];
2087 cstrike 27 formatex(banpath, 63, "%s/mapstoban.ini", custompath);
2088 cstrike 9 new i = 0;
2089     new line = 0;
2090     new stextsize = 0;
2091     new linestr[256];
2092     new maptext[32];
2093    
2094     if (file_exists(banpath)) {
2095     while (read_file(banpath, line, linestr, 255, stextsize) && i < MAX_MAPS_AMOUNT) {
2096 cstrike 27 formatex(maptext, 31, "%s", linestr);
2097 cstrike 9 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
2098     banthesemaps[i++] = maptext;
2099     }
2100     line++;
2101     }
2102     }
2103     totalbanned = i;
2104     #if defined DEDICATED_LOG_ENABLED
2105     if (totalbanned > 0) {
2106     log_to_file(logfilename, "Banned %d Maps in your mapstoban.ini file", totalbanned);
2107     } else {
2108     log_to_file(logfilename, "Did not ban any maps from mapstoban.ini file");
2109     }
2110     #endif
2111     //BAN RECENT MAPS PLAYED
2112     new lastmapspath[64];
2113 cstrike 27 formatex(lastmapspath, 63, "%s/lastmapsplayed.txt", custompath);
2114 cstrike 9 //new linestring[32];
2115     line = stextsize = 0;
2116     new current_map[32];
2117     get_mapname(current_map, 31);
2118     lastmaps[0] = current_map;
2119     bannedsofar++;
2120     currentplayers = activeplayers = rocks = 0;
2121     if (file_exists(lastmapspath)) {
2122     while(read_file(lastmapspath, line, linestr, 255, stextsize) && bannedsofar <= ban_last_maps) {
2123     if ((strlen(linestr) > 0) && (is_map_valid(linestr))) {
2124 cstrike 27 formatex(lastmaps[bannedsofar++], 31, "%s", linestr);
2125 cstrike 9 }
2126     line++;
2127     }
2128     }
2129     write_lastmaps(); //deletes and writes to lastmapsplayed.txt
2130     }
2131    
2132     public write_lastmaps() {
2133     new lastmapspath[64];
2134 cstrike 27 formatex(lastmapspath, 63, "%s/lastmapsplayed.txt", custompath);
2135 cstrike 9 if (file_exists(lastmapspath)) {
2136     delete_file(lastmapspath);
2137     }
2138     new text[256], p;
2139     for (p = 0; p < bannedsofar; p++) {
2140 cstrike 27 formatex(text, 255, "%s", lastmaps[p]);
2141 cstrike 9 write_file(lastmapspath, text);
2142     }
2143     write_file(lastmapspath, "Generated by map_nominate plugin,");
2144     write_file(lastmapspath, "these are most recent maps played");
2145    
2146     load_maps();
2147     }
2148    
2149     public load_maps() {
2150     new choicepath[64];
2151 cstrike 27 formatex(choicepath, 63, "%s/mapchoice.ini", custompath);
2152 cstrike 9 new line = 0;
2153     new stextsize = 0, isinlist, unable = 0, i;
2154     new linestr[256];
2155     new maptext[32];
2156     new current_map[32];
2157     get_mapname(current_map, 31);
2158     if (file_exists(choicepath)) {
2159     while (read_file(choicepath, line, linestr, 255, stextsize) && (num_nmapsfill < MAX_MAPS_AMOUNT)) {
2160 cstrike 27 formatex(maptext, 31, "%s", linestr);
2161 cstrike 9 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
2162     isinlist = 0;
2163     if (isbanned(maptext) || islastmaps(maptext)) {
2164     isinlist = 1;
2165     } else {
2166     if (equali(maptext, current_map) || equali(maptext, last_map)) {
2167     isinlist = 1;
2168     } else {
2169     for (i = 0; i < num_nmapsfill; i++) {
2170     if (equali(maptext, nmapsfill[i])) {
2171     #if defined DEDICATED_LOG_ENABLED
2172     log_to_file(logfilename, "Map ^"%s^" is already in list! It is defined it twice", maptext);
2173     #endif
2174     isinlist = 1;
2175     }
2176     }
2177     }
2178     }
2179     if (!isinlist) {
2180     copy(nmapsfill[num_nmapsfill++], 31, maptext);
2181     } else {
2182     unable++;
2183     }
2184     }
2185     line++;
2186     }
2187     #if defined DEDICATED_LOG_ENABLED
2188     log_to_file(logfilename, "Loaded %d Maps into the maps that will be picked for the vote", num_nmapsfill);
2189     log_to_file(logfilename, "%d Maps were not loaded because they were the last maps played, or defined twice, or banned", unable);
2190     } else {
2191     log_to_file(logfilename, "Unable to open file %s, In order to get maps: your mapcycle.txt file will be searched", choicepath);
2192     #endif
2193     }
2194     get_listing();
2195     }
2196    
2197     public load_defaultmaps() {
2198     new standardpath[64];
2199 cstrike 27 formatex(standardpath, 63, "%s/standardmaps.ini", custompath);
2200 cstrike 9 new i = 0;
2201     new line = 0;
2202     new stextsize = 0;
2203     new linestr[256];
2204     new maptext[32];
2205     usestandard = 1;
2206     if (!file_exists(standardpath)) {
2207     usestandard = standardtotal = 0;
2208     } else {
2209     while(read_file(standardpath, line, linestr, 255, stextsize) && i < 40) {
2210 cstrike 27 formatex(maptext, 31, "%s", linestr);
2211 cstrike 9 if (is_map_valid(maptext)) {
2212     standard[i++] = maptext;
2213     }
2214     line++;
2215     }
2216     standardtotal = i;
2217     }
2218     if (standardtotal < 5) {
2219     usestandard = 0;
2220     #if defined DEDICATED_LOG_ENABLED
2221     log_to_file(logfilename, "Attention, %d Maps were found in the standardmaps.ini file. This is no problem, but the words Custom will not be used", standardtotal);
2222     #endif
2223     }
2224     }
2225    
2226     bool:iscustommap(map[]) {
2227     new a;
2228     for (a = 0; a < standardtotal; a++) {
2229     if (equali(map, standard[a])) {
2230     return false;
2231     }
2232     }
2233     if (usestandard) {
2234     return true;
2235     }
2236     return false;
2237     }
2238    
2239     bool:islastmaps(map[]) {
2240     new a;
2241     for (a = 0; a < bannedsofar; a++) {
2242     if (equali(map, lastmaps[a])) {
2243     return true;
2244     }
2245     }
2246     return false;
2247     }
2248    
2249     bool:isnominated(map[]) {
2250     new a;
2251     for (a = 0; a < nmaps_num; a++) {
2252     if (equali(map, nmaps[a])) {
2253     return true;
2254     }
2255     }
2256     return false;
2257     }
2258    
2259     bool:isbanned(map[]) {
2260     new a;
2261     for (a = 0; a < totalbanned; a++) {
2262     if (equali(map, banthesemaps[a])) {
2263     return true;
2264     }
2265     }
2266     return false;
2267     }
2268    
2269     loadsettings(filename[]) {
2270     if (!file_exists(filename)) {
2271     return 0;
2272     }
2273    
2274     new text[256], percent[5], strban[4], strplay[3], strwait[3], strwait2[3], strurl[64], strnum[3], strnum2[3];
2275     new len, pos = 0;
2276     new Float:numpercent;
2277     new banamount, nplayers, waittime, mapsnum;
2278     while (read_file(filename, pos++, text, 255, len)) {
2279     if (text[0] == ';') {
2280     continue;
2281     }
2282     switch(text[0]) {
2283     case 'r': {
2284 cstrike 27 formatex(percent, 4, "%s", text[2]);
2285 cstrike 9 numpercent = float(str_to_num(percent)) / 100.0;
2286     if (numpercent >= 0.03 && numpercent <= 1.0) {
2287     rtvpercent = numpercent;
2288     }
2289     }
2290     case 'q': {
2291     if (text[1] == '2') {
2292     quiet = 2;
2293     } else {
2294     quiet = 1;
2295     }
2296     }
2297     case 'c': {
2298     cycle = 1;
2299     }
2300     case 'd': {
2301     enabled = 0;
2302     }
2303     case 'f': {
2304     if (text[1] == 'r') {
2305 cstrike 27 formatex(strwait2, 2, "%s", text[2]);
2306 cstrike 9 waittime = str_to_num(strwait2);
2307     if (waittime >= 2 && waittime <= 20) {
2308     frequency = waittime;
2309     }
2310     } else {
2311     dofreeze = 0;
2312     }
2313     }
2314     case 'b': {
2315 cstrike 27 formatex(strban, 3, "%s", text[2]);
2316 cstrike 9 banamount = str_to_num(strban);
2317     if (banamount >= 0 && banamount <= 100) {
2318     if ((banamount == 0 && text[2] == '0') || banamount > 0) {
2319     ban_last_maps = banamount;
2320     }
2321     }
2322     }
2323     case 'm': {
2324     if (atstart) {
2325 cstrike 27 formatex(strnum, 2, "%s", text[2]);
2326 cstrike 9 mapsnum = str_to_num(strnum);
2327     if (mapsnum >= 2 && mapsnum <= 8) {
2328     maps_to_select = mapssave = mapsnum;
2329     }
2330     }
2331     }
2332     case 'p': {
2333 cstrike 27 formatex(strplay, 2, "%s", text[2]);
2334 cstrike 9 nplayers = str_to_num(strplay);
2335     if (nplayers > 0 && nplayers <= 32) {
2336     minimum = nplayers;
2337     }
2338     }
2339     case 'u': {
2340 cstrike 27 formatex(strurl, 63, "%s", text[2]);
2341 cstrike 9 if ((containi(strurl, "www") != -1 || containi(strurl, "http") != -1) && !equali(strurl, "http")) {
2342     mapsurl = strurl;
2343     }
2344     }
2345     case 'w': {
2346 cstrike 27 formatex(strwait, 2, "%s", text[2]);
2347 cstrike 9 waittime = str_to_num(strwait);
2348     if (waittime >= 5 && waittime <= 30) {
2349     minimumwait = waittime;
2350     }
2351     }
2352     case 'x': {
2353 cstrike 27 formatex(strnum2, 2, "%s", text[2]);
2354 cstrike 9 mapsnum = str_to_num(strnum2);
2355     if (mapsnum >= 1 && mapsnum <= 3) {
2356     maxnom = mapsnum;
2357     }
2358     }
2359     case 'y': {
2360 cstrike 27 formatex(strnum2, 2, "%s", text[2]);
2361 cstrike 9 mapsnum = str_to_num(strnum2);
2362     if (mapsnum >= 0 && mapsnum <= mapssave) {
2363     maxcustnom = mapsnum;
2364     }
2365     }
2366     }
2367     }
2368     return 1;
2369     }
2370    
2371     set_defaults(myid) {
2372    
2373     rtvpercent = 0.6;
2374     ban_last_maps = 4;
2375     maxnom = frequency = 3;
2376     quiet = cycle = 0;
2377     minimum = enabled = 1;
2378     minimumwait = 10;
2379     mapssave = maxcustnom = 5;
2380     mapsurl = "";
2381     dofreeze = cstrike_running() == 1;
2382    
2383     if (myid < 0) {
2384     savesettings(-1);
2385     } else {
2386     savesettings(myid);
2387     showsettings(myid);
2388     console_print(myid, "================== DEFAULTS SET =========================");
2389     }
2390     }
2391    
2392     public dmaprtvpercent(id, level, cid) {
2393     if (!cmd_access(id, level, cid, 2)) {
2394     return PLUGIN_HANDLED;
2395     }
2396    
2397     new arg[32];
2398     read_argv(1, arg, 3);
2399     new Float:percentage = float(str_to_num(arg)) / 100.0;
2400     if (percentage >= 0.03 && percentage <= 1.0) {
2401     rtvpercent = percentage;
2402     savesettings(id);
2403     showsettings(id);
2404     } else {
2405     console_print(id, "You must specify a value between 3 and 100 for dmap_rtvpercent");
2406     console_print(id, "This sets minimum percent of players that must say rockthevote to rockit");
2407     }
2408     return PLUGIN_HANDLED;
2409     }
2410    
2411     public dmaprtvplayers(id, level, cid) {
2412     if (!cmd_access(id, level, cid, 2)) {
2413     return PLUGIN_HANDLED;
2414     }
2415    
2416     new arg[32];
2417     read_argv(1, arg, 3);
2418     new players = str_to_num(arg);
2419     if (players >= 1 && players <= 32) {
2420     minimum = players;
2421     savesettings(id);
2422     showsettings(id);
2423     } else {
2424     console_print(id, "You must specify a value between 1 and 32 for dmap_rtvplayers");
2425     console_print(id, "This sets minimum num of players that must say rockthevote to rockit");
2426     }
2427     return PLUGIN_HANDLED;
2428     }
2429    
2430     public dmaprtvwait(id, level, cid) {
2431     if (!cmd_access(id, level, cid, 2)) {
2432     return PLUGIN_HANDLED;
2433     }
2434    
2435     new arg[32];
2436     read_argv(1, arg, 3);
2437     new wait = str_to_num(arg);
2438     if (wait >= 5 && wait <= 30) {
2439     minimumwait = wait;
2440     savesettings(id);
2441     showsettings(id);
2442     } else {
2443     console_print(id, "You must specify a value between 5 and 30 for dmap_rtvwait");
2444     console_print(id, "This sets how long must pass from the start of map before players may rockthevote");
2445     }
2446     return PLUGIN_HANDLED;
2447     }
2448    
2449     public dmapmessages(id, level, cid) {
2450     if (!cmd_access(id, level, cid, 2)) {
2451     return PLUGIN_HANDLED;
2452     }
2453    
2454     new arg[32];
2455     read_argv(1, arg, 3);
2456     new wait = str_to_num(arg);
2457     if (wait >= 2 && wait <= 20) {
2458     frequency = wait;
2459     savesettings(id);
2460     showsettings(id);
2461     } else {
2462     console_print(id, "You must specify a value between 2 and 20 minutes for dmap_messages");
2463     console_print(id, "This sets how many minutes will pass between messages for nominations for available maps");
2464     }
2465     return PLUGIN_HANDLED;
2466     }
2467    
2468     public dmapmapsnum(id, level, cid) {
2469     if (!cmd_access(id, level, cid, 2)) {
2470     return PLUGIN_HANDLED;
2471     }
2472    
2473     new arg[32];
2474     read_argv(1, arg, 3);
2475     new maps = str_to_num(arg);
2476     if (maps >= 2 && maps <= 8) {
2477     mapssave = maps;
2478     savesettings(id);
2479     showsettings(id);
2480     console_print(id, "***** Settings for dmap_mapsnum do NOT take effect until the next map!!! ******");
2481     } else {
2482     console_print(id, "You must specify a value between 2 and 8 for dmap_mapsnum");
2483     console_print(id, "This sets the # of maps in the vote, changing this doesn't take effect until the next map");
2484     }
2485     return PLUGIN_HANDLED;
2486     }
2487    
2488     public dmapmaxnominations(id, level, cid) {
2489     if (!cmd_access(id, level, cid, 2)) {
2490     return PLUGIN_HANDLED;
2491     }
2492    
2493     new arg[32];
2494     read_argv(1, arg, 3);
2495     new thisnumber = str_to_num(arg);
2496     if (thisnumber >= 0 && thisnumber <= 3) {
2497     maxnom = thisnumber;
2498     savesettings(id);
2499     showsettings(id);
2500     console_print(id, "***** Settings for dmap_nominations do NOT take effect until the next map!!! ******");
2501     } else {
2502     console_print(id, "You must specify a value between 0 and 3 for dmap_nominations");
2503     console_print(id, "This sets the maximum number of maps a person can nominate");
2504     }
2505     return PLUGIN_HANDLED;
2506     }
2507    
2508     public dmapmaxcustom(id, level, cid) {
2509     if (!cmd_access(id, level, cid, 2)) {
2510     return PLUGIN_HANDLED;
2511     }
2512    
2513     new arg[32];
2514     read_argv(1, arg, 3);
2515     new thisnumber = str_to_num(arg);
2516     if (thisnumber >= 0 && thisnumber <= mapssave) {
2517     maxcustnom = thisnumber;
2518     savesettings(id);
2519     showsettings(id);
2520     } else {
2521     console_print(id, "You must specify a value between {0} and maximum maps in the vote, which is {%d}, for dmap_maxcustom", mapssave);
2522     console_print(id, "This sets the maximum number of custom maps that may be nominated by the players");
2523     }
2524     return PLUGIN_HANDLED;
2525     }
2526    
2527     public dmapquiet(id, level, cid) {
2528     if (!cmd_access(id, level, cid, 2)) {
2529     return PLUGIN_HANDLED;
2530     }
2531    
2532     new arg[32];
2533     read_argv(1, arg, 31);
2534     if (containi(arg, "off") != -1) {
2535     console_print(id, "======Quiet mode is now OFF, messages pertaining to maps will be shown=====");
2536     quiet = 0;
2537     } else if (containi(arg, "silent") != -1) {
2538     console_print(id, "======Quiet mode is now set to SILENT, A minimal amount of messages will be shown!=====");
2539     quiet = 2;
2540     } else if (containi(arg, "nosound") != -1) {
2541     console_print(id, "======Quiet mode is now set to NOSOUND, messages pertaining to maps will be shown, with no sound=====");
2542     quiet = 1;
2543     } else {
2544     console_print(id, "USAGE: dmap_quietmode <OFF|NOSOUND|SILENT>");
2545     return PLUGIN_HANDLED;
2546     }
2547     savesettings(id);
2548     showsettings(id);
2549     return PLUGIN_HANDLED;
2550     }
2551    
2552     public dmaprtvtoggle(id, level, cid) {
2553     if (!cmd_access(id, level, cid, 1)) {
2554     return PLUGIN_HANDLED;
2555     }
2556    
2557     if (enabled == 0) {
2558     console_print(id, "=========Rockthevote is now enabled==============");
2559     } else {
2560     console_print(id, "=========Rockthevote is not disabled=================");
2561     }
2562     enabled = !enabled;
2563     savesettings(id);
2564     showsettings(id);
2565     return PLUGIN_HANDLED;
2566     }
2567    
2568     public changefreeze(id, level, cid) {
2569     if (!cmd_access(id, level, cid, 1)) {
2570     return PLUGIN_HANDLED;
2571     }
2572    
2573     if (!cstrike_running()) {
2574     console_print(id, "Freeze is always off on non-Counter Strike Servers");
2575     return PLUGIN_HANDLED;
2576     }
2577    
2578     new arg[32];
2579     read_argv(1, arg, 31);
2580     if (containi(arg, "off") != -1) {
2581     console_print(id, "=========FREEZE/Weapon Drop at end of round is now disabled==============");
2582     dofreeze = 0;
2583     } else {
2584     if (containi(arg, "on") != -1) {
2585     console_print(id, "=========FREEZE/Weapon Drop at end of round is now enabled==============");
2586     dofreeze = 1;
2587     } else {
2588     console_print(id, "========= USAGE of dmap_freeze: dmap_freeze on|off (this will turn freeze/weapons drop at end of round on/off");
2589     return PLUGIN_HANDLED;
2590     }
2591     }
2592     savesettings(id);
2593     showsettings(id);
2594     return PLUGIN_HANDLED;
2595     }
2596    
2597     public dmapcyclemode(id, level, cid) {
2598     if (!cmd_access(id, level, cid, 1)) {
2599     return PLUGIN_HANDLED;
2600     }
2601    
2602     if (!cycle) {
2603     console_print(id, "========= Cylce mode is now ON, NO VOTE will take place! =========");
2604     } else {
2605     console_print(id, "========= Cycle Mode is already on, no change is made =========");
2606     console_print(id, "========= If you are trying to enable voting, use command dmap_votemode");
2607     return PLUGIN_HANDLED;
2608     }
2609     cycle = 1;
2610     savesettings(id);
2611     showsettings(id);
2612     if (inprogress) {
2613     console_print(id, "========= The Vote In Progress cannot be terminated, unless it hasn't started! =========");
2614     }
2615     return PLUGIN_HANDLED;
2616     }
2617    
2618     public dmapvotemode(id, level, cid) {
2619     if (!cmd_access(id, level, cid, 1)) {
2620     return PLUGIN_HANDLED;
2621     }
2622    
2623     if (cycle) {
2624     console_print(id, "========= Voting mode is now ON, Votes WILL take place =========");
2625     } else {
2626     console_print(id, "========= Voting mode is already ON, no change is made =========");
2627     console_print(id, "========= If you are trying to disable voting, use command dmap_cyclemode");
2628     return PLUGIN_HANDLED;
2629     }
2630     cycle = 0;
2631     savesettings(id);
2632     showsettings(id);
2633     return PLUGIN_HANDLED;
2634     }
2635    
2636     public dmapbanlastmaps(id, level, cid) {
2637     if (!cmd_access(id, level, cid, 2)) {
2638     return PLUGIN_HANDLED;
2639     }
2640    
2641     new arg[32];
2642     read_argv(1, arg, 4);
2643     new banamount;
2644     banamount = str_to_num(arg);
2645     if (banamount >= 0 && banamount <= 99) {
2646     if (banamount > ban_last_maps) {
2647     console_print(id, "You have choosen to increase the number of banned maps");
2648     console_print(id, "Changes will not take affect until the nextmap; maps played more than %d maps ago will not be included in the ban", ban_last_maps);
2649     } else {
2650     if (banamount < ban_last_maps) {
2651     console_print(id, "You have choosen to decrease the number of banned maps");
2652     }
2653     }
2654     ban_last_maps = banamount;
2655     savesettings(id);
2656     showsettings(id);
2657     } else {
2658     console_print(id, "You must specify a value between 0 and 99 for dmap_banlastmaps");
2659     console_print(id, "dmap_banlastmaps <n> will ban the last <n> maps from being voted/nominated");
2660     }
2661     return PLUGIN_HANDLED;
2662     }
2663    
2664     public dmaphelp(id) {
2665     if (!(get_user_flags(id) & ADMIN_MAP)) {
2666     new myversion[32];
2667     get_cvar_string("Deags_Map_Manage", myversion, 31);
2668     console_print(id, "*****This server uses the plugin Deagles NextMap Management %s *****", myversion);
2669     console_print(id, "");
2670     if (cycle) {
2671     console_print(id, "=================== The plugin is set to cycle mode. No vote will take place =================");
2672     return PLUGIN_HANDLED;
2673     }
2674     console_print(id, "Say ^"vote mapname^" ^"nominate mapname^" or just simply ^"mapname^" to nominate a map");
2675     console_print(id, "");
2676     console_print(id, "Say ^"nominations^" to see a list of maps already nominated.");
2677     console_print(id, "Say ^"listmaps^" for a list of maps you can nominate");
2678     console_print(id, "Number of maps for the vote at the end of this map will be: %d", maps_to_select);
2679     console_print(id, "Players may nominate up to %d maps for the vote (dmap_nominations)", maxnom);
2680     console_print(id, "Players may nominate up to %d **Custom** maps for the vote (dmap_maxcustom)", maxcustnom);
2681     if (enabled) {
2682     console_print(id, "Say ^"rockthevote^" to rockthevote");
2683     console_print(id, "In order to rockthevote the following 3 conditions need to be true:");
2684     console_print(id, "%d percent of players must rockthevote, and at least %d players must rockthevote", floatround(rtvpercent * 100.0), minimum);
2685     console_print(id, "Vote may not be rocked before %d minutes have elapsed on the map", minimumwait);
2686     }
2687     if (containi(mapsurl, "www") != -1 || containi(mapsurl, "http") != -1) {
2688     console_print(id, "You can download Custom maps at %s (dmap_mapsurl)", mapsurl);
2689     }
2690     return PLUGIN_HANDLED;
2691     }
2692     //For CS 1.6, the following MOTD will display nicely, for 1.5, It will show html tags.
2693 cstrike 10 client_print(id, print_chat, "%L", id, "DMAP_MOTD_LOADING");
2694 cstrike 9 showmotdhelp(id);
2695    
2696     return PLUGIN_HANDLED;
2697     }
2698    
2699     public gen_maphelphtml() {
2700     new path[64], text[128];
2701 cstrike 27 formatex(path, 63, "%s/map_manage_help.htm", custompath);
2702 cstrike 9 if (file_exists(path)) {
2703     delete_file(path);
2704     }
2705 cstrike 27 formatex(text, 127, "%L", LANG_SERVER, "DMAP_HELP");
2706 cstrike 9 write_file(path, text);
2707 cstrike 27 formatex(text, 127, "%L", LANG_SERVER, "DMAP_HELP2");
2708 cstrike 9 write_file(path, text);
2709 cstrike 27 formatex(text, 127, "%L", LANG_SERVER, "DMAP_HELP3");
2710 cstrike 9 write_file(path, text);
2711 cstrike 27 formatex(text, 127, "%L", LANG_SERVER, "DMAP_HELP4");
2712 cstrike 9 write_file(path, text);
2713 cstrike 27 formatex(text, 127, "%L", LANG_SERVER, "DMAP_HELP5");
2714 cstrike 9 write_file(path, text);
2715 cstrike 27 formatex(text, 127, "%L", LANG_SERVER, "DMAP_HELP6");
2716 cstrike 9 write_file(path, text);
2717 cstrike 27 formatex(text, 127, "%L", LANG_SERVER, "DMAP_HELP7");
2718 cstrike 9 write_file(path, text);
2719 cstrike 27 formatex(text, 127, "%L", LANG_SERVER, "DMAP_HELP8");
2720 cstrike 9 write_file(path, text);
2721     }
2722    
2723     public showmotdhelp(id) {
2724     new header[80];
2725     new myversion[32];
2726 cstrike 27 new helpfile[64];
2727     formatex(helpfile, 63, "%s/map_manage_help.htm", custompath);
2728 cstrike 9 get_cvar_string("Deags_Map_Manage", myversion, 31);
2729 cstrike 29 formatex(header, 79, "%L", id, "DMAP_HELP9", myversion);
2730 cstrike 9 if (!file_exists(helpfile)) {
2731     gen_maphelphtml();
2732     }
2733     show_motd(id, helpfile, header);
2734     }
2735    
2736     public dmapstatus(id, level, cid) {
2737     if (!cmd_access(id, level, cid, 1)) {
2738     return PLUGIN_HANDLED;
2739     }
2740    
2741     showsettings(id);
2742     return PLUGIN_CONTINUE;
2743     }
2744    
2745     showsettings(id) {
2746    
2747     console_print(id, "-----------------------------------------------------------------------------------------------");
2748     console_print(id, " Status of Deagles Map Management Version %s", VERSION);
2749    
2750     if (cycle) {
2751     console_print(id, "=================== Mode is Cycle Mode NO vote will take place =================");
2752     console_print(id, "=================== To enable voting use command dmap_votemode ===================");
2753     } else {
2754     console_print(id, "======================= Current Mode is Voting Mode ===============================");
2755     if (quiet == 2) {
2756     console_print(id, "Quiet Mode is set to SILENT. Minimal text messages will be shown, no sound will be played (dmap_quietmode)");
2757     } else {
2758     if (quiet == 1) {
2759     console_print(id, "Quiet Mode is set to NOSOUND. Text messages will be shown, with no sound. (dmap_quietmode)");
2760     } else {
2761     console_print(id, "Quiet Mode is OFF, messages will be shown with sound (dmap_quietmode)");
2762     }
2763     console_print(id, "The time between messages about maps is %d minutes (dmap_messages)", frequency);
2764     }
2765    
2766     console_print(id, "The last %d Maps played will not be in the vote (changing this will not start until the Next Map)", ban_last_maps);
2767    
2768     if (maps_to_select != mapssave) {
2769     console_print(id, "Number of maps for the vote on this map is: %d (Next Map it will be: %d)", maps_to_select, mapssave);
2770     } else {
2771     console_print(id, "Number of maps for the vote at the end of this map will be: %d (dmap_mapsnum)", maps_to_select);
2772     }
2773    
2774     console_print(id, "Players may nominate up to %d maps each for the vote (dmap_nominations)", maxnom);
2775    
2776     console_print(id, "Players may nominate up to %d **Custom** maps each for the vote (dmap_maxcustom)", maxcustnom);
2777    
2778     if (get_cvar_num("enforce_timelimit")) {
2779     console_print(id, "^"Timeleft^" will be followed to change the maps, not allowing players to finish the round");
2780     console_print(id, "To change this, ask your server admin to set the cvar ^"enforce_timelimit^" to 0");
2781     }
2782    
2783     if (enabled == 0) {
2784     if (!get_cvar_num("mp_timelimit")) {
2785     console_print(id, "rockthevote is disabled since mp_timelimit is set to 0");
2786     } else {
2787     console_print(id, "rockthevote is disabled; (dmap_rtvtoggle)");
2788     }
2789     }
2790     console_print(id, "In order to rockthevote the following 3 conditions need to be met:");
2791     console_print(id, "%d percent of players must rockthevote, and at least %d players must rockthevote", floatround(rtvpercent * 100.0), minimum);
2792     console_print(id, "Vote may not be rocked before %d minutes have elapsed on the map (10 is recommended)", minimumwait);
2793     }
2794    
2795     console_print(id, "The Freeze/Weapons Drop at the end of the round is %s (dmap_freeze)", dofreeze ? "ENABLED" : "DISABLED");
2796    
2797     if (!usestandard) {
2798     console_print(id, "Custom will not be shown by any maps, since file standardmaps.ini is not on the server");
2799     } else {
2800     console_print(id, "The words custom will be shown by Custom maps");
2801     }
2802     if (containi(mapsurl, "www") != -1 || containi(mapsurl, "http") != -1) {
2803     console_print(id, "URL to download Custom maps is %s (dmap_mapsurl)", mapsurl);
2804     } else {
2805     console_print(id, "URL to download maps from will not be shown (dmap_mapsurl)");
2806     }
2807     console_print(id, "------------------------------------------------------------------------------------------------");
2808     console_print(id, "Commands : dmap_status; dmap_cyclemode; dmap_votemode; dmap_quietmode <OFF|NOSOUND|SILENT>; ");
2809     console_print(id, "Commands : dmap_banlastmaps <n>; dmap_default ; dmap_mapsurl <url>; dmap_mapsnum <n>; dmap_maxcustom <n>;");
2810     console_print(id, "Commands : dmap_rtvtoggle; dmap_rtvpercent <n>; dmap_rtvplayers <n>; dmap_rtvwait <n>");
2811     console_print(id, "Commands : dmap_rockthevote; dmap_freeze; dmap_nominations <n>; dmap_messages <n(minutes)>");
2812     console_print(id, "Cvars: dmap_strict <0|1>, enforce_timelimit <0|1>; amx_extendmap_max <n>; amx_extendmap_step <n>");
2813     console_print(id, "------------------------- use command dmap_help for more information -----------------------");
2814     }
2815    
2816     change_custom_path() {
2817     new temp[64];
2818 cstrike 27 formatex(temp, 63, "%s/dmap", custompath);
2819 cstrike 9 if (dir_exists(temp)) {
2820     copy(custompath, 48, temp);
2821     }
2822     }
2823    
2824     savesettings(myid) {
2825    
2826     new settings[64];
2827 cstrike 27 formatex(settings, 63, "%s/mapvault.dat", custompath);
2828 cstrike 9
2829     if (file_exists(settings)) {
2830     delete_file(settings);
2831     }
2832     new text[32], text2[128], percent, success = 1, usedany = 0;
2833 cstrike 27 formatex(text2, 127, ";To use comments simply use ;");
2834 cstrike 9 if (!write_file(settings,text2)) {
2835     success = 0;
2836     }
2837 cstrike 27 formatex(text2, 127, ";Do not modify this variables, this is used by the Nomination_style_voting plugin to save settings");
2838 cstrike 9
2839     if (!write_file(settings, text2)) {
2840     success = 0;
2841     }
2842 cstrike 27 formatex(text2, 127, ";If you delete this file, defaults will be restored.");
2843 cstrike 9 if (!write_file(settings, text2)) {
2844     success = 0;
2845     }
2846 cstrike 27 formatex(text2, 127, ";If you make an invalid setting, that specific setting will restore to the default");
2847 cstrike 9 if (!write_file(settings, text2)) {
2848     success = 0;
2849     }
2850     if (!enabled) {
2851 cstrike 27 formatex(text, 31, "d"); //d for disabled
2852 cstrike 9 usedany = 1;
2853     if (!write_file(settings, text)) {
2854     success = 0;
2855     }
2856     }
2857     if (quiet != 0) {
2858     if (quiet == 1) {
2859 cstrike 27 formatex(text, 31, "q1"); //d for disabled
2860 cstrike 9 } else {
2861 cstrike 27 formatex(text, 31, "q2"); //d for disabled
2862 cstrike 9 }
2863     usedany = 1;
2864     if (!write_file(settings, text)) {
2865     success = 0;
2866     }
2867     }
2868     if (!dofreeze || !(cstrike_running() == 1)) {
2869 cstrike 27 formatex(text, 31, "f");
2870 cstrike 9 if (!write_file(settings, text)) {
2871     success = 0;
2872     }
2873     }
2874     if (cycle) {
2875 cstrike 27 formatex(text, 31, "c"); //c for Cycle mode=on
2876 cstrike 9 usedany = 1;
2877     if (!write_file(settings, text)) {
2878     success = 0;
2879     }
2880     }
2881     percent = floatround(rtvpercent * 100.0);
2882     if (percent >= 3 && percent <= 100) {
2883 cstrike 27 formatex(text, 31, "r %d", percent);
2884 cstrike 9 usedany = 1;
2885     if (!write_file(settings, text)) {
2886     success = 0;
2887     }
2888     }
2889     if (ban_last_maps >= 0 && ban_last_maps <= 100) {
2890 cstrike 27 formatex(text, 31, "b %d", ban_last_maps);
2891 cstrike 9 usedany = 1;
2892     if (!write_file(settings, text)) {
2893     success = 0;
2894     }
2895     }
2896     if (mapssave >= 2 && mapssave <= 8) {
2897 cstrike 27 formatex(text, 31, "m %d", mapssave);
2898 cstrike 9 usedany = 1;
2899     if (!write_file(settings, text)) {
2900     success = 0;
2901     }
2902     }
2903     if (maxnom >= 0 && maxnom <= 3) {
2904 cstrike 27 formatex(text, 31, "x %d", maxnom);
2905 cstrike 9 usedany = 1;
2906     if (!write_file(settings, text)) {
2907     success = 0;
2908     }
2909     }
2910     if (maxcustnom >= 0 && maxcustnom <= mapssave) {
2911 cstrike 27 formatex(text, 31, "y %d", maxcustnom);
2912 cstrike 9 usedany = 1;
2913     if (!write_file(settings, text)) {
2914     success = 0;
2915     }
2916     }
2917     if (minimum > 0 && minimum <= 32) {
2918 cstrike 27 formatex(text, 31, "p %d", minimum);
2919 cstrike 9 usedany = 1;
2920     if (!write_file(settings, text)) {
2921     success = 0;
2922     }
2923     }
2924     if (minimumwait >= 5 && minimumwait <= 30) {
2925 cstrike 27 formatex(text, 31, "w %d", minimumwait);
2926 cstrike 9 usedany = 1;
2927     if (!write_file(settings, text)) {
2928     success = 0;
2929     }
2930     }
2931     if (frequency >= 2 && frequency <= 20) {
2932 cstrike 27 formatex(text, 31, "fr %d", frequency);
2933 cstrike 9 usedany = 1;
2934     if (!write_file(settings, text)) {
2935     success = 0;
2936     }
2937     }
2938     if (containi(mapsurl, "www") != -1 || containi(mapsurl, "http") != -1) {
2939 cstrike 27 formatex(text2, 75, "u %s", mapsurl);
2940 cstrike 9 usedany = 1;
2941     if (!write_file(settings, text2)) {
2942     success = 0;
2943     }
2944     }
2945     if (usedany) {
2946     if (myid >= 0) {
2947     if (success) {
2948     console_print(myid, "********* Settings saved successfully *********");
2949     } else {
2950     console_print(myid, "Unable to write to file %s", settings);
2951     }
2952     }
2953     if (!success) {
2954     #if defined DEDICATED_LOG_ENABLED
2955     log_to_file(logfilename, "Unable to write to file %s", settings);
2956     #endif
2957     return 0;
2958     }
2959     } else {
2960     if (myid >= 0) {
2961     console_print(myid, "Variables not valid, not saving to %s", settings);
2962     }
2963     #if defined DEDICATED_LOG_ENABLED
2964     log_to_file(logfilename, "Warning: Variables not valid, not saving to %s", settings);
2965     #endif
2966     return 0;
2967     }
2968     return 1;
2969     }
2970    
2971     public dmapmapsurl(id, level, cid) {
2972     if (!cmd_access(id, level, cid, 2)) {
2973     return PLUGIN_HANDLED;
2974     }
2975    
2976     new arg[64];
2977     read_argv(1, arg, 63);
2978     if (equali(arg, "http")) {
2979     console_print(id, "You must specify a url that contains www or http (do not use any colons)(use ^"none^" to disable)");
2980     return PLUGIN_HANDLED;
2981     }
2982     if (containi(arg, "www") != -1 || containi(arg, "http") != -1) {
2983     console_print(id, "You have changed the mapsurl to %s", arg);
2984     mapsurl = arg;
2985     savesettings(id);
2986     showsettings(id);
2987     } else {
2988     if (containi(arg, "none") != -1) {
2989     console_print(id, "You have choosen to disable your mapsurl, none will be used");
2990     mapsurl = "";
2991     savesettings(id);
2992     showsettings(id);
2993     } else {
2994     console_print(id, "You must specify a url that contains www or http (do not use any colons)(use ^"none^" to disable)");
2995     }
2996     }
2997     return PLUGIN_HANDLED;
2998     }
2999    
3000     public dmapdefaults(id, level, cid) {
3001     if (!cmd_access(id, level, cid, 1)) {
3002     return PLUGIN_HANDLED;
3003     }
3004    
3005     set_defaults(id);
3006     return PLUGIN_HANDLED;
3007     }
3008    
3009     public event_RoundStart() {
3010     isbetween = 0;
3011     isbuytime = 1;
3012     set_task(10.0, "now_safe_to_vote");
3013    
3014     currounds++;
3015     new players[32], playernum;
3016     get_players(players, playernum, "c");
3017     curplayers += playernum;
3018     }
3019    
3020     public event_RoundEnd() {
3021     isbetween = 1;
3022     }
3023    
3024     public now_safe_to_vote() {
3025     //client_print(0, print_chat, "Now it is safe to vote");
3026     isbuytime = 0;
3027     }
3028    
3029     public list_maps2() {
3030     messagemaps();
3031     }
3032    
3033     public list_maps3() {
3034     messagenominated();
3035     }
3036    
3037     public plugin_init() {
3038    
3039     register_plugin(PLUGIN, VERSION, AUTHOR);
3040     register_dictionary("deagsmapmanager.txt");
3041    
3042     get_configsdir(custompath, 49);
3043     change_custom_path();
3044    
3045     register_clcmd("say", "HandleSay", 0, "Say: vote mapname, nominate mapname, or just mapname to nominate a map, say: nominations");
3046     register_clcmd("say rockthevote", "rock_the_vote", 0, "Rocks the Vote");
3047     register_clcmd("say rtv", "rock_the_vote", 0, "Rocks the Vote");
3048     register_clcmd("say listmaps", "list_maps", 0, "Lists all maps in a window and in console");
3049     register_clcmd("say nextmap", "say_nextmap", 0, "Shows nextmap information to players");
3050     register_concmd("dmap_help", "dmaphelp", 0, "Shows on-screen help information about Map Plugin");
3051     register_concmd("dmap_status", "dmapstatus", ADMIN_DMAP, "Shows settings/status/help of the map management variables");
3052     register_concmd("dmap_votemode", "dmapvotemode", ADMIN_SUPER_DMAP, "Enables Voting (This is default mode)");
3053     register_concmd("dmap_cyclemode", "dmapcyclemode", ADMIN_SUPER_DMAP, "Disables Voting (To restore voting use dmap_votemode)");
3054     register_concmd("dmap_banlastmaps", "dmapbanlastmaps", ADMIN_SUPER_DMAP, "Bans the last <n> maps played from being voted (0-99)");
3055     register_concmd("dmap_quietmode", "dmapquiet", ADMIN_SUPER_DMAP, "Usage: <OFF|nosound|silent>");
3056     register_concmd("dmap_freeze", "changefreeze", ADMIN_SUPER_DMAP, "Toggles Freeze/Drop at end of round ON|off");
3057     register_concmd("dmap_messages", "dmapmessages", ADMIN_SUPER_DMAP, "Sets the time interval in minutes between messages");
3058     register_concmd("dmap_rtvtoggle", "dmaprtvtoggle", ADMIN_SUPER_DMAP, "Toggles on|off Ability of players to use rockthevote");
3059     register_concmd("dmap_rockthevote", "admin_rockit", ADMIN_DMAP, "(option: now) Allows admins to force a vote");
3060     register_concmd("amx_rockthevote", "admin_rockit", ADMIN_DMAP, "(option: now) Allows admins to force a vote");
3061     register_concmd("amx_rtv", "admin_rockit", ADMIN_DMAP, "(option: now) Allows admins to force a vote");
3062     register_concmd("dmap_rtvpercent", "dmaprtvpercent", ADMIN_SUPER_DMAP, "Set the percent (3-100) of players for a rtv");
3063     register_concmd("dmap_rtvplayers", "dmaprtvplayers", ADMIN_SUPER_DMAP, "Sets the minimum number of players needed to rockthevote");
3064     register_concmd("dmap_rtvwait", "dmaprtvwait", ADMIN_SUPER_DMAP, "Sets the minimum time before rockthevote can occur (5-30)");
3065     register_concmd("dmap_default", "dmapdefaults", ADMIN_SUPER_DMAP, "Will restore settings to default");
3066     register_concmd("dmap_mapsurl", "dmapmapsurl", ADMIN_SUPER_DMAP, "Specify what website to get custom maps from");
3067     register_concmd("dmap_mapsnum", "dmapmapsnum", ADMIN_SUPER_DMAP, "Set number of maps in vote (will not take effect until next map");
3068     register_concmd("dmap_nominations", "dmapmaxnominations", ADMIN_SUPER_DMAP, "Set maximum number of nominations for each person");
3069     register_concmd("dmap_maxcustom", "dmapmaxcustom", ADMIN_SUPER_DMAP, "Set maximum number of custom nominations that may be made");
3070     register_concmd("dmap_cancelvote", "dmapcancelvote", ADMIN_DMAP, "Cancels the rocked vote");
3071 cstrike 27 register_concmd("dmap_nominate", "dmapnominate", ADMIN_DMAP, "Force nomination of a map by an admin");
3072 cstrike 9
3073     register_logevent("event_RoundStart", 2, "0=World triggered", "1=Round_Start");
3074     register_logevent("event_RoundEnd", 2, "0=World triggered", "1=Round_End");
3075    
3076     register_event("30", "changeMap", "a");
3077     #if defined DEDICATED_LOG_ENABLED
3078     get_time("dmaplog%m%d.log", logfilename, 255);
3079     #endif
3080     dmap_strict = register_cvar("dmap_strict", "0");
3081     nominations_allowed = register_cvar("nominations_allowed", "1");
3082    
3083     register_cvar("enforce_timelimit", "0");
3084     register_cvar("amx_extendmap_max", "90");
3085     register_cvar("amx_extendmap_step", "15");
3086     register_cvar("amx_staytime", "300");
3087    
3088     emptymap = register_cvar("amx_emptymap", "de_dust2");
3089     idletime = register_cvar("amx_idletime", "5");
3090     emptymap_allowed = register_cvar("emptymap_allowed", "0");
3091     weapon_delay = register_cvar("weapon_delay", "1");
3092    
3093     staytime = get_cvar_num("amx_staytime");
3094    
3095     is_cstrike = (cstrike_running() == 1);
3096     nmaps_num = num_nmapsfill = 0;
3097    
3098     if (cstrike_running() == 1) {
3099     register_cvar("Deags_Map_Manage", VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY);
3100     register_event("TeamScore", "team_score", "a");
3101     } else {
3102     dofreeze = 0;
3103     register_cvar("Deags_Map_Manage", VERSION);
3104     }
3105     rtvpercent = 0.6;
3106     ban_last_maps = 4;
3107     minimumwait = 10;
3108     atstart = enabled = minimum = 1;
3109     quiet = cycle = isend = 0;
3110     mapsurl = "";
3111     set_task(3.0, "ban_some_maps"); //reads from lastmapsplayed.txt and stores into global array
3112     //set_task(8.0, "write_lastmaps"); //deletes and writes to lastmapsplayed.txt
3113     //set_task(2.0, "get_listing"); //loads mapcycle / allmaps.txt
3114     set_task(14.0, "load_defaultmaps"); //loads standardmaps.ini
3115     //set_task(17.0, "load_maps"); //loads mapchoice.ini
3116     set_task(15.0, "askfornextmap", 987456, "", 0, "b");
3117     set_task(5.0, "loopmessages", 987111, "", 0, "b");
3118     set_task(34.0, "gen_maphelphtml"); //Writes to help file, which is read every time that dmap_help is called by ANY player
3119     oldtimelimit = get_cvar_float("mp_timelimit");
3120     get_localinfo("amx_lastmap", last_map, 31);
3121     set_localinfo("amx_lastmap", "");
3122     set_task(1.0, "timer", 0, "curtime", 0, "b", 1);
3123     maps_to_select = mapssave = 5;
3124     new temparray[64];
3125 cstrike 27 formatex(temparray, 63, "%s/mapvault.dat", custompath);
3126 cstrike 9 if (!loadsettings(temparray)) {
3127     set_defaults(-1);
3128     }
3129     atstart = 0;
3130     register_menucmd(register_menuid("Choose the next map:"), (-1 ^ (-1 << (maps_to_select + 2))), "vote_count");
3131     }

Contact webmaster
ViewVC Help
Powered by ViewVC RSS 2.0 feed