|
Junior Member
|

04-04-2013
, 11:29
Re: Deagles' Map Manager v3.25Beta
|
#135
|
Quote:
Originally Posted by DynamicBits
- Make vote results display until everyone has finished voting
|
I think I've done it:
PHP Code:
show_vote_menu(bool:bFirstTime) {
new menu[512], menuVoted[512], a, mkeys = (1 << maps_to_select + 1); new steptime = get_pcvar_num(pExtendmapStep);
new pos, pos2;
new mp_winlimit = get_cvar_num("mp_winlimit"); if (bFirstTime == true) { g_TotalVotes = 0; for (a = 0; a <= 32; a++) { g_AlreadyVoted[a] = false; } }
if (bIsCstrike) { pos = formatex(menu, charsmax(menu), "\r%L\w^n^n", LANG_SERVER, "DMAP_MENU_TITLE"); pos2 = formatex(menuVoted, charsmax(menuVoted), "\r%L\w^n^n", LANG_SERVER, "DMAP_MENU_TITLE"); } else { pos = formatex(menu, charsmax(menu), "%L^n^n", LANG_SERVER, "DMAP_MENU_TITLE"); pos2 = formatex(menuVoted, charsmax(menuVoted), "%L^n^n", LANG_SERVER, "DMAP_MENU_TITLE"); }
new dmax = (nmaps_num > maps_to_select) ? maps_to_select : nmaps_num;
new tagpath[64], sMenuOption[64], sMenuOption2[64]; // If size of sMenuOption is changed, change maxlength in append_vote_percent as well formatex(tagpath, charsmax(tagpath), "%s/dmaptags.ini", custompath);
for (nmapstoch = 0; nmapstoch < dmax; ++nmapstoch) { if (bFirstTime == true) { a = random_num(0, nmaps_num - 1); // Randomize order of maps in vote while (is_in_menu(a)) { if (++a >= nmaps_num) { a = 0; } } nnextmaps[nmapstoch] = a; nvotes[nmapstoch] = 0; // Reset votes for each map }
if (is_custom_map(nmaps[nnextmaps[nmapstoch]]) && usestandard) { if (bIsCstrike) { formatex(sMenuOption, charsmax(sMenuOption), "%d. %s \b(%L)\w", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]], LANG_SERVER, "DMAP_MENU_CUSTOM"); formatex(sMenuOption2, charsmax(sMenuOption2), "\d%d. %s (%L)", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]], LANG_SERVER, "DMAP_MENU_CUSTOM"); } else { formatex(sMenuOption, charsmax(sMenuOption2), "%d. %s (%L)", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]], LANG_SERVER, "DMAP_MENU_CUSTOM"); formatex(sMenuOption2, charsmax(sMenuOption2), "%d. %s (%L)", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]], LANG_SERVER, "DMAP_MENU_CUSTOM"); } } else { // Don't show (Custom) formatex(sMenuOption, charsmax(sMenuOption), "%d. %s", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]]); if (bIsCstrike) formatex(sMenuOption2, charsmax(sMenuOption2), "\d%d. %s", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]]); else formatex(sMenuOption2, charsmax(sMenuOption2), "%d. %s", nmapstoch + 1, nmaps[nnextmaps[nmapstoch]]); }
if (file_exists(tagpath)) { // If the tag file is there, check for the extra tag new iLine, sFullLine[64], sTagMap[32], sTagText[32], txtLen; while (read_file(tagpath, iLine, sFullLine, charsmax(sFullLine), txtLen)) { if (sFullLine[0] == ';') { iLine++; continue; // Ignore comments }
strbreak(sFullLine, sTagMap, charsmax(sTagMap), sTagText, charsmax(sTagText)); // Split the map name and tag apart
// TODO: Wildcard (regex) matching // I pulled this code for the v3.24 release. // Sorry! Expect it to return in the future.
if (equali(nmaps[nnextmaps[nmapstoch]], sTagMap)) { format(sMenuOption, charsmax(sMenuOption), "%s [%s]", sMenuOption, sTagText); format(sMenuOption2, charsmax(sMenuOption2), "%s [%s]", sMenuOption2, sTagText); break; // Quit reading the file } iLine++; } }
#if FILE_LOGLEVEL >= LOGLEVEL_DEBUG log_to_file(logfilename, "[DMM] DEBUG: (nmapstoch:sMenuOption): %d:%s;", nmapstoch, sMenuOption); #endif append_vote_percent(sMenuOption, nmapstoch, true); append_vote_percent(sMenuOption2, nmapstoch, true, true); pos += formatex(menu[pos], charsmax(menu), sMenuOption); // TODO: This should probably be less than 511 since pos is > 0 pos2 += formatex(menuVoted[pos2], charsmax(menuVoted), sMenuOption2); mkeys |= (1 << nmapstoch); }
menu[pos++] = '^n'; menuVoted[pos2++] = '^n'; if (bFirstTime == true) { nvotes[maps_to_select] = 0; nvotes[maps_to_select + 1] = 0; } new mapname[32]; get_mapname(mapname, charsmax(mapname)); if (!mp_winlimit && get_cvar_float("mp_timelimit") < get_pcvar_float(pExtendmapMax)) { formatex(sMenuOption, charsmax(sMenuOption), "%L^n", LANG_SERVER, "DMAP_MENU_EXTEND", maps_to_select + 1, mapname, steptime); if (bIsCstrike) formatex(sMenuOption2, charsmax(sMenuOption2), "\d%L^n", LANG_SERVER, "DMAP_MENU_EXTEND", maps_to_select + 1, mapname, steptime); else formatex(sMenuOption2, charsmax(sMenuOption2), "%L^n", LANG_SERVER, "DMAP_MENU_EXTEND", maps_to_select + 1, mapname, steptime); append_vote_percent(sMenuOption, maps_to_select, true); append_vote_percent(sMenuOption2, maps_to_select, true, true); pos += formatex(menu[pos], 511, sMenuOption); pos2 += formatex(menuVoted[pos2], 511, sMenuOption2);
mkeys |= (1 << maps_to_select); }
formatex(sMenuOption, charsmax(sMenuOption), "%L", LANG_SERVER, "DMAP_MENU_NONE", maps_to_select + 2); if (bIsCstrike) formatex(sMenuOption2, charsmax(sMenuOption2), "\d%L", LANG_SERVER, "DMAP_MENU_NONE", maps_to_select + 2); else formatex(sMenuOption2, charsmax(sMenuOption2), "%L", LANG_SERVER, "DMAP_MENU_NONE", maps_to_select + 2); append_vote_percent(sMenuOption, maps_to_select + 1); append_vote_percent(sMenuOption2, maps_to_select + 1, _, true); formatex(menu[pos], 511, sMenuOption); formatex(menuVoted[pos2], 511, sMenuOption2);
if (bFirstTime == true) { g_VoteTimeRemaining = DMAP_VOTE_TIME; set_task(float(g_VoteTimeRemaining), "check_votes"); show_menu(0, mkeys, menu, --g_VoteTimeRemaining, DMAP_MENU_TITLE); set_task(1.0, "update_vote_time_remaining", DMAP_TASKID_VTR, "", 0, "a", g_VoteTimeRemaining); if (bIsCstrike) { c_p(0, print_chat, "[DMM] %L", LANG_PLAYER, "DMAP_TIME_TO_CHOOSE"); } if (quiet == 0) { client_cmd(0, "spk Gman/Gman_Choose%d", random_num(1, 2)); } #if FILE_LOGLEVEL >= LOGLEVEL_INFO log_to_file(logfilename, "[DMM] Voting for the next map started."); #endif } else { new players[32], iNum, id; get_players(players, iNum, "ch"); for (new iPlayer = 0; iPlayer < iNum; iPlayer++) { id = players[iPlayer]; if (g_AlreadyVoted[id] == false) { show_menu(players[iPlayer], mkeys, menu, g_VoteTimeRemaining, DMAP_MENU_TITLE); } else show_menu(players[iPlayer], 0, menuVoted, g_VoteTimeRemaining, DMAP_MENU_TITLE); }
} return PLUGIN_HANDLED; }
PHP Code:
append_vote_percent(sMenuOption[], iChoice, bool:bNewLine = false, bool:bDisabled = false) {
new iPercent = percent(nvotes[iChoice], g_TotalVotes); new sPercent[16]; if (iPercent > 0) { // Don't show 0% if (bIsCstrike) { if(!bDisabled) formatex(sPercent, charsmax(sPercent), " \d(%d%s)\w", iPercent, "%%"); else formatex(sPercent, charsmax(sPercent), " \y(%d%s)\d", iPercent, "%%"); } else { formatex(sPercent, charsmax(sPercent), " (%d%s)", iPercent, "%%"); } strcat(sMenuOption, sPercent, 63); }
if (bNewLine == true) { // Do this even if vote is 0% strcat(sMenuOption, "^n", 63); }
return PLUGIN_HANDLED; }
Last edited by GwynBleidD; 04-04-2013 at 11:31.
|
|