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

Contact webmaster
ViewVC Help
Powered by ViewVC RSS 2.0 feed