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

Contact webmaster
ViewVC Help
Powered by ViewVC RSS 2.0 feed