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

Contact webmaster
ViewVC Help
Powered by ViewVC RSS 2.0 feed