Not tested ._. I hope it helps you
PHP Code:
/* Plugin generated by AMXX-Studio */
#include < amxmodx >
#include < cstrike >
#include < hamsandwich >
#define MAX_MAPS 3
new bool:Voted[ 33 ];
new g_szRoundVotemap, Timer
new g_szKind[MAX_MAPS]
new g_maps[MAX_MAPS][30]
new rounds
new const Change[][] =
{
"jb_funny_live",
"jail_crewkule",
"jb_flyhigh",
"jail_pyramid",
"jail_crewkule2",
"jail_aj_bananamuffin_nd",
"jail_rehab_b2",
"jail_xmf",
"jail_armageddon",
"jail_renner_b6",
"jail_rats"
}
public plugin_init()
{
register_plugin("Simple VoteMap", "1.0", "AMXX")
register_event( "HLTV", "NewRound", "a", "1=0", "2=0" )
rounds = register_cvar("amx_roundstovote", "3")
}
public NewRound()
{
g_szRoundVotemap++;
ColorChat( 0, "there will be votemap in: %i Rounds", 3 - g_szRoundVotemap);
if(g_szRoundVotemap >= get_pcvar_num(rounds))
set_task( 1.0, "ActionSpecial" );
}
public ActionSpecial()
{
for( new i = 0; i <= MAX_MAPS; i++ ) //select X maps
{
g_szKind[i] = 0
format(g_maps[i], 29, "%s", Change[random_num(0, sizeof(Change))])
}
for( new i = 1; i <= get_maxplayers(); i++ ) //show menu
{
if(is_user_connected(i))
{
Voted[i] = false;
ChangeMaps(i)
}
}
Timer = 17
client_cmd(0, "spk ^"get red(e80) ninety(s45) to check(e20) use bay(s18) mass(e42) cap(s50)^"")
set_task( 17.0, "checkvotesd",1700 );
countdown2();
}
public ChangeMaps(client)
{
static szMap[128];
new st[ 3 ];
formatex(szMap, charsmax(szMap), "\r[AMXX]\w Choose Map:^n\r// \wStatus: %s^n\r// \wTime to choose: \y%i",Voted[client] ? "\yVoted" : "\rNot Voted", Timer);
new menu = menu_create(szMap, "handlerdddd");
for( new k = 0; k < MAX_MAPS; k++ ) // show selected maps + votes
{
num_to_str( k, st, 2 );
formatex( szMap, charsmax( szMap ), "\w%s \d[\y%i Votes\d]", g_maps[k] , g_szKind[k]);
menu_additem( menu, szMap, st );
}
menu_setprop( menu, MPROP_EXIT, MEXIT_NEVER );
menu_display(client,menu);
}
public checkvotesd()
{
new Winner = 0;
for( new i = 1; i < sizeof g_maps; i++ ) // select maps with more votes
{
if( g_szKind[ Winner ] < g_szKind[ i ] )
Winner = i;
}
ColorChat( 0, "%s ^4won ^1the vote with ^3%i ^1", g_maps[ Winner ], g_szKind[ Winner ] );
new map[30]
format(map, 29, "%s", g_maps[Winner])
set_task(5.0, "changemap_", _, map, 30) // change map in 5 seconds from vote end
}
public changemap_(param[])
server_cmd("changelevel %s", param)
public handlerdddd( client, menu, item )
{
if( Voted[ client ] == true )
{
ChangeMaps( client);
return
}
new szName[ 32 ];
get_user_name( client, szName, 32 );
ColorChat( 0, "^3%s^1 has^4 voted ^1for^4 %s", szName, g_maps[ item ] )
g_szKind[ item ]++;
Voted[ client ] = true;
ChangeMaps(client);
return
}
public countdown2()
{
if(Timer <= 0)
remove_task(2000)
else
{
Timer--
set_task(1.0,"countdown2");
for( new i = 1; i <= get_maxplayers(); i++ )
if(is_user_connected( i ) )
ChangeMaps(i)
}
}
stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...)
{
new msg[191], players[32], count = 1
static len
len = formatex(msg, charsmax(msg), "^1[^3 AMXX^1] ")
vformat(msg[len], charsmax(msg) - len, string, 3)
if(id) players[0] = id
else get_players(players,count,"ch")
for (new i = 0; i < count; i++)
{
if(is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
return
}