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

Contact webmaster
ViewVC Help
Powered by ViewVC RSS 2.0 feed