19/11/2020, 05:45 PM
(Última modificación: 21/11/2020, 02:08 AM por Meliodas. Edited 1 time in total.)
estoy tratando de adaptar un menú a este vote pero el problema que tengo es que no me inicia la votación la votación debería de iniciar en la ronda de freezetime pero no inicia
Código PHP:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
//#include <pug>
#define NONE_TARGET -1
enum _:VOTE_EVENTS
{
NONE_EVENT = 0,
VOTE
}
new g_szTag[] = "^4[Test]^1";
new const g_iTask = 12512;
new const g_iTask2 = 12452;
new Float:g_fFreezeTime;
new bool:g_bEvent;
new g_iTypeEvent;
new g_iPlayerTarget;
new g_iMaxPlayers;
new g_iVotes[2];
new g_iTeamVotes[CsTeams];
new g_pCvarTeamVotes;
public plugin_init()
{
register_plugin("Votekick", "1.0", "Alejandro-.");
g_pCvarTeamVotes = register_cvar("pv_team_votes", "2");
register_event("HLTV", "EventNewRound", "a", "1=0", "2=0");
//register_pug_event(INTERMISSION_START, "PugEventIntermissionStart");
//register_clcmd("say", "HookSay");
register_clcmd("say test", "OnVote")
g_iMaxPlayers = get_maxplayers();
g_fFreezeTime = get_cvar_float("mp_freezetime");
g_iTeamVotes[CS_TEAM_CT] = get_pcvar_num(g_pCvarTeamVotes);
g_iTeamVotes[CS_TEAM_T] = get_pcvar_num(g_pCvarTeamVotes);
g_iPlayerTarget = NONE_TARGET;
g_iTypeEvent = NONE_EVENT;
g_bEvent = false;
}
public OnVote(id)
{
new menu
menu = menu_create("\y[Test] \wVote", "handler_vote")
new name[32], IDS[12]
for(new i = 1; i <= g_iMaxPlayers; i++)
{
if(is_user_connected(i) && cs_get_user_team(i) == cs_get_user_team(id) && id != i)
{
get_user_name(i, name, charsmax(name))
formatex(IDS, charsmax(IDS), "%d %d", i, get_user_userid(i))
menu_additem(menu, name, IDS)
}
}
menu_display(id, menu, 0)
}
public handler_vote(const index, menu, item)
{
new playerid
new lol, buffer[12], userid
menu_item_getinfo(menu, item, lol, buffer, charsmax(buffer), _, _, lol)
new szid[3], szuserid[9]
parse(buffer, szid, charsmax(szid), szuserid, charsmax(szuserid))
playerid = str_to_num(szid)
userid = str_to_num(szuserid)
if (!g_bEvent)
{
if (g_iTypeEvent != NONE_EVENT)
{
g_bEvent = false;
g_iPlayerTarget = NONE_TARGET;
g_iTypeEvent = NONE_EVENT;
}
else
{
if(g_bEvent)
{
client_print_color(index, print_team_default, "%s Ya hay una votacion en curso", g_szTag);
return PLUGIN_HANDLED
}
if (!is_user_connected(playerid))
{
client_print_color(index, print_team_default, "%s El jugador ^4%s^1 no se encuentra disponible", g_szTag, playerid);
return PLUGIN_HANDLED;
}
if(userid != get_user_userid(playerid))
{
return PLUGIN_HANDLED;
}
if (get_user_flags(playerid) & ADMIN_IMMUNITY)
{
client_print_color(index, print_team_default, "%s El jugador tiene ^4inmunidad", g_szTag);
return PLUGIN_HANDLED;
}
if (!g_iTeamVotes[cs_get_user_team(index)])
{
client_print_color(index, print_team_default, "%s Se le acabaron las votaciones a tu equipo", g_szTag);
return PLUGIN_HANDLED;
}
client_print_color(0, get_user_team(index) == 1 ? print_team_red : print_team_blue, "El equipo ^3%s^1 decidio hacer una votacion", get_user_team(index) == 1 ? "Terrorista" : "AntiTerrorista");
g_bEvent = true;
g_iPlayerTarget = playerid;
g_iTeamVotes[cs_get_user_team(index)]--;
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public PugEventIntermissionStart()
{
g_iTeamVotes[CS_TEAM_CT] = get_pcvar_num(g_pCvarTeamVotes);
g_iTeamVotes[CS_TEAM_T] = get_pcvar_num(g_pCvarTeamVotes);
}
public EventNewRound()
{
if (g_bEvent)
{
switch(g_iTypeEvent)
{
case VOTE:
{
for (new i = 1; i <=g_iMaxPlayers; i++)
{
if (!is_user_connected(i))
continue;
if (get_user_team(i) != get_user_team(g_iPlayerTarget))
continue;
new snd_vote = random_num(1, 2);
client_cmd(i, "spk Gman/Gman_Choose%d", snd_vote);
DisplayerPlayerMenu(i);
set_task(0.1, "DisplayPlayerHud", i+g_iTask2, _, _, "b");
}
set_task(g_fFreezeTime, "EndEventVote", g_iTask);
}
case NONE_EVENT:
{
g_bEvent = false;
g_iPlayerTarget = NONE_TARGET;
}
}
}
}
public DisplayerPlayerMenu(index)
{
new menu = menu_create("¿Deseas aceptar el Vote?", "HandlerPlayerMenuVote");
menu_additem(menu, "Si");
menu_additem(menu, "No");
menu_setprop(menu, MPROP_EXITNAME, "Salir");
menu_display(index, menu);
}
public HandlerPlayerMenuVote(index, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
g_iVotes[item]++;
client_print_team_msg(index, fmt("%s ^3%n^1: Voto ah ^4%s^1.", g_szTag, index, item == 0 ? "Si" : "No"));
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public DisplayPlayerHud(index)
{
index -= g_iTask2;
if (!g_bEvent)
{
remove_task(index+g_iTask2);
return;
}
if (!is_user_connected(g_iPlayerTarget))
{
CancelVote();
return;
}
set_dhudmessage(0, 255, 0, -1.0, 0.05, 0, 6.0, 0.2);
show_dhudmessage(index, "VOTE");
set_hudmessage(255, 255, 255, -1.0, 0.1, 0, 6.0, 0.2);
show_hudmessage(index, "Jugador: %n^nSi: %d | No: %d", g_iPlayerTarget, g_iVotes[0], g_iVotes[1]);
}
public CancelVote()
{
for (new i = 1; i <= g_iMaxPlayers; i++)
{
if (!is_user_connected(i))
continue;
if (get_user_team(i) != get_user_team(g_iPlayerTarget))
continue;
show_menu(i, 0, "^n");
}
g_bEvent = false;
g_iPlayerTarget = NONE_TARGET;
g_iTypeEvent = NONE_EVENT;
g_iVotes[0] = 0;
g_iVotes[1] = 0;
if (task_exists(g_iTask))
{
remove_task(g_iTask);
}
client_print_team_msg(g_iPlayerTarget, fmt("%s La votacion fue cancelada por que el jugador no se encuentra en el servidor", g_szTag));
}
public EndEventVote()
{
if (g_iVotes[0] == g_iVotes[1])
{
client_print_team_msg(g_iPlayerTarget, fmt("%s Los votos quedaron en empate, no sera ^3kickeado", g_szTag));
}
else if (g_iVotes[0] > g_iVotes[1])
{
client_print_team_msg(g_iPlayerTarget, fmt("%s El jugador es ^3kickeado^1 por mayoria de votos", g_szTag));
if (g_iTypeEvent == VOTE)
{
server_cmd("amx_ban #%i ^"5^" ^"'¡Fuiste baneado por mayoria de votos!'^"", get_user_userid(g_iPlayerTarget));
}
}
else
{
client_print_team_msg(g_iPlayerTarget, fmt("%s El jugador no sera ^3kickeado^1 por mayoria de votos", g_szTag));
}
for (new i = 1; i <=g_iMaxPlayers; i++)
{
if (!is_user_connected(i))
continue;
if (get_user_team(i) != get_user_team(g_iPlayerTarget))
continue;
show_menu(i, 0, "^n");
}
g_bEvent = false;
g_iPlayerTarget = NONE_TARGET;
g_iTypeEvent = NONE_EVENT;
g_iVotes[0] = 0;
g_iVotes[1] = 0;
}
stock client_print_team_msg(const index, const msg[])
{
for (new i = 1; i <=g_iMaxPlayers; i++)
{
if (is_user_connected(i) && get_user_team(index) == get_user_team(i))
{
client_print_color(i, print_team_default, msg);
}
}
}
Pawn Básico no critiquen xD