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

Contact webmaster
ViewVC Help
Powered by ViewVC RSS 2.0 feed