07/04/2021, 09:59 PM
(Última modificación: 07/04/2021, 11:38 PM por iZeus. Edited 2 times in total.
Razón: solucionado el orden de los mapas dependiendo de los votos que reciban
)
Hola a todos, como dice el titulo he intentado agregarle la opción de ampliar la duración del mapa actual en este votemap hecho por claans, pero no se me ocurre la metodología.
Ojala puedan ayudarme, muchas gracias.
Ojala puedan ayudarme, muchas gracias.
Código PHP:
#include < amxmodx >
new const PLUGIN[ ] = "Vote Map"
new const AUTHOR[ ] = "cLAANS"
new const VERSION[ ] = "1.0"
new const g_menu_mapas[ ][ ] =
{
{ "de_dust2" },
{ "de_nuke" },
{ "de_inferno" },
{ "de_train" },
{ "de_tuscan" },
{ "de_forge" },
{ "de_russka" },
{ "de_cbble" }
}
new g_iVotes[ sizeof g_menu_mapas ];
new g_iMenuVoteMapa;
public plugin_init( )
{
register_plugin( PLUGIN, VERSION, AUTHOR );
register_clcmd( "vote", "VoteMenu");
}
public VoteMenu( )
{
new RandomMapas[ sizeof g_menu_mapas ];
for ( new i = 0 ; i < sizeof RandomMapas ; i++ )
RandomMapas[ i ] = i;
g_iMenuVoteMapa = menu_create( "\y[VoteMap]\w Votacion del mapa", "HandlerVote" );
new iMapaRandom, info[ 2 ];
for( new i = 0 ; i < 3 ; i++ )
{
iMapaRandom = random( sizeof RandomMapas - i ) + i;
info[ 0 ] = RandomMapas[ iMapaRandom ];
menu_additem( g_iMenuVoteMapa, g_menu_mapas[ iMapaRandom ], info);
RandomMapas[ iMapaRandom ] = RandomMapas[ i ];
}
menu_additem(g_iMenuVoteMapa, "Extender Mapa Actual")
new players[ 32 ], playersnum;
get_players( players, playersnum, "c" );
for( new i = 0 ; i < playersnum ; i++ ) menu_display( players[ i ], g_iMenuVoteMapa );
set_task( 10.0, "VoteMenuEnd" );
}
public HandlerVote( id, menu, item )
{
if( item == MENU_EXIT ) return;
new info[ 2 ], dummy;
menu_item_getinfo(menu, item, dummy, info, 1, _, _, dummy)
if( item == 3 ) {
client_print( id, print_chat, "Has votado por Extender el Mapa" );
// Como lo haria aqui?
return;
}
client_print( id, print_chat, "Has votado por el mapa %s", g_menu_mapas[ info[ 0 ] ] );
g_iVotes[ info[ 0 ] ]++;
}
public VoteMenuEnd( )
{
menu_destroy( g_iMenuVoteMapa );
new cell[sizeof g_menu_mapas], Draw, winner;
calc_vote(g_iVotes, sizeof g_menu_mapas, cell, Draw);
// if (?) client_print( 0, print_chat, "El mapa actual se extendera 15 minutos" );
if (Draw) {
winner = random(Draw+1);
client_print( 0, print_chat, "El mapa ganador fue: %s debido a un empate", g_menu_mapas[ winner ] );
} else {
for(new i = 1; i < sizeof g_iVotes; i++) if(g_iVotes[i] > g_iVotes[winner]) winner = i;
client_print( 0, print_chat, "El mapa ganador fue: %s con %d votos", g_menu_mapas[ winner ], g_iVotes[ winner ] );
}
arrayset(g_iVotes, 0, sizeof g_iVotes);
}
stock calc_vote(Vote[], size, cell[], &draw) {
new i, z, nocheck
for(/*nothing*/; i < size; i++) {
cell[i] = -1
for(z = 0; z < size; z++) {
if(nocheck & (1 << (z & 31))) continue
if(cell[i] == -1 || Vote[cell[i]] <= Vote[z]) cell[i] = z
}
nocheck |= (1 << (cell[i] & 31))
}
for(i = 1; i < size; i++) {
if(Vote[cell[i-1]] != Vote[cell[i]]) break
draw++
}
}