Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < amxmodx >
- #define MAX_MAPS 4
- #define VOTE_NO 0
- #define VOTE_IN_PROGRESS 1
- #define VOTE_ENDED 2
- new const Tag[] = "YourTag";
- new bool:Voted[ 33 ];
- new g_szRoundVotemap, Timer
- new g_szKind[MAX_MAPS]
- new g_maps[MAX_MAPS][30]
- new rounds
- new menu
- new g_votestatus
- new g_nextmap[30]
- new const Change[][] =
- {
- "de_dust2",
- "de_nuke",
- "de_inferno",
- "de_train",
- "de_dust" //יכולים להוסיף כמה מפות שאתם רוצים
- }
- public plugin_init()
- {
- register_plugin("Simple VoteMap", "1.0", "AMXX")
- register_event( "HLTV", "NewRound", "a", "1=0", "2=0" )
- rounds = register_cvar("amx_roundtovote", "35") // מספר הראונדים שיהיה הצבעה
- register_clcmd("say nextvote", "shownextvote")
- register_clcmd("say /nextvote", "shownextvote")
- set_task(45.0,"Adv_message",.flags="b")
- g_votestatus = VOTE_NO
- }
- public shownextvote(id)
- {
- if(g_votestatus == VOTE_NO)
- {
- new r = get_pcvar_num(rounds) - g_szRoundVotemap
- if(r > 0)
- ColorChat(id, "There Will be^4 VoteMaps^1 in:^3 %i ^1Rounds", r)
- }
- return PLUGIN_HANDLED
- }
- public NewRound()
- {
- if(g_votestatus == VOTE_IN_PROGRESS)
- return
- g_szRoundVotemap++
- new rounds_left = get_pcvar_num(rounds) - g_szRoundVotemap
- if(rounds_left > 0)
- ColorChat(0, "There Will be^4 VoteMaps^1 in:^3 %i ^1Rounds", rounds_left)
- else
- {
- if(g_votestatus == VOTE_NO)
- {
- ColorChat(0, "^4 VoteMaps^1 will start now", rounds_left)
- set_task(1.0, "ActionSpecial")
- g_votestatus = VOTE_IN_PROGRESS
- }
- if(g_votestatus == VOTE_ENDED)
- {
- message_begin(MSG_ALL, SVC_INTERMISSION)
- message_end()
- set_task(floatmax(get_cvar_float("mp_chattime"), 2.0), "map_change")
- ColorChat(0, "Nextmap will be^4 %s", g_nextmap)
- }
- }
- }
- public map_change()
- server_cmd("changelevel %s", g_nextmap)
- public ActionSpecial()
- {
- new mapid, currentmap[32]
- new bool:g_choosedmap[sizeof(Change)] = false
- get_mapname(currentmap, 31)
- for(mapid = 0; mapid < sizeof(Change); mapid++) //don't add currentmap to vote
- if(equali(Change[mapid], currentmap))
- {
- g_choosedmap[mapid] = true
- break
- }
- for(new i = 0; i < MAX_MAPS; i++) //select defined amount maps
- {
- g_szKind[i] = 0 //clean votes
- do
- {
- while(g_choosedmap[mapid = random_num(0, sizeof(Change)-1)]) {}//if already in vote let's take another
- } while(!is_map_valid(Change[mapid])) //if not valid map choose another aswell
- g_choosedmap[mapid] = true //choosed for vote, will not be picked again
- format(g_maps[i], 29, "%s", Change[mapid])//added to selected maps for vote
- }
- new players[32], num, id
- get_players(players, num)
- for( new i = 0; i < num; i++ ) //show menu
- {
- id = players[i]
- Voted[id] = false;
- ChangeMaps(id)
- }
- 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");
- countdown2()
- }
- public ChangeMaps(client)
- {
- if(Timer >= 0)
- {
- static szMap[128]
- new st[3]
- formatex(szMap, charsmax(szMap)-1, "\d[\r AMXX \d]^n\w Which Map Do You Want?^n\r// \wStatus: %s^n\r// \wTime to choose: \y%i",Voted[client] ? "\yVoted" : "\rNot Voted", Timer)
- menu = menu_create(szMap, "menu_handler")
- for( new k = 0; k < MAX_MAPS; k++ ) // show selected maps + votes
- {
- num_to_str(k+1, st, 2)
- formatex( szMap, charsmax(szMap)-1, "\w%s \w[\r%i \yVotes\w]", g_maps[k] , g_szKind[k])
- menu_additem(menu, szMap, st)
- }
- menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER)
- menu_display(client, menu)
- }
- else //vote expired
- show_menu(client,0,"^n",1)
- }
- 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 ^3Won ^1the vote with ^4%i ^1Votes ^3Next Round Change Map^1.", g_maps[Winner], g_szKind[Winner])
- format(g_nextmap, 29, "%s", g_maps[Winner]) // set winner as nextmap
- g_votestatus = VOTE_ENDED
- }
- public menu_handler(client, menu, item)
- {
- if(Timer >= 0)
- {
- if(!Voted[client] && item != MENU_EXIT) //if didn't vote, count client's vote
- {
- new data[6], iName[64]
- new access, callback
- menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
- new key = str_to_num(data) - 1
- new szName[32]
- get_user_name(client, szName, 31)
- ColorChat(0, "^3%s^1 has^4 Voted ^1for^4 %s", szName, g_maps[key])
- g_szKind[key]++
- Voted[client] = true
- }
- ChangeMaps(client) //then show again
- }
- else //vote expired :BB
- show_menu(client,0,"^n",1)
- return PLUGIN_HANDLED
- }
- public countdown2()
- {
- if(Timer >= 0)
- {
- Timer--
- set_task(1.0,"countdown2")
- new players[32], num, id
- get_players(players, num)
- for( new i = 0; i < num; i++ )
- {
- id = players[i]
- show_menu(id,0,"^n",1)
- ChangeMaps(id)
- }
- }
- }
- public Adv_message(){
- ColorChat(0,"Type ^3/nextvote^1 To View The ^4Next Vote Map^1.");
- }
- stock ColorChat(const client, const string[], {Float, Sql, Resul,_}:...)
- {
- new msg[ 191 ], players[ 32 ], count = 1;
- static len; len = formatex( msg, charsmax(msg), "^4[^3%s^4]^1 ",Tag );
- vformat( msg[ len ], charsmax( msg ) - len, string, 3 );
- if( client ) players[ 0 ] = client;
- 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();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement