unKn0wn | Дата: Среда, 20.08.2008, 16:49:24 | Сообщение # 1 |
 Майор
Группа: Пользователи
Сообщений: 98
Статус: Не в сети
| Плагин я выкладываю в оригинальном виде (сири за код, неумею выкладывать файлом ) Плагин умеет: задовать голосование на любой серверной\консольной команды по истечению 30 секунд как началась карта. Сейчас плагин настроен так, чтобы в КСе включить убийство только в голову или оставить как есть. Code
#include <amxmodx> #include <amxmisc>
#define SPEED 0.3
new g_Answer[128] new g_optionName[4][32] new g_voteCount[4] new g_validMaps new g_yesNoVote new g_coloredMenus new g_voteCaller new g_Execute[256] new g_execLen
new bool:g_execResult new Float:g_voteRatio
new float:speed = 10.0
public plugin_init() { register_plugin("Headshot changer", AMXX_VERSION_STR, "Defekt (c) 2008")
register_menucmd(register_menuid("Vote: "), MENU_KEY_1|MENU_KEY_2, "voteCount") register_menucmd(register_menuid("The result: "), MENU_KEY_1|MENU_KEY_2, "actionResult") register_srvcmd("quest_hs", "cmdWaitVote", 0, "- test") register_concmd("votehs", "cmdVote", 0, "<question> <answer#1> <answer#2>") register_concmd("amx_cancelvote", "cmdCancelVote", ADMIN_VOTE, "- cancels last vote") g_coloredMenus = colored_menus()
set_task(26.0, "sek4", 0) set_task(27.0, "sek3", 0) set_task(28.0, "sek2", 0) set_task(29.0, "sek1", 0) set_task(30.0, "cmdVote", 0, "") }
public sek4(id) server_cmd("amx_csay green Headshot choice in 4 sek")
public sek3(id) server_cmd("amx_csay green Headshot choice in 3 sek")
public sek2(id) server_cmd("amx_csay yellow Headshot choice in 2 sek")
public sek1(id) server_cmd("amx_csay red Headshot choice in 1 sek")
public cmdWaitVote(id) { set_task(speed, "cmdVote", 0, "") server_cmd("amx_csay red waiting for cmdVote") }
public cmdCancelVote(id, level, cid) { if (!cmd_access(id, level, cid, 0)) return PLUGIN_HANDLED
if (task_exists(99889988, 1)) { new authid[32], name[32] get_user_authid(id, authid, 31) get_user_name(id, name, 31) log_amx("Vote: ^"%s<%d><%s><>^" cancel vote session", name, get_user_userid(id), authid) new players[32], pnum, lTag[16], activity = get_cvar_num("amx_show_activity") get_players(players, pnum, "c") for (new i = 0; i < pnum;i ++) { format(lTag, 15, "%L", players[i], is_user_admin(id) ? "ADMIN" : "PLAYER") switch (activity) { case 2: client_print(players[i], print_chat, "%L", LANG_PLAYER, "ADMIN_CANC_VOTE_2", lTag, name) case 1: client_print(players[i], print_chat, "%L", LANG_PLAYER, "ADMIN_CANC_VOTE_1", lTag) } } console_print(id, "%L", id, "VOTING_CANC") client_print(0,print_chat,"%L",LANG_PLAYER,"VOTING_CANC") remove_task(99889988, 1) set_cvar_float("amx_last_voting", get_gametime()) } else console_print(id, "%L", id, "NO_VOTE_CANC")
return PLUGIN_HANDLED }
public delayedExec(cmd[]) server_cmd("%s", cmd)
public autoRefuse() { log_amx("Vote: %L", "en", "RES_REF") client_print(0, print_chat, "%L", LANG_PLAYER, "RES_REF") }
public actionResult(id, key) { remove_task(4545454) switch (key) { case 0: { set_task(2.0, "delayedExec", 0, g_Execute, g_execLen) log_amx("Vote: %L", "en", "RES_ACCEPTED") client_print(0, print_chat, "%L", LANG_PLAYER, "RES_ACCEPTED") } case 1: autoRefuse() } return PLUGIN_HANDLED }
public checkVotes() { new best = 0 if (!g_yesNoVote) { for (new a = 0; a < 4; ++a) if (g_voteCount[a] > g_voteCount[best]) best = a }
new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3] new iRatio = votesNum ? floatround(g_voteRatio * float(votesNum), floatround_ceil) : 1 new iResult = g_voteCount[best] new players[32], pnum, i get_players(players, pnum, "c") if (iResult < iRatio) { new lVotingFailed[64] for (i = 0; i < pnum; i++) { format(lVotingFailed, 63, "%L", players[i], "VOTING_FAILED") if (g_yesNoVote) client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_1", lVotingFailed, g_voteCount[0], g_voteCount[1], iRatio) else client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_2", lVotingFailed, iResult, iRatio) } format(lVotingFailed, 63, "%L", "en", "VOTING_FAILED") log_amx("Vote: %s (got ^"%d^") (needed ^"%d^")", lVotingFailed, iResult, iRatio) client_print(0, print_chat, "Voting result rejected. only headshots off", LANG_PLAYER, "123")
return PLUGIN_CONTINUE }
g_execLen = format(g_Execute, 255, g_Answer, g_optionName[best]) + 1 if (g_execResult) { g_execResult = false if (is_user_connected(g_voteCaller)) { new menuBody[512], lTheResult[32], lYes[16], lNo[16] format(lTheResult, 31, "%L", g_voteCaller, "THE_RESULT") format(lYes, 15, "%L", g_voteCaller, "YES") format(lNo, 15, "%L", g_voteCaller, "NO") new len = format(menuBody, 511, g_coloredMenus ? "\y%s: \w%s^n^n" : "%s: %s^n^n", lTheResult, g_Execute) len += format(menuBody[len], 511 - len, g_coloredMenus ? "\y%L^n\w" : "%L^n", g_voteCaller, "WANT_CONTINUE") format(menuBody[len], 511 - len, "^n1. %s^n2. %s", lYes, lNo) show_menu(g_voteCaller, 0x03, menuBody, 10, "The result: ") set_task(10.0, "autoRefuse", 4545454) } else set_task(2.0, "delayedExec", 0, g_Execute, g_execLen)
} new lVotingSuccess[32] for (i = 0; i < pnum; i++) { format(lVotingSuccess, 31, "%L", players[i], "VOTING_SUCCESS") //client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_3", lVotingSuccess, iResult, iRatio, g_Execute) } if ( g_voteCount[0] > g_voteCount[1] ) { server_cmd("amx_csay red Play HARD, Only HEADSHOTS Started") server_cmd("amx_csay red Play HARD, Only HEADSHOTS Started") server_cmd("amx_csay red Play HARD, Only HEADSHOTS Started") client_print(0, print_chat, "Voting result success. only headshots on", LANG_PLAYER, "123") server_cmd("headshots 1") } else { server_cmd("amx_csay green Play easy, only headshots off") server_cmd("amx_csay green Play easy, only headshots off") server_cmd("amx_csay green Play easy, only headshots off") client_print(0, print_chat, "Voting result success. only headshots off", LANG_PLAYER, "123") server_cmd("headshots 0") }
format(lVotingSuccess, 31, "%L", "en", "VOTING_SUCCESS") log_amx("Vote: %s (got ^"%d^") (needed ^"%d^") (result ^"%s^")", lVotingSuccess, iResult, iRatio, g_Execute) return PLUGIN_CONTINUE }
public voteCount(id, key) { if (get_cvar_num("amx_vote_answers")) { new name[32] get_user_name(id, name, 31) if (g_yesNoVote) client_print(0, print_chat, "%L", LANG_PLAYER, key ? "VOTED_AGAINST" : "VOTED_FOR", name) else client_print(0, print_chat, "%L", LANG_PLAYER, "VOTED_FOR_OPT", name, key + 1) } ++g_voteCount[key] return PLUGIN_HANDLED }
public cmdVote(id, level, cid) { remove_task(555)
new quest[48] = "What game wanting?" g_optionName[0] = "Hits only headshot." g_optionName[1] = "Hits anywhere."
new authid[32], name[32] get_user_authid(id, authid, 31) get_user_name(id, name, 31) log_amx("Vote: ^"%s<%d><%s><>^" vote custom (question ^"%s^") (option#1 ^"%s^") (option#2 ^"%s^")", name, get_user_userid(id), authid, quest, g_optionName[0], g_optionName[1])
new activity = get_cvar_num("amx_show_activity") if (activity > 0) { new players[32], pnum, lTag[16] get_players(players, pnum, "c") for (new i = 0; i < pnum; i++) { format(lTag, 15, "%L", players[i], is_user_admin(id) ? "ADMIN" : "PLAYER") switch (activity) { case 2: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_CUS_2", lTag, name) case 1: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_CUS_1", lTag) } } }
new menu_msg[256], lVote[16] format(lVote, 15, "%L", LANG_SERVER, "VOTE") new keys = MENU_KEY_1|MENU_KEY_2 format(menu_msg, 255, g_coloredMenus ? "\y%s: %s\w^n^n1. %s^n2. %s" : "%s: %s^n^n1. %s^n2. %s", lVote, quest, g_optionName[0], g_optionName[1]) g_execResult = false new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0 g_voteRatio = get_cvar_float("amx_vote_ratio") format(g_Answer, 127, "%s - %%s", quest) show_menu(0, keys, menu_msg, floatround(vote_time), "Vote: ") set_task(vote_time, "checkVotes", 99889988) g_voteCaller = id console_print(id, "%L", id, "VOTING_STARTED") g_voteCount = {0, 0, 0, 0} g_yesNoVote = 0 return PLUGIN_HANDLED } а измени я вот так (не считая информационных сообщений) Code server_cmd("amx_csay red Play HARD, Only HEADSHOTS Started") server_cmd("amx_csay red Play HARD, Only HEADSHOTS Started") server_cmd("amx_csay red Play HARD, Only HEADSHOTS Started") client_print(0, print_chat, "Voting result success. only headshots on", LANG_PLAYER, "123") server_cmd("amx_removeegon 1") server_cmd("restart") } else { server_cmd("amx_csay green Play easy, only headshots off") server_cmd("amx_csay green Play easy, only headshots off") server_cmd("amx_csay green Play easy, only headshots off") client_print(0, print_chat, "Voting result success. only headshots off", LANG_PLAYER, "123") server_cmd("amx_removeegon 0") server_cmd("restart") } Я изменил переменную в плагине чтобы выводилось голосование за замену айтема с карты. Но чтобы сделать эту замену, нужно после голосования сделать рестарт(рестарт нужен обизательно). Таким образом перезагрузиться карта и айтемы, и изменения вступят в силу. (Плагин для замены айтемов в этой теме) Но проблема в том, что после рестарта голосование начинаеться заново, следовательно получаеться замкнутый круг (30сек. иргы-голосование-рестарт-30сек. иргы-голосование...). Прошу помощи (так как сам неразбираюсь) переделать плагин чтобы небыло этого "замкнутого круга"
Сообщение отредактировал unKn0wn - Среда, 20.08.2008, 16:51:12 |
|
| |