/[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 16 - (show annotations) (download)
Thu Sep 18 04:23:17 2008 UTC (15 years, 6 months ago) by cstrike
File size: 99613 byte(s)
Added support for extra tags in the vote menu
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
1420 new tagpath[64], sMenuOption[64];
1421 format(tagpath, 64, "%s/dmaptags.ini", custompath);
1422
1423 if (iscustommap(nmaps[a]) && usestandard) {
1424 if (cstrike_running() == 1) {
1425 formatex(sMenuOption, 64, "%L", LANG_PLAYER, "DMAP_CS_MENU_CUSTOM", nmapstoch + 1, nmaps[a]);
1426 } else {
1427 formatex(sMenuOption, 64, "%L", LANG_PLAYER, "DMAP_MENU_CUSTOM", nmapstoch + 1, nmaps[a]);
1428 }
1429 } else { // Don't show (Custom)
1430 formatex(sMenuOption, 64, "%d. %s", nmapstoch + 1, nmaps[a]);
1431 }
1432
1433 if (file_exists(tagpath)) { // If the tag file is there, check for the extra tag
1434 new iLine, sFullLine[64], sTagMap[32], sTagText[32], txtLen;
1435
1436 while (read_file(tagpath, iLine, sFullLine, 64, txtLen)) {
1437 if (sFullLine[0] == ';') {
1438 iLine++;
1439 continue; // Ignore comments
1440 }
1441
1442 strbreak(sFullLine, sTagMap, 32, sTagText, 32); // Split the map name and tag apart
1443
1444 if (equali(nmaps[a], sTagMap)) {
1445 format(sMenuOption, 64, "%s [%s]", sMenuOption, sTagText);
1446 break; // Quit reading the file
1447 }
1448 iLine++;
1449 }
1450 }
1451
1452 strcat(sMenuOption, "^n", 64);
1453 pos += formatex(menu[pos], 511, sMenuOption);
1454
1455 mkeys |= (1 << nmapstoch);
1456 nvotes[nmapstoch] = 0;
1457 }
1458
1459 menu[pos++] = '^n';
1460 nvotes[maps_to_select] = 0;
1461 nvotes[maps_to_select + 1] = 0;
1462 new mapname[32];
1463 get_mapname(mapname, 31);
1464 if (!mp_winlimit && get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max")) {
1465 pos += format(menu[pos], 511, "%L", LANG_PLAYER, "DMAP_MENU_EXTEND", maps_to_select + 1, mapname, extendint);
1466 mkeys |= (1 << maps_to_select);
1467 }
1468
1469 format(menu[pos], 511, "%L", LANG_PLAYER, "DMAP_MENU_NONE", maps_to_select + 2);
1470 show_menu(0, mkeys, menu, 19);
1471 set_task(20.0, "check_votes"); //set_task(15.0, "check_votes")
1472 if (is_cstrike) {
1473 client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_TIME_TO_CHOOSE");
1474 }
1475 if (quiet == 0) {
1476 client_cmd(0, "spk Gman/Gman_Choose%d", random_num(1, 2));
1477 }
1478 #if defined DEDICATED_LOG_ENABLED
1479 log_to_file(logfilename, "Vote: Voting for the nextmap started");
1480 #endif
1481 return PLUGIN_HANDLED;
1482 }
1483
1484 public handle_andchange(id, map2[]) {
1485 new tester[128];
1486 if (is_map_valid(map2) == 1) {
1487 handle_nominate(id, map2);
1488 } else {
1489 format(tester, 31, "cs_%s", map2);
1490 if (is_map_valid(tester) == 1) {
1491 handle_nominate(id, tester);
1492 } else {
1493 format(tester, 31, "de_%s", map2);
1494 if (is_map_valid(tester) == 1) {
1495 handle_nominate(id, tester);
1496 } else {
1497 format(tester, 31, "as_%s", map2);
1498 if (is_map_valid(tester) == 1) {
1499 handle_nominate(id, tester);
1500 } else {
1501 format(tester, 31, "dod_%s", map2);
1502 if (is_map_valid(tester) == 1) {
1503 handle_nominate(id, tester);
1504 } else {
1505 format(tester, 31, "fy_%s", map2);
1506 if (is_map_valid(tester) == 1) {
1507 handle_nominate(id, tester);
1508 } else {
1509 handle_nominate(id, map2);
1510 }
1511 }
1512 }
1513 }
1514 }
1515 }
1516 }
1517
1518 public HandleSay(id) {
1519
1520 new chat[256];
1521 read_args(chat, 256);
1522 new saymap[256];
1523 saymap = chat;
1524 remove_quotes(saymap);
1525 new saymap2[28];
1526 read_args(saymap2,28);
1527 remove_quotes(saymap2);
1528 new chat2[32];
1529 format(chat2, 31, "cs_%s", saymap2);
1530 if (containi(chat, "<") != -1 || containi(chat, "?") != -1 || containi(chat, ">") != -1 || containi(chat, "*") != -1 || containi(chat, "&") != -1 || containi(chat, ".") != -1) {
1531 return PLUGIN_CONTINUE;
1532 }
1533 if (containi(chat, "nominations") != -1) {
1534 if (get_pcvar_num(nominations_allowed) == 0) {
1535 client_print(id, print_chat, "%L", id, "DMAP_NOMINATIONS_DISABLED");
1536 return PLUGIN_HANDLED;
1537 }
1538 if (mselected) {
1539 client_print(id, print_chat, "%L", id, "DMAP_VOTE_IN_PROGRESS");
1540 } else {
1541 if (nmaps_num == 0) {
1542 client_print(id, print_chat, "%L", id, "DMAP_NO_NOMINATIONS");
1543 } else {
1544 listnominations(id);
1545 }
1546 }
1547 } else {
1548 if (containi(chat, "nominate ") == 1) {
1549 new mycommand[32];
1550 read_args(mycommand, 32);
1551 remove_quotes(mycommand);
1552 handle_andchange(id, mycommand[9]);
1553 } else {
1554 if (containi(chat, "vote ") == 1) {
1555 new mycommand[32];
1556 read_args(mycommand, 32);
1557 remove_quotes(mycommand);
1558 handle_andchange(id, mycommand[5]);
1559 } else {
1560 if (is_map_valid(saymap) == 1) {
1561 handle_nominate(id, saymap);
1562 } else {
1563 format(chat2, 31, "cs_%s", saymap2);
1564 if (is_map_valid(chat2) == 1) {
1565 handle_nominate(id, chat2);
1566 } else {
1567 format(chat2, 31, "de_%s", saymap2);
1568 if (is_map_valid(chat2) == 1) {
1569 handle_nominate(id, chat2);
1570 } else {
1571 format(chat2, 31, "as_%s", saymap2);
1572 if (is_map_valid(chat2) == 1) {
1573 handle_nominate(id, chat2);
1574 } else {
1575 format(chat2, 31, "dod_%s", saymap2);
1576 if (is_map_valid(chat2) == 1) {
1577 handle_nominate(id, chat2);
1578 } else {
1579 format(chat2, 31, "fy_%s", saymap2);
1580 if (is_map_valid(chat2) == 1) {
1581 handle_nominate(id, chat2);
1582 }
1583 }
1584 }
1585 }
1586 }
1587 }
1588 }
1589 }
1590 }
1591 return PLUGIN_CONTINUE;
1592 }
1593
1594 public calculate_custom() {
1595 //New optional protection against "too many" custom maps being nominated.
1596 amt_custom = 0;
1597 new i;
1598 for (i = 0; i < nmaps_num; i++) {
1599 if (iscustommap(nmaps[i])) {
1600 amt_custom++;
1601 }
1602 }
1603 }
1604
1605 public handle_nominate(id, map[]) {
1606 if (get_pcvar_num(nominations_allowed) == 0) {
1607 client_print(id, print_chat, "%L", id, "DMAP_NOMINATIONS_DISABLED");
1608 return PLUGIN_HANDLED;
1609 }
1610 strtolower(map);
1611 new current_map[32], iscust = 0, iscust_t = 0, full;
1612 full = (amt_custom >= maxcustnom);
1613 new n = 0, i, done = 0, isreplacement = 0; //0: (not a replacement), 1: (replacing his own), 2: (replacing others)
1614 new tempnmaps = nmaps_num;
1615 get_mapname(current_map, 31);
1616 if (maxnom == 0) {
1617 client_print(id, print_chat, "%L", id, "DMAP_NOMINATIONS_DISABLED");
1618 return PLUGIN_HANDLED;
1619 }
1620 if (inprogress && mselected) {
1621 client_print(id, print_chat, "%L", id, "DMAP_VOTING_IN_PROGRESS");
1622 return PLUGIN_HANDLED;
1623 }
1624 if (mselected) {
1625 new smap[32];
1626 get_cvar_string("amx_nextmap", smap, 31);
1627 client_print(id, print_chat, "%L", id, "DMAP_VOTING_OVER", smap);
1628 return PLUGIN_HANDLED;
1629 }
1630 if (!is_map_valid(map) || is_map_valid(map[1])) {
1631 client_print(id, print_chat, "%L", id, "DMAP_MAP_NOTFOUND", map);
1632 return PLUGIN_HANDLED;
1633 }
1634 if (isbanned(map)) {
1635 client_print(id, print_chat, "%L", id, "DMAP_MAPVOTE_NOT_AVAILABLE");
1636 return PLUGIN_HANDLED;
1637 }
1638 if (islastmaps(map) && !equali(map, current_map)) {
1639 client_print(id, print_chat, "%L", id, "DMAP_CANT_NOMINATE_LASTMAP", ban_last_maps);
1640 return PLUGIN_HANDLED;
1641 }
1642 if (equali(map, current_map)) {
1643 client_print(id, print_chat, "%L", id, "DMAP_EXTEND_MAP", map);
1644 return PLUGIN_HANDLED;
1645 }
1646 //Insert Strict Style code here, for pcvar dmap_strict 1
1647 if (get_pcvar_num(dmap_strict)) {
1648 new isinthelist = 0;
1649 for (new a = 0; a < totalmaps; a++) {
1650 if (equali(map, listofmaps[a]))
1651 isinthelist = 1;
1652 }
1653 if (!isinthelist) {
1654 client_print(id, print_chat, "%L", id, "DMAP_ALLOWED_MAPS");
1655 return PLUGIN_HANDLED;
1656 }
1657 }
1658 iscust = iscustommap(map);
1659 if (nmaps_num >= maps_to_select || Nominated[id] >= maxnom) { //3 (1,2,3)
1660 if (Nominated[id] > maxnom) { //3
1661 client_print(id, print_chat, "%L", id, "DMAP_MAX_MAPS_REACHED"); //Possible to reach here!
1662 //only if the command dmap_nominations is used to lower amount of maps that can be nominated
1663 return PLUGIN_HANDLED;
1664 }
1665
1666 for (i = 0; i < nmaps_num; i++) {
1667 if (equali(map, nmaps[i])) {
1668
1669 new name[32];
1670 get_user_name(whonmaps_num[i], name, 32);
1671 if (quiet == 2) {
1672 client_print(id, print_chat, "%L", id, "DMAP_ALREADY_NOMINATED", map, name);
1673 } else {
1674 client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_ALREADY_NOMINATED", map, name);
1675 }
1676 return PLUGIN_HANDLED;
1677 }
1678 }
1679
1680 while (n < nmaps_num && !done && Nominated[id] > 1) { //If the person has nominated 2 or 3 maps, he can replace his own
1681 if (whonmaps_num[n] == id) { //If a map is found that he has nominated, replace his own nomination.
1682 iscust_t = iscustommap(nmaps[n]);
1683 if (!(full && iscust && !iscust_t)) {
1684 Nominated[id] = Nominated[id] - 1;
1685 nmaps_num = n;
1686 done = 1;
1687 isreplacement = 1;
1688 }
1689 }
1690 n++;
1691 }
1692
1693 if (!done) {
1694 n = 0;
1695 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
1696 if (Nominated[whonmaps_num[n]] > 2) { //Replace the "greedy person's" nomination
1697 iscust_t = iscustommap(nmaps[n]);
1698 if (!(full && iscust && !iscust_t)) {
1699 done = 1;
1700 Nominated[whonmaps_num[n]] = Nominated[whonmaps_num[n]] - 1;
1701 nmaps_num = n;
1702 isreplacement = 2;
1703 }
1704 }
1705 n++;
1706 }
1707 }
1708 if (!done) {
1709 n = 0;
1710
1711 while (n < nmaps_num && !done && Nominated[id] < 1) { //If the person has not nom any maps, he can replace those with more than one
1712 //he cannot replace those with only one nomination, that would NOT be fair
1713
1714 if (Nominated[whonmaps_num[n]] > 1) { //Replace the "greedy person's" nomination
1715 iscust_t = iscustommap(nmaps[n]);
1716 if (!(full && iscust && !iscust_t)) {
1717 done = 1;
1718 Nominated[whonmaps_num[n]] = Nominated[whonmaps_num[n]] - 1;
1719 nmaps_num = n;
1720 isreplacement = 2;
1721 }
1722 }
1723 n++;
1724 }
1725 }
1726
1727 if (!done) {
1728 n = 0;
1729
1730 while (n < nmaps_num && !done && Nominated[id] > 0) { //If the person has nominated a map, he can replace his own
1731 if (whonmaps_num[n] == id) { //If a map is found that he has nominated, replace his own nomination.
1732 iscust_t = iscustommap(nmaps[n]);
1733 if (!(full && iscust && !iscust_t)) { //Check to see if too many custom maps are nominated
1734 Nominated[id] = Nominated[id] - 1;
1735 nmaps_num = n;
1736 done = 1;
1737 isreplacement = 1;
1738 }
1739 }
1740 n++;
1741 }
1742 }
1743 if (!done) {
1744 client_print(id, print_chat, "%L", id, "DMAP_MAX_NOMINATIONS_REACHED", nmaps_num);
1745 return PLUGIN_HANDLED;
1746 }
1747 }
1748
1749 for (i = 0; i < nmaps_num; i++) {
1750 if (equali(map, nmaps[i])) {
1751 new name[32];
1752 get_user_name(whonmaps_num[i], name, 32);
1753
1754 client_print(id, print_chat, "%L", id, "DMAP_ALREADY_NOMINATED", map, name);
1755
1756 nmaps_num = tempnmaps;
1757
1758 return PLUGIN_HANDLED;
1759 }
1760 }
1761
1762 if (!isreplacement && iscust && full) {
1763 client_print(id, print_chat, "%L", id, "DMAP_MAX_CUSTOMMAPS_REACHED", maxcustnom);
1764 return PLUGIN_HANDLED;
1765 }
1766
1767 new name[32];
1768 get_user_name(id, name, 21);
1769 if (isreplacement == 1) { //They are replacing their old map
1770 if (quiet == 2) {
1771 client_print(id, print_chat, "%L", id, "DMAP_REPLACE_PREVIOUS_NOMINATION", nmaps[nmaps_num]);
1772 } else {
1773 client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_PLAYER_REPLACED_NOMINATION", name, nmaps[nmaps_num]);
1774 }
1775 } else {
1776 if (isreplacement == 2) {
1777 if (quiet == 2) {
1778 client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NOMINATION_REPLACED", nmaps[nmaps_num]);
1779 } else {
1780 new name21[32];
1781 get_user_name(whonmaps_num[nmaps_num], name21, 31);
1782 client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NOMINATION_REPLACED2", name21, nmaps[nmaps_num]);
1783 }
1784 }
1785 }
1786
1787 Nominated[id]++;
1788
1789 console_print(id, "%L", id, "DMAP_ADD_NOMINATION", map, nmaps_num + 1);
1790
1791 set_task(0.18, "calculate_custom");
1792 copy(nmaps[nmaps_num], 31, map);
1793 whonmaps_num[nmaps_num] = id;
1794
1795 if (isreplacement) {
1796 nmaps_num = tempnmaps;
1797 } else {
1798 nmaps_num = tempnmaps + 1;
1799 }
1800 client_print(0, print_chat, "%L", LANG_PLAYER, "DMAP_NOMINATED_MAP", name, map);
1801
1802 return PLUGIN_HANDLED;
1803 }
1804
1805 public team_score() {
1806
1807 new team[2];
1808 read_data(1, team, 1);
1809 teamscore[(team[0] == 'C') ? 0 : 1] = read_data(2);
1810
1811 return PLUGIN_CONTINUE;
1812 }
1813
1814 public plugin_end() {
1815 new current_map[32];
1816 get_mapname(current_map, 31);
1817 set_localinfo("amx_lastmap", current_map);
1818
1819 if (istimeset) {
1820 set_cvar_float("mp_timelimit", oldtimelimit);
1821 } else {
1822 if (istimeset2) {
1823 set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") - 2.0);
1824 }
1825 }
1826 if (isspeedset) {
1827 set_cvar_float("sv_maxspeed", thespeed);
1828 }
1829 if (iswinlimitset) {
1830 set_cvar_num("mp_winlimit", oldwinlimit);
1831 }
1832 return PLUGIN_CONTINUE;
1833 }
1834
1835 public get_listing() {
1836 new i = 0, iavailable = 0;
1837 new line = 0, p;
1838 new stextsize = 0, isinthislist = 0, found_a_match = 0, done = 0;
1839 new linestr[256];
1840 new maptext[32];
1841 new current_map[32];
1842 get_mapname(current_map, 31);
1843 //pathtomaps = "mapcycle.txt";
1844 get_cvar_string("mapcyclefile", pathtomaps, 63);
1845 new smap[32];
1846 get_cvar_string("amx_nextmap", smap, 31);
1847 if (file_exists(pathtomaps)) {
1848 while (read_file(pathtomaps, line, linestr, 255, stextsize) && !done) {
1849 format(maptext, 31, "%s", linestr);
1850 if (is_map_valid(maptext) && !is_map_valid(maptext[1]) && equali(maptext, current_map)) {
1851 done = found_a_match = 1;
1852 line++;
1853 if (read_file(pathtomaps, line, linestr, 255, stextsize)) {
1854 format(maptext, 31, "%s", linestr);
1855 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
1856 //////////////////////////////////////////
1857 if (equali(smap, "")) {
1858 register_cvar("amx_nextmap", "", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY);
1859 }
1860 set_cvar_string("amx_nextmap", maptext);
1861 } else {
1862 found_a_match = 0;
1863 }
1864 } else {
1865 found_a_match = 0;
1866 }
1867 } else {
1868 line++;
1869 }
1870 }
1871 /*
1872 if (!found_a_match) {
1873 line = 0;
1874 while (read_file(pathtomaps, line, linestr, 255, stextsize) && !found_a_match && line < 1024) {
1875 format(maptext, 31, "%s", linestr);
1876 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
1877 if (equali(smap, "")) {
1878 register_cvar("amx_nextmap", "", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY);
1879 }
1880 set_cvar_string("amx_nextmap", maptext);
1881 found_a_match = 1;
1882 } else {
1883 line++;
1884 }
1885 }
1886 }
1887 */
1888 /* CODE TO RANDOMIZE NEXTMAP VARIABLE!*/
1889 if (!found_a_match) {
1890 line = random_num(0, 50);
1891 new tries = 0;
1892
1893 while ((read_file(pathtomaps, line, linestr, 255, stextsize) || !found_a_match) && (tries < 1024 && !found_a_match)) {
1894 format(maptext, 31, "%s", linestr);
1895 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
1896 if (equali(smap, "")) {
1897 register_cvar("amx_nextmap", "", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY);
1898 }
1899 set_cvar_string("amx_nextmap", maptext);
1900 found_a_match = 1;
1901 } else {
1902 line = random_num(0, 50);
1903 tries++;
1904 }
1905 }
1906 }
1907 }
1908
1909 line = 0;
1910 format(pathtomaps, 64, "%s/allmaps.txt", custompath);
1911 if (!file_exists(pathtomaps)) {
1912 new mapsadded = 0;
1913 while ((line = read_dir("maps", line, linestr, 255, stextsize)) != 0) {
1914 stextsize -= 4;
1915
1916 if (stextsize > 0) {
1917 if (!equali(linestr[stextsize], ".bsp")) {
1918 continue; // skip non map files
1919 }
1920 linestr[stextsize] = 0; // remove .bsp
1921 }
1922
1923 if (is_map_valid(linestr)) {
1924 write_file(pathtomaps, linestr);
1925 mapsadded++;
1926 }
1927 }
1928 #if defined DEDICATED_LOG_ENABLED
1929 log_to_file(logfilename, "Found %d maps in your <mod>/MAPS folder, and added these to the addons/amxmodx/allmaps.txt file", mapsadded);
1930 #endif
1931 line = 0;
1932 }
1933
1934 if (get_pcvar_float(dmap_strict) == 1.0) {
1935 get_cvar_string("mapcyclefile", pathtomaps, 63);
1936 //pathtomaps = "mapcycle.txt";
1937 }
1938
1939 if (file_exists(pathtomaps)) {
1940 while (read_file(pathtomaps, line, linestr, 255, stextsize) && i < MAX_MAPS_AMOUNT) {
1941 format(maptext, 31, "%s", linestr);
1942 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
1943 isinthislist = 0;
1944 for (p = 0; p < i; p++) {
1945 if (equali(maptext, listofmaps[p])) {
1946 isinthislist = 1;
1947 }
1948 }
1949 if (!isinthislist) {
1950 listofmaps[i++] = maptext;
1951 }
1952 }
1953 line++;
1954 }
1955 }
1956
1957 line = 0;
1958 for (p = 0; p < i; p++) {
1959 if (!isbanned(listofmaps[p]) && !islastmaps(listofmaps[p])) {
1960 iavailable++;
1961 }
1962 }
1963 new dummy_str[64];
1964 get_cvar_string("mapcyclefile", dummy_str, 63);
1965 //if (iavailable < maps_to_select && !equali(pathtomaps, "mapcycle.txt"))
1966 if (iavailable < maps_to_select && !equali(pathtomaps, dummy_str)) {
1967 //pathtomaps = "mapcycle.txt";
1968 get_cvar_string("mapcyclefile", pathtomaps, 63);
1969 if (file_exists(pathtomaps)) {
1970 while (read_file(pathtomaps, line, linestr, 255, stextsize) && i < MAX_MAPS_AMOUNT) {
1971 format(maptext, 31, "%s", linestr);
1972 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
1973 isinthislist = 0;
1974 for (p = 0; p < i; p++)
1975 if (equali(maptext, listofmaps[p])) {
1976 isinthislist = 1;
1977 }
1978 if (!isinthislist) {
1979 listofmaps[i++] = maptext;
1980 }
1981 }
1982 line++;
1983 }
1984 }
1985 }
1986 totalmaps = i;
1987 iavailable = 0;
1988 for (p = 0; p < i; p++) {
1989 if (!isbanned(listofmaps[p]) && !islastmaps(listofmaps[p])) {
1990 iavailable++;
1991 }
1992 }
1993 #if defined DEDICATED_LOG_ENABLED
1994 log_to_file(logfilename, "Found %d Maps in your mapcycle.txt/allmaps.txt file, %d are available for filling slots", i, iavailable);
1995 #endif
1996 }
1997
1998 public ban_some_maps() {
1999 //BAN MAPS FROM CONFIG FILE
2000 new banpath[64];
2001 format(banpath, 64, "%s/mapstoban.ini", custompath);
2002 new i = 0;
2003 new line = 0;
2004 new stextsize = 0;
2005 new linestr[256];
2006 new maptext[32];
2007
2008 if (file_exists(banpath)) {
2009 while (read_file(banpath, line, linestr, 255, stextsize) && i < MAX_MAPS_AMOUNT) {
2010 format(maptext, 31, "%s", linestr);
2011 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
2012 banthesemaps[i++] = maptext;
2013 }
2014 line++;
2015 }
2016 }
2017 totalbanned = i;
2018 #if defined DEDICATED_LOG_ENABLED
2019 if (totalbanned > 0) {
2020 log_to_file(logfilename, "Banned %d Maps in your mapstoban.ini file", totalbanned);
2021 } else {
2022 log_to_file(logfilename, "Did not ban any maps from mapstoban.ini file");
2023 }
2024 #endif
2025 //BAN RECENT MAPS PLAYED
2026 new lastmapspath[64];
2027 format(lastmapspath, 64, "%s/lastmapsplayed.txt", custompath);
2028 //new linestring[32];
2029 line = stextsize = 0;
2030 new current_map[32];
2031 get_mapname(current_map, 31);
2032 lastmaps[0] = current_map;
2033 bannedsofar++;
2034 currentplayers = activeplayers = rocks = 0;
2035 if (file_exists(lastmapspath)) {
2036 while(read_file(lastmapspath, line, linestr, 255, stextsize) && bannedsofar <= ban_last_maps) {
2037 if ((strlen(linestr) > 0) && (is_map_valid(linestr))) {
2038 format(lastmaps[bannedsofar++], 31, "%s", linestr);
2039 //copy(lastmaps[bannedsofar++], 31, "%s", linestr);
2040 }
2041 line++;
2042 }
2043 }
2044 write_lastmaps(); //deletes and writes to lastmapsplayed.txt
2045 }
2046
2047 public write_lastmaps() {
2048 new lastmapspath[64];
2049 format(lastmapspath, 64, "%s/lastmapsplayed.txt", custompath);
2050 if (file_exists(lastmapspath)) {
2051 delete_file(lastmapspath);
2052 }
2053 new text[256], p;
2054 for (p = 0; p < bannedsofar; p++) {
2055 format(text, 255, "%s", lastmaps[p]);
2056 write_file(lastmapspath, text);
2057 }
2058 write_file(lastmapspath, "Generated by map_nominate plugin,");
2059 write_file(lastmapspath, "these are most recent maps played");
2060
2061 load_maps();
2062 }
2063
2064 public load_maps() {
2065 new choicepath[64];
2066 format(choicepath, 64, "%s/mapchoice.ini", custompath);
2067 new line = 0;
2068 new stextsize = 0, isinlist, unable = 0, i;
2069 new linestr[256];
2070 new maptext[32];
2071 new current_map[32];
2072 get_mapname(current_map, 31);
2073 if (file_exists(choicepath)) {
2074 while (read_file(choicepath, line, linestr, 255, stextsize) && (num_nmapsfill < MAX_MAPS_AMOUNT)) {
2075 format(maptext, 31, "%s", linestr);
2076 if (is_map_valid(maptext) && !is_map_valid(maptext[1])) {
2077 isinlist = 0;
2078 if (isbanned(maptext) || islastmaps(maptext)) {
2079 isinlist = 1;
2080 } else {
2081 if (equali(maptext, current_map) || equali(maptext, last_map)) {
2082 isinlist = 1;
2083 } else {
2084 for (i = 0; i < num_nmapsfill; i++) {
2085 if (equali(maptext, nmapsfill[i])) {
2086 #if defined DEDICATED_LOG_ENABLED
2087 log_to_file(logfilename, "Map ^"%s^" is already in list! It is defined it twice", maptext);
2088 #endif
2089 isinlist = 1;
2090 }
2091 }
2092 }
2093 }
2094 if (!isinlist) {
2095 copy(nmapsfill[num_nmapsfill++], 31, maptext);
2096 } else {
2097 unable++;
2098 }
2099 }
2100 line++;
2101 }
2102 #if defined DEDICATED_LOG_ENABLED
2103 log_to_file(logfilename, "Loaded %d Maps into the maps that will be picked for the vote", num_nmapsfill);
2104 log_to_file(logfilename, "%d Maps were not loaded because they were the last maps played, or defined twice, or banned", unable);
2105 } else {
2106 log_to_file(logfilename, "Unable to open file %s, In order to get maps: your mapcycle.txt file will be searched", choicepath);
2107 #endif
2108 }
2109 get_listing();
2110 }
2111
2112 public load_defaultmaps() {
2113 new standardpath[64];
2114 format(standardpath, 64, "%s/standardmaps.ini", custompath);
2115 new i = 0;
2116 new line = 0;
2117 new stextsize = 0;
2118 new linestr[256];
2119 new maptext[32];
2120 usestandard = 1;
2121 if (!file_exists(standardpath)) {
2122 usestandard = standardtotal = 0;
2123 } else {
2124 while(read_file(standardpath, line, linestr, 255, stextsize) && i < 40) {
2125 format(maptext, 31, "%s", linestr);
2126 if (is_map_valid(maptext)) {
2127 standard[i++] = maptext;
2128 }
2129 line++;
2130 }
2131 standardtotal = i;
2132 }
2133 if (standardtotal < 5) {
2134 usestandard = 0;
2135 #if defined DEDICATED_LOG_ENABLED
2136 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);
2137 #endif
2138 }
2139 }
2140
2141 bool:iscustommap(map[]) {
2142 new a;
2143 for (a = 0; a < standardtotal; a++) {
2144 if (equali(map, standard[a])) {
2145 return false;
2146 }
2147 }
2148 if (usestandard) {
2149 return true;
2150 }
2151 return false;
2152 }
2153
2154 bool:islastmaps(map[]) {
2155 new a;
2156 for (a = 0; a < bannedsofar; a++) {
2157 if (equali(map, lastmaps[a])) {
2158 return true;
2159 }
2160 }
2161 return false;
2162 }
2163
2164 bool:isnominated(map[]) {
2165 new a;
2166 for (a = 0; a < nmaps_num; a++) {
2167 if (equali(map, nmaps[a])) {
2168 return true;
2169 }
2170 }
2171 return false;
2172 }
2173
2174 bool:isbanned(map[]) {
2175 new a;
2176 for (a = 0; a < totalbanned; a++) {
2177 if (equali(map, banthesemaps[a])) {
2178 return true;
2179 }
2180 }
2181 return false;
2182 }
2183
2184 loadsettings(filename[]) {
2185 if (!file_exists(filename)) {
2186 return 0;
2187 }
2188
2189 new text[256], percent[5], strban[4], strplay[3], strwait[3], strwait2[3], strurl[64], strnum[3], strnum2[3];
2190 new len, pos = 0;
2191 new Float:numpercent;
2192 new banamount, nplayers, waittime, mapsnum;
2193 while (read_file(filename, pos++, text, 255, len)) {
2194 if (text[0] == ';') {
2195 continue;
2196 }
2197 switch(text[0]) {
2198 case 'r': {
2199 format(percent, 4, "%s", text[2]);
2200 numpercent = float(str_to_num(percent)) / 100.0;
2201 if (numpercent >= 0.03 && numpercent <= 1.0) {
2202 rtvpercent = numpercent;
2203 }
2204 }
2205 case 'q': {
2206 if (text[1] == '2') {
2207 quiet = 2;
2208 } else {
2209 quiet = 1;
2210 }
2211 }
2212 case 'c': {
2213 cycle = 1;
2214 }
2215 case 'd': {
2216 enabled = 0;
2217 }
2218 case 'f': {
2219 if (text[1] == 'r') {
2220 format(strwait2, 2, "%s", text[2]);
2221 waittime = str_to_num(strwait2);
2222 if (waittime >= 2 && waittime <= 20) {
2223 frequency = waittime;
2224 }
2225 } else {
2226 dofreeze = 0;
2227 }
2228 }
2229 case 'b': {
2230 format(strban, 3, "%s", text[2]);
2231 banamount = str_to_num(strban);
2232 if (banamount >= 0 && banamount <= 100) {
2233 if ((banamount == 0 && text[2] == '0') || banamount > 0) {
2234 ban_last_maps = banamount;
2235 }
2236 }
2237 }
2238 case 'm': {
2239 if (atstart) {
2240 format(strnum, 2, "%s", text[2]);
2241 mapsnum = str_to_num(strnum);
2242 if (mapsnum >= 2 && mapsnum <= 8) {
2243 maps_to_select = mapssave = mapsnum;
2244 }
2245 }
2246 }
2247 case 'p': {
2248 format(strplay, 2, "%s", text[2]);
2249 nplayers = str_to_num(strplay);
2250 if (nplayers > 0 && nplayers <= 32) {
2251 minimum = nplayers;
2252 }
2253 }
2254 case 'u': {
2255 format(strurl, 63, "%s", text[2]);
2256 if ((containi(strurl, "www") != -1 || containi(strurl, "http") != -1) && !equali(strurl, "http")) {
2257 mapsurl = strurl;
2258 }
2259 }
2260 case 'w': {
2261 format(strwait, 2, "%s", text[2]);
2262 waittime = str_to_num(strwait);
2263 if (waittime >= 5 && waittime <= 30) {
2264 minimumwait = waittime;
2265 }
2266 }
2267 case 'x': {
2268 format(strnum2, 2, "%s", text[2]);
2269 mapsnum = str_to_num(strnum2);
2270 if (mapsnum >= 1 && mapsnum <= 3) {
2271 maxnom = mapsnum;
2272 }
2273 }
2274 case 'y': {
2275 format(strnum2, 2, "%s", text[2]);
2276 mapsnum = str_to_num(strnum2);
2277 if (mapsnum >= 0 && mapsnum <= mapssave) {
2278 maxcustnom = mapsnum;
2279 }
2280 }
2281 }
2282 }
2283 return 1;
2284 }
2285
2286 set_defaults(myid) {
2287
2288 rtvpercent = 0.6;
2289 ban_last_maps = 4;
2290 maxnom = frequency = 3;
2291 quiet = cycle = 0;
2292 minimum = enabled = 1;
2293 minimumwait = 10;
2294 mapssave = maxcustnom = 5;
2295 mapsurl = "";
2296 dofreeze = cstrike_running() == 1;
2297
2298 if (myid < 0) {
2299 savesettings(-1);
2300 } else {
2301 savesettings(myid);
2302 showsettings(myid);
2303 console_print(myid, "================== DEFAULTS SET =========================");
2304 }
2305 }
2306
2307 public dmaprtvpercent(id, level, cid) {
2308 if (!cmd_access(id, level, cid, 2)) {
2309 return PLUGIN_HANDLED;
2310 }
2311
2312 new arg[32];
2313 read_argv(1, arg, 3);
2314 new Float:percentage = float(str_to_num(arg)) / 100.0;
2315 if (percentage >= 0.03 && percentage <= 1.0) {
2316 rtvpercent = percentage;
2317 savesettings(id);
2318 showsettings(id);
2319 } else {
2320 console_print(id, "You must specify a value between 3 and 100 for dmap_rtvpercent");
2321 console_print(id, "This sets minimum percent of players that must say rockthevote to rockit");
2322 }
2323 return PLUGIN_HANDLED;
2324 }
2325
2326 public dmaprtvplayers(id, level, cid) {
2327 if (!cmd_access(id, level, cid, 2)) {
2328 return PLUGIN_HANDLED;
2329 }
2330
2331 new arg[32];
2332 read_argv(1, arg, 3);
2333 new players = str_to_num(arg);
2334 if (players >= 1 && players <= 32) {
2335 minimum = players;
2336 savesettings(id);
2337 showsettings(id);
2338 } else {
2339 console_print(id, "You must specify a value between 1 and 32 for dmap_rtvplayers");
2340 console_print(id, "This sets minimum num of players that must say rockthevote to rockit");
2341 }
2342 return PLUGIN_HANDLED;
2343 }
2344
2345 public dmaprtvwait(id, level, cid) {
2346 if (!cmd_access(id, level, cid, 2)) {
2347 return PLUGIN_HANDLED;
2348 }
2349
2350 new arg[32];
2351 read_argv(1, arg, 3);
2352 new wait = str_to_num(arg);
2353 if (wait >= 5 && wait <= 30) {
2354 minimumwait = wait;
2355 savesettings(id);
2356 showsettings(id);
2357 } else {
2358 console_print(id, "You must specify a value between 5 and 30 for dmap_rtvwait");
2359 console_print(id, "This sets how long must pass from the start of map before players may rockthevote");
2360 }
2361 return PLUGIN_HANDLED;
2362 }
2363
2364 public dmapmessages(id, level, cid) {
2365 if (!cmd_access(id, level, cid, 2)) {
2366 return PLUGIN_HANDLED;
2367 }
2368
2369 new arg[32];
2370 read_argv(1, arg, 3);
2371 new wait = str_to_num(arg);
2372 if (wait >= 2 && wait <= 20) {
2373 frequency = wait;
2374 savesettings(id);
2375 showsettings(id);
2376 } else {
2377 console_print(id, "You must specify a value between 2 and 20 minutes for dmap_messages");
2378 console_print(id, "This sets how many minutes will pass between messages for nominations for available maps");
2379 }
2380 return PLUGIN_HANDLED;
2381 }
2382
2383 public dmapmapsnum(id, level, cid) {
2384 if (!cmd_access(id, level, cid, 2)) {
2385 return PLUGIN_HANDLED;
2386 }
2387
2388 new arg[32];
2389 read_argv(1, arg, 3);
2390 new maps = str_to_num(arg);
2391 if (maps >= 2 && maps <= 8) {
2392 mapssave = maps;
2393 savesettings(id);
2394 showsettings(id);
2395 console_print(id, "***** Settings for dmap_mapsnum do NOT take effect until the next map!!! ******");
2396 } else {
2397 console_print(id, "You must specify a value between 2 and 8 for dmap_mapsnum");
2398 console_print(id, "This sets the # of maps in the vote, changing this doesn't take effect until the next map");
2399 }
2400 return PLUGIN_HANDLED;
2401 }
2402
2403 public dmapmaxnominations(id, level, cid) {
2404 if (!cmd_access(id, level, cid, 2)) {
2405 return PLUGIN_HANDLED;
2406 }
2407
2408 new arg[32];
2409 read_argv(1, arg, 3);
2410 new thisnumber = str_to_num(arg);
2411 if (thisnumber >= 0 && thisnumber <= 3) {
2412 maxnom = thisnumber;
2413 savesettings(id);
2414 showsettings(id);
2415 console_print(id, "***** Settings for dmap_nominations do NOT take effect until the next map!!! ******");
2416 } else {
2417 console_print(id, "You must specify a value between 0 and 3 for dmap_nominations");
2418 console_print(id, "This sets the maximum number of maps a person can nominate");
2419 }
2420 return PLUGIN_HANDLED;
2421 }
2422
2423 public dmapmaxcustom(id, level, cid) {
2424 if (!cmd_access(id, level, cid, 2)) {
2425 return PLUGIN_HANDLED;
2426 }
2427
2428 new arg[32];
2429 read_argv(1, arg, 3);
2430 new thisnumber = str_to_num(arg);
2431 if (thisnumber >= 0 && thisnumber <= mapssave) {
2432 maxcustnom = thisnumber;
2433 savesettings(id);
2434 showsettings(id);
2435 } else {
2436 console_print(id, "You must specify a value between {0} and maximum maps in the vote, which is {%d}, for dmap_maxcustom", mapssave);
2437 console_print(id, "This sets the maximum number of custom maps that may be nominated by the players");
2438 }
2439 return PLUGIN_HANDLED;
2440 }
2441
2442 public dmapquiet(id, level, cid) {
2443 if (!cmd_access(id, level, cid, 2)) {
2444 return PLUGIN_HANDLED;
2445 }
2446
2447 new arg[32];
2448 read_argv(1, arg, 31);
2449 if (containi(arg, "off") != -1) {
2450 console_print(id, "======Quiet mode is now OFF, messages pertaining to maps will be shown=====");
2451 quiet = 0;
2452 } else if (containi(arg, "silent") != -1) {
2453 console_print(id, "======Quiet mode is now set to SILENT, A minimal amount of messages will be shown!=====");
2454 quiet = 2;
2455 } else if (containi(arg, "nosound") != -1) {
2456 console_print(id, "======Quiet mode is now set to NOSOUND, messages pertaining to maps will be shown, with no sound=====");
2457 quiet = 1;
2458 } else {
2459 console_print(id, "USAGE: dmap_quietmode <OFF|NOSOUND|SILENT>");
2460 return PLUGIN_HANDLED;
2461 }
2462 savesettings(id);
2463 showsettings(id);
2464 return PLUGIN_HANDLED;
2465 }
2466
2467 public dmaprtvtoggle(id, level, cid) {
2468 if (!cmd_access(id, level, cid, 1)) {
2469 return PLUGIN_HANDLED;
2470 }
2471
2472 if (enabled == 0) {
2473 console_print(id, "=========Rockthevote is now enabled==============");
2474 } else {
2475 console_print(id, "=========Rockthevote is not disabled=================");
2476 }
2477 enabled = !enabled;
2478 savesettings(id);
2479 showsettings(id);
2480 return PLUGIN_HANDLED;
2481 }
2482
2483 public changefreeze(id, level, cid) {
2484 if (!cmd_access(id, level, cid, 1)) {
2485 return PLUGIN_HANDLED;
2486 }
2487
2488 if (!cstrike_running()) {
2489 console_print(id, "Freeze is always off on non-Counter Strike Servers");
2490 return PLUGIN_HANDLED;
2491 }
2492
2493 new arg[32];
2494 read_argv(1, arg, 31);
2495 if (containi(arg, "off") != -1) {
2496 console_print(id, "=========FREEZE/Weapon Drop at end of round is now disabled==============");
2497 dofreeze = 0;
2498 } else {
2499 if (containi(arg, "on") != -1) {
2500 console_print(id, "=========FREEZE/Weapon Drop at end of round is now enabled==============");
2501 dofreeze = 1;
2502 } else {
2503 console_print(id, "========= USAGE of dmap_freeze: dmap_freeze on|off (this will turn freeze/weapons drop at end of round on/off");
2504 return PLUGIN_HANDLED;
2505 }
2506 }
2507 savesettings(id);
2508 showsettings(id);
2509 return PLUGIN_HANDLED;
2510 }
2511
2512 public dmapcyclemode(id, level, cid) {
2513 if (!cmd_access(id, level, cid, 1)) {
2514 return PLUGIN_HANDLED;
2515 }
2516
2517 if (!cycle) {
2518 console_print(id, "========= Cylce mode is now ON, NO VOTE will take place! =========");
2519 } else {
2520 console_print(id, "========= Cycle Mode is already on, no change is made =========");
2521 console_print(id, "========= If you are trying to enable voting, use command dmap_votemode");
2522 return PLUGIN_HANDLED;
2523 }
2524 cycle = 1;
2525 savesettings(id);
2526 showsettings(id);
2527 if (inprogress) {
2528 console_print(id, "========= The Vote In Progress cannot be terminated, unless it hasn't started! =========");
2529 }
2530 return PLUGIN_HANDLED;
2531 }
2532
2533 public dmapvotemode(id, level, cid) {
2534 if (!cmd_access(id, level, cid, 1)) {
2535 return PLUGIN_HANDLED;
2536 }
2537
2538 if (cycle) {
2539 console_print(id, "========= Voting mode is now ON, Votes WILL take place =========");
2540 } else {
2541 console_print(id, "========= Voting mode is already ON, no change is made =========");
2542 console_print(id, "========= If you are trying to disable voting, use command dmap_cyclemode");
2543 return PLUGIN_HANDLED;
2544 }
2545 cycle = 0;
2546 savesettings(id);
2547 showsettings(id);
2548 return PLUGIN_HANDLED;
2549 }
2550
2551 public dmapbanlastmaps(id, level, cid) {
2552 if (!cmd_access(id, level, cid, 2)) {
2553 return PLUGIN_HANDLED;
2554 }
2555
2556 new arg[32];
2557 read_argv(1, arg, 4);
2558 new banamount;
2559 banamount = str_to_num(arg);
2560 if (banamount >= 0 && banamount <= 99) {
2561 if (banamount > ban_last_maps) {
2562 console_print(id, "You have choosen to increase the number of banned maps");
2563 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);
2564 } else {
2565 if (banamount < ban_last_maps) {
2566 console_print(id, "You have choosen to decrease the number of banned maps");
2567 }
2568 }
2569 ban_last_maps = banamount;
2570 savesettings(id);
2571 showsettings(id);
2572 } else {
2573 console_print(id, "You must specify a value between 0 and 99 for dmap_banlastmaps");
2574 console_print(id, "dmap_banlastmaps <n> will ban the last <n> maps from being voted/nominated");
2575 }
2576 return PLUGIN_HANDLED;
2577 }
2578
2579 public dmaphelp(id) {
2580 if (!(get_user_flags(id) & ADMIN_MAP)) {
2581 new myversion[32];
2582 get_cvar_string("Deags_Map_Manage", myversion, 31);
2583 console_print(id, "*****This server uses the plugin Deagles NextMap Management %s *****", myversion);
2584 console_print(id, "");
2585 if (cycle) {
2586 console_print(id, "=================== The plugin is set to cycle mode. No vote will take place =================");
2587 return PLUGIN_HANDLED;
2588 }
2589 console_print(id, "Say ^"vote mapname^" ^"nominate mapname^" or just simply ^"mapname^" to nominate a map");
2590 console_print(id, "");
2591 console_print(id, "Say ^"nominations^" to see a list of maps already nominated.");
2592 console_print(id, "Say ^"listmaps^" for a list of maps you can nominate");
2593 console_print(id, "Number of maps for the vote at the end of this map will be: %d", maps_to_select);
2594 console_print(id, "Players may nominate up to %d maps for the vote (dmap_nominations)", maxnom);
2595 console_print(id, "Players may nominate up to %d **Custom** maps for the vote (dmap_maxcustom)", maxcustnom);
2596 if (enabled) {
2597 console_print(id, "Say ^"rockthevote^" to rockthevote");
2598 console_print(id, "In order to rockthevote the following 3 conditions need to be true:");
2599 console_print(id, "%d percent of players must rockthevote, and at least %d players must rockthevote", floatround(rtvpercent * 100.0), minimum);
2600 console_print(id, "Vote may not be rocked before %d minutes have elapsed on the map", minimumwait);
2601 }
2602 if (containi(mapsurl, "www") != -1 || containi(mapsurl, "http") != -1) {
2603 console_print(id, "You can download Custom maps at %s (dmap_mapsurl)", mapsurl);
2604 }
2605 return PLUGIN_HANDLED;
2606 }
2607 //For CS 1.6, the following MOTD will display nicely, for 1.5, It will show html tags.
2608 client_print(id, print_chat, "%L", id, "DMAP_MOTD_LOADING");
2609 showmotdhelp(id);
2610
2611 return PLUGIN_HANDLED;
2612 }
2613
2614 public gen_maphelphtml() {
2615 new path[64], text[128];
2616 format(path, 63, "%s/map_manage_help.htm", custompath);
2617 if (file_exists(path)) {
2618 delete_file(path);
2619 }
2620 format(text, 127, "%L", LANG_SERVER, "DMAP_HELP");
2621 write_file(path, text);
2622 format(text, 127, "%L", LANG_SERVER, "DMAP_HELP2");
2623 write_file(path, text);
2624 format(text, 127, "%L", LANG_SERVER, "DMAP_HELP3");
2625 write_file(path, text);
2626 format(text, 127, "%L", LANG_SERVER, "DMAP_HELP4");
2627 write_file(path, text);
2628 format(text, 127, "%L", LANG_SERVER, "DMAP_HELP5");
2629 write_file(path, text);
2630 format(text, 127, "%L", LANG_SERVER, "DMAP_HELP6");
2631 write_file(path, text);
2632 format(text, 127, "%L", LANG_SERVER, "DMAP_HELP7");
2633 write_file(path, text);
2634 format(text, 127, "%L", LANG_SERVER, "DMAP_HELP8");
2635 write_file(path, text);
2636 }
2637
2638 public showmotdhelp(id) {
2639 new header[80];
2640 new myversion[32];
2641 new helpfile[60];
2642 format(helpfile, 60, "%s/map_manage_help.htm", custompath);
2643 get_cvar_string("Deags_Map_Manage", myversion, 31);
2644 format(header, 79, "%L", LANG_PLAYER, "DMAP_HELP9", myversion);
2645 if (!file_exists(helpfile)) {
2646 gen_maphelphtml();
2647 }
2648 show_motd(id, helpfile, header);
2649 }
2650
2651 public dmapstatus(id, level, cid) {
2652 if (!cmd_access(id, level, cid, 1)) {
2653 return PLUGIN_HANDLED;
2654 }
2655
2656 showsettings(id);
2657 return PLUGIN_CONTINUE;
2658 }
2659
2660 showsettings(id) {
2661
2662 console_print(id, "-----------------------------------------------------------------------------------------------");
2663 console_print(id, " Status of Deagles Map Management Version %s", VERSION);
2664
2665 if (cycle) {
2666 console_print(id, "=================== Mode is Cycle Mode NO vote will take place =================");
2667 console_print(id, "=================== To enable voting use command dmap_votemode ===================");
2668 } else {
2669 console_print(id, "======================= Current Mode is Voting Mode ===============================");
2670 if (quiet == 2) {
2671 console_print(id, "Quiet Mode is set to SILENT. Minimal text messages will be shown, no sound will be played (dmap_quietmode)");
2672 } else {
2673 if (quiet == 1) {
2674 console_print(id, "Quiet Mode is set to NOSOUND. Text messages will be shown, with no sound. (dmap_quietmode)");
2675 } else {
2676 console_print(id, "Quiet Mode is OFF, messages will be shown with sound (dmap_quietmode)");
2677 }
2678 console_print(id, "The time between messages about maps is %d minutes (dmap_messages)", frequency);
2679 }
2680
2681 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);
2682
2683 if (maps_to_select != mapssave) {
2684 console_print(id, "Number of maps for the vote on this map is: %d (Next Map it will be: %d)", maps_to_select, mapssave);
2685 } else {
2686 console_print(id, "Number of maps for the vote at the end of this map will be: %d (dmap_mapsnum)", maps_to_select);
2687 }
2688
2689 console_print(id, "Players may nominate up to %d maps each for the vote (dmap_nominations)", maxnom);
2690
2691 console_print(id, "Players may nominate up to %d **Custom** maps each for the vote (dmap_maxcustom)", maxcustnom);
2692
2693 if (get_cvar_num("enforce_timelimit")) {
2694 console_print(id, "^"Timeleft^" will be followed to change the maps, not allowing players to finish the round");
2695 console_print(id, "To change this, ask your server admin to set the cvar ^"enforce_timelimit^" to 0");
2696 }
2697
2698 if (enabled == 0) {
2699 if (!get_cvar_num("mp_timelimit")) {
2700 console_print(id, "rockthevote is disabled since mp_timelimit is set to 0");
2701 } else {
2702 console_print(id, "rockthevote is disabled; (dmap_rtvtoggle)");
2703 }
2704 }
2705 console_print(id, "In order to rockthevote the following 3 conditions need to be met:");
2706 console_print(id, "%d percent of players must rockthevote, and at least %d players must rockthevote", floatround(rtvpercent * 100.0), minimum);
2707 console_print(id, "Vote may not be rocked before %d minutes have elapsed on the map (10 is recommended)", minimumwait);
2708 }
2709
2710 console_print(id, "The Freeze/Weapons Drop at the end of the round is %s (dmap_freeze)", dofreeze ? "ENABLED" : "DISABLED");
2711
2712 if (!usestandard) {
2713 console_print(id, "Custom will not be shown by any maps, since file standardmaps.ini is not on the server");
2714 } else {
2715 console_print(id, "The words custom will be shown by Custom maps");
2716 }
2717 if (containi(mapsurl, "www") != -1 || containi(mapsurl, "http") != -1) {
2718 console_print(id, "URL to download Custom maps is %s (dmap_mapsurl)", mapsurl);
2719 } else {
2720 console_print(id, "URL to download maps from will not be shown (dmap_mapsurl)");
2721 }
2722 console_print(id, "------------------------------------------------------------------------------------------------");
2723 console_print(id, "Commands : dmap_status; dmap_cyclemode; dmap_votemode; dmap_quietmode <OFF|NOSOUND|SILENT>; ");
2724 console_print(id, "Commands : dmap_banlastmaps <n>; dmap_default ; dmap_mapsurl <url>; dmap_mapsnum <n>; dmap_maxcustom <n>;");
2725 console_print(id, "Commands : dmap_rtvtoggle; dmap_rtvpercent <n>; dmap_rtvplayers <n>; dmap_rtvwait <n>");
2726 console_print(id, "Commands : dmap_rockthevote; dmap_freeze; dmap_nominations <n>; dmap_messages <n(minutes)>");
2727 console_print(id, "Cvars: dmap_strict <0|1>, enforce_timelimit <0|1>; amx_extendmap_max <n>; amx_extendmap_step <n>");
2728 console_print(id, "------------------------- use command dmap_help for more information -----------------------");
2729 }
2730
2731 change_custom_path() {
2732 new temp[64];
2733 format(temp, 63, "%s/dmap", custompath);
2734 if (dir_exists(temp)) {
2735 copy(custompath, 48, temp);
2736 }
2737 }
2738
2739 savesettings(myid) {
2740
2741 new settings[64];
2742 format(settings, 64, "%s/mapvault.dat", custompath);
2743
2744 if (file_exists(settings)) {
2745 delete_file(settings);
2746 }
2747 new text[32], text2[128], percent, success = 1, usedany = 0;
2748 format(text2, 127, ";To use comments simply use ;");
2749 if (!write_file(settings,text2)) {
2750 success = 0;
2751 }
2752 format(text2, 127, ";Do not modify this variables, this is used by the Nomination_style_voting plugin to save settings");
2753
2754 if (!write_file(settings, text2)) {
2755 success = 0;
2756 }
2757 format(text2, 127, ";If you delete this file, defaults will be restored.");
2758 if (!write_file(settings, text2)) {
2759 success = 0;
2760 }
2761 format(text2, 127, ";If you make an invalid setting, that specific setting will restore to the default");
2762 if (!write_file(settings, text2)) {
2763 success = 0;
2764 }
2765 if (!enabled) {
2766 format(text, 31, "d"); //d for disabled
2767 usedany = 1;
2768 if (!write_file(settings, text)) {
2769 success = 0;
2770 }
2771 }
2772 if (quiet != 0) {
2773 if (quiet == 1) {
2774 format(text, 31, "q1"); //d for disabled
2775 } else {
2776 format(text, 31, "q2"); //d for disabled
2777 }
2778 usedany = 1;
2779 if (!write_file(settings, text)) {
2780 success = 0;
2781 }
2782 }
2783 if (!dofreeze || !(cstrike_running() == 1)) {
2784 format(text, 31, "f");
2785 if (!write_file(settings, text)) {
2786 success = 0;
2787 }
2788 }
2789 if (cycle) {
2790 format(text, 31, "c"); //c for Cycle mode=on
2791 usedany = 1;
2792 if (!write_file(settings, text)) {
2793 success = 0;
2794 }
2795 }
2796 percent = floatround(rtvpercent * 100.0);
2797 if (percent >= 3 && percent <= 100) {
2798 format(text, 31, "r %d", percent);
2799 usedany = 1;
2800 if (!write_file(settings, text)) {
2801 success = 0;
2802 }
2803 }
2804 if (ban_last_maps >= 0 && ban_last_maps <= 100) {
2805 format(text, 31, "b %d", ban_last_maps);
2806 usedany = 1;
2807 if (!write_file(settings, text)) {
2808 success = 0;
2809 }
2810 }
2811 if (mapssave >= 2 && mapssave <= 8) {
2812 format(text, 31, "m %d", mapssave);
2813 usedany = 1;
2814 if (!write_file(settings, text)) {
2815 success = 0;
2816 }
2817 }
2818 if (maxnom >= 0 && maxnom <= 3) {
2819 format(text, 31, "x %d", maxnom);
2820 usedany = 1;
2821 if (!write_file(settings, text)) {
2822 success = 0;
2823 }
2824 }
2825 if (maxcustnom >= 0 && maxcustnom <= mapssave) {
2826 format(text, 31, "y %d", maxcustnom);
2827 usedany = 1;
2828 if (!write_file(settings, text)) {
2829 success = 0;
2830 }
2831 }
2832 if (minimum > 0 && minimum <= 32) {
2833 format(text, 31, "p %d", minimum);
2834 usedany = 1;
2835 if (!write_file(settings, text)) {
2836 success = 0;
2837 }
2838 }
2839 if (minimumwait >= 5 && minimumwait <= 30) {
2840 format(text, 31, "w %d", minimumwait);
2841 usedany = 1;
2842 if (!write_file(settings, text)) {
2843 success = 0;
2844 }
2845 }
2846 if (frequency >= 2 && frequency <= 20) {
2847 format(text, 31, "fr %d", frequency);
2848 usedany = 1;
2849 if (!write_file(settings, text)) {
2850 success = 0;
2851 }
2852 }
2853 if (containi(mapsurl, "www") != -1 || containi(mapsurl, "http") != -1) {
2854 format(text2, 75, "u %s", mapsurl);
2855 usedany = 1;
2856 if (!write_file(settings, text2)) {
2857 success = 0;
2858 }
2859 }
2860 if (usedany) {
2861 if (myid >= 0) {
2862 if (success) {
2863 console_print(myid, "********* Settings saved successfully *********");
2864 } else {
2865 console_print(myid, "Unable to write to file %s", settings);
2866 }
2867 }
2868 if (!success) {
2869 #if defined DEDICATED_LOG_ENABLED
2870 log_to_file(logfilename, "Unable to write to file %s", settings);
2871 #endif
2872 return 0;
2873 }
2874 } else {
2875 if (myid >= 0) {
2876 console_print(myid, "Variables not valid, not saving to %s", settings);
2877 }
2878 #if defined DEDICATED_LOG_ENABLED
2879 log_to_file(logfilename, "Warning: Variables not valid, not saving to %s", settings);
2880 #endif
2881 return 0;
2882 }
2883 return 1;
2884 }
2885
2886 public dmapmapsurl(id, level, cid) {
2887 if (!cmd_access(id, level, cid, 2)) {
2888 return PLUGIN_HANDLED;
2889 }
2890
2891 new arg[64];
2892 read_argv(1, arg, 63);
2893 if (equali(arg, "http")) {
2894 console_print(id, "You must specify a url that contains www or http (do not use any colons)(use ^"none^" to disable)");
2895 return PLUGIN_HANDLED;
2896 }
2897 if (containi(arg, "www") != -1 || containi(arg, "http") != -1) {
2898 console_print(id, "You have changed the mapsurl to %s", arg);
2899 mapsurl = arg;
2900 savesettings(id);
2901 showsettings(id);
2902 } else {
2903 if (containi(arg, "none") != -1) {
2904 console_print(id, "You have choosen to disable your mapsurl, none will be used");
2905 mapsurl = "";
2906 savesettings(id);
2907 showsettings(id);
2908 } else {
2909 console_print(id, "You must specify a url that contains www or http (do not use any colons)(use ^"none^" to disable)");
2910 }
2911 }
2912 return PLUGIN_HANDLED;
2913 }
2914
2915 public dmapdefaults(id, level, cid) {
2916 if (!cmd_access(id, level, cid, 1)) {
2917 return PLUGIN_HANDLED;
2918 }
2919
2920 set_defaults(id);
2921 return PLUGIN_HANDLED;
2922 }
2923
2924 public event_RoundStart() {
2925 isbetween = 0;
2926 isbuytime = 1;
2927 set_task(10.0, "now_safe_to_vote");
2928
2929 currounds++;
2930 new players[32], playernum;
2931 get_players(players, playernum, "c");
2932 curplayers += playernum;
2933 }
2934
2935 public event_RoundEnd() {
2936 isbetween = 1;
2937 }
2938
2939 public now_safe_to_vote() {
2940 //client_print(0, print_chat, "Now it is safe to vote");
2941 isbuytime = 0;
2942 }
2943
2944 public list_maps2() {
2945 messagemaps();
2946 }
2947
2948 public list_maps3() {
2949 messagenominated();
2950 }
2951
2952 public plugin_init() {
2953
2954 register_plugin(PLUGIN, VERSION, AUTHOR);
2955 register_dictionary("deagsmapmanager.txt");
2956
2957 get_configsdir(custompath, 49);
2958 change_custom_path();
2959
2960 register_clcmd("say", "HandleSay", 0, "Say: vote mapname, nominate mapname, or just mapname to nominate a map, say: nominations");
2961 register_clcmd("say rockthevote", "rock_the_vote", 0, "Rocks the Vote");
2962 register_clcmd("say rtv", "rock_the_vote", 0, "Rocks the Vote");
2963 register_clcmd("say listmaps", "list_maps", 0, "Lists all maps in a window and in console");
2964 register_clcmd("say nextmap", "say_nextmap", 0, "Shows nextmap information to players");
2965 register_concmd("dmap_help", "dmaphelp", 0, "Shows on-screen help information about Map Plugin");
2966 register_concmd("dmap_status", "dmapstatus", ADMIN_DMAP, "Shows settings/status/help of the map management variables");
2967 register_concmd("dmap_votemode", "dmapvotemode", ADMIN_SUPER_DMAP, "Enables Voting (This is default mode)");
2968 register_concmd("dmap_cyclemode", "dmapcyclemode", ADMIN_SUPER_DMAP, "Disables Voting (To restore voting use dmap_votemode)");
2969 register_concmd("dmap_banlastmaps", "dmapbanlastmaps", ADMIN_SUPER_DMAP, "Bans the last <n> maps played from being voted (0-99)");
2970 register_concmd("dmap_quietmode", "dmapquiet", ADMIN_SUPER_DMAP, "Usage: <OFF|nosound|silent>");
2971 register_concmd("dmap_freeze", "changefreeze", ADMIN_SUPER_DMAP, "Toggles Freeze/Drop at end of round ON|off");
2972 register_concmd("dmap_messages", "dmapmessages", ADMIN_SUPER_DMAP, "Sets the time interval in minutes between messages");
2973 register_concmd("dmap_rtvtoggle", "dmaprtvtoggle", ADMIN_SUPER_DMAP, "Toggles on|off Ability of players to use rockthevote");
2974 register_concmd("dmap_rockthevote", "admin_rockit", ADMIN_DMAP, "(option: now) Allows admins to force a vote");
2975 register_concmd("amx_rockthevote", "admin_rockit", ADMIN_DMAP, "(option: now) Allows admins to force a vote");
2976 register_concmd("amx_rtv", "admin_rockit", ADMIN_DMAP, "(option: now) Allows admins to force a vote");
2977 register_concmd("dmap_rtvpercent", "dmaprtvpercent", ADMIN_SUPER_DMAP, "Set the percent (3-100) of players for a rtv");
2978 register_concmd("dmap_rtvplayers", "dmaprtvplayers", ADMIN_SUPER_DMAP, "Sets the minimum number of players needed to rockthevote");
2979 register_concmd("dmap_rtvwait", "dmaprtvwait", ADMIN_SUPER_DMAP, "Sets the minimum time before rockthevote can occur (5-30)");
2980 register_concmd("dmap_default", "dmapdefaults", ADMIN_SUPER_DMAP, "Will restore settings to default");
2981 register_concmd("dmap_mapsurl", "dmapmapsurl", ADMIN_SUPER_DMAP, "Specify what website to get custom maps from");
2982 register_concmd("dmap_mapsnum", "dmapmapsnum", ADMIN_SUPER_DMAP, "Set number of maps in vote (will not take effect until next map");
2983 register_concmd("dmap_nominations", "dmapmaxnominations", ADMIN_SUPER_DMAP, "Set maximum number of nominations for each person");
2984 register_concmd("dmap_maxcustom", "dmapmaxcustom", ADMIN_SUPER_DMAP, "Set maximum number of custom nominations that may be made");
2985 register_concmd("dmap_cancelvote", "dmapcancelvote", ADMIN_DMAP, "Cancels the rocked vote");
2986
2987 register_logevent("event_RoundStart", 2, "0=World triggered", "1=Round_Start");
2988 register_logevent("event_RoundEnd", 2, "0=World triggered", "1=Round_End");
2989
2990 register_event("30", "changeMap", "a");
2991 #if defined DEDICATED_LOG_ENABLED
2992 get_time("dmaplog%m%d.log", logfilename, 255);
2993 #endif
2994 dmap_strict = register_cvar("dmap_strict", "0");
2995 nominations_allowed = register_cvar("nominations_allowed", "1");
2996
2997 register_cvar("enforce_timelimit", "0");
2998 register_cvar("amx_extendmap_max", "90");
2999 register_cvar("amx_extendmap_step", "15");
3000 register_cvar("amx_staytime", "300");
3001
3002 emptymap = register_cvar("amx_emptymap", "de_dust2");
3003 idletime = register_cvar("amx_idletime", "5");
3004 emptymap_allowed = register_cvar("emptymap_allowed", "0");
3005 weapon_delay = register_cvar("weapon_delay", "1");
3006
3007 staytime = get_cvar_num("amx_staytime");
3008
3009 is_cstrike = (cstrike_running() == 1);
3010 nmaps_num = num_nmapsfill = 0;
3011
3012 if (cstrike_running() == 1) {
3013 register_cvar("Deags_Map_Manage", VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY);
3014 register_event("TeamScore", "team_score", "a");
3015 } else {
3016 dofreeze = 0;
3017 register_cvar("Deags_Map_Manage", VERSION);
3018 }
3019 rtvpercent = 0.6;
3020 ban_last_maps = 4;
3021 minimumwait = 10;
3022 atstart = enabled = minimum = 1;
3023 quiet = cycle = isend = 0;
3024 mapsurl = "";
3025 set_task(3.0, "ban_some_maps"); //reads from lastmapsplayed.txt and stores into global array
3026 //set_task(8.0, "write_lastmaps"); //deletes and writes to lastmapsplayed.txt
3027 //set_task(2.0, "get_listing"); //loads mapcycle / allmaps.txt
3028 set_task(14.0, "load_defaultmaps"); //loads standardmaps.ini
3029 //set_task(17.0, "load_maps"); //loads mapchoice.ini
3030 set_task(15.0, "askfornextmap", 987456, "", 0, "b");
3031 set_task(5.0, "loopmessages", 987111, "", 0, "b");
3032 set_task(34.0, "gen_maphelphtml"); //Writes to help file, which is read every time that dmap_help is called by ANY player
3033 oldtimelimit = get_cvar_float("mp_timelimit");
3034 get_localinfo("amx_lastmap", last_map, 31);
3035 set_localinfo("amx_lastmap", "");
3036 set_task(1.0, "timer", 0, "curtime", 0, "b", 1);
3037 maps_to_select = mapssave = 5;
3038 new temparray[64];
3039 format(temparray, 64, "%s/mapvault.dat", custompath);
3040 if (!loadsettings(temparray)) {
3041 set_defaults(-1);
3042 }
3043 atstart = 0;
3044 register_menucmd(register_menuid("Choose the next map:"), (-1 ^ (-1 << (maps_to_select + 2))), "vote_count");
3045 }

Contact webmaster
ViewVC Help
Powered by ViewVC RSS 2.0 feed