Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Includes */
- #include <amxmodx>
- #include <amxmisc>
- /* Defines */
- #define MAX_MAPS 4
- #define DMAP_TASKID_COUNTDOWN 1100 //
- /* Bool */
- new bool:g_Vote[ 33 ]
- new bool:Voted[ 33 ]
- new bool:g_Voted[ 33 ]
- new bool:g_Status[ 33 ]
- new bool:changeMap
- new bool:g_AdminStart // Vote Menu On
- new bool:g_VoteOff // Vote Menu Off
- new bool:g_HasVote // The vote map will start in Next Map
- new bool:g_Started // The VoteMap has already started
- new bool:g_DontVote // the next map: ^"^4%s^1^"
- new bool:g_WaitVote // Wait voting ends
- new bool:g_AutoVote // Currently active voting
- new bool:g_VoteStarted // public MTimer()
- new bool:g_AdminVote // You can not turn on the ^4VoteMap^1 will try to map
- /* New */
- new g_ModIndex[4]
- new g_szKind[ 4 ]
- new Spk[10]
- new g_Map[ 32 ]
- new TimeVote[ 33 ]
- new g_TotalVotes
- new Timers
- new Sum
- new g_szRoundMap
- new g_MTimer
- new g_STimer
- new countnum
- new time_s
- new id
- new const szPrefix[] = "AMXX";
- /* Maps */
- new const g_MapNames[][] =
- {
- // "Map"
- ""
- }
- /* Start Mod */
- public plugin_init()
- {
- register_plugin("VoteMap", "v1.0", "Edited By Michael")
- g_AdminStart = true
- g_VoteOff = false
- g_HasVote = false
- g_Started = false
- g_DontVote = false
- g_WaitVote = false
- g_VoteStarted = true
- g_AutoVote = false
- g_AdminVote = false
- register_clcmd( "say /startvote", "admin");
- register_clcmd( "say !startvote", "admin");
- register_clcmd( "say /nextmap", "NextMap" );
- register_clcmd( "say /nextvote", "ShowTime" );
- register_clcmd( "say /map", "ShowTime" );
- register_clcmd( "say /nm", "NextMap" );
- register_clcmd( "say nextmap", "NextMap" );
- register_clcmd( "say nextvote", "ShowTime" );
- register_clcmd( "say map", "ShowTime" );
- register_clcmd( "say nm", "NextMap" );
- register_clcmd( "say /Status", "cmdGetInfo" );
- register_event( "HLTV", "NewRound", "a", "1=0", "2=0" );
- get_mapname( g_Map, 31 );
- set_task( 0.5, "reset");
- }
- /* Shot Time In Hud */
- public cmdGetInfo(client)
- {
- if(TimeVote[client])
- TimeVote[client] = false;
- else {
- TimeVote[client] = true;
- TimeInHud(client);
- }
- }
- public TimeInHud(client)
- {
- remove_task(client);
- if(TimeVote[client])
- {
- set_hudmessage(255, 85, 0, 0.0, 0.93, 0, 6.0, 1.5)
- if( g_HasVote )
- {
- show_hudmessage(client, "The vote map will start in Next Map");
- }
- if( g_Started )
- {
- return show_hudmessage(client, "The VoteMap has already started.");
- }
- else
- {
- show_hudmessage(client, "VoteMap Will Be Start In More: %i.%i minutes.",g_MTimer,g_STimer);
- }
- set_task(1.0, "TimeInHud", client)
- }
- return PLUGIN_CONTINUE;
- }
- /* New Round */
- public NewRound()
- if( changeMap )
- {
- new Winner = 0;
- for( new i = 0; i < sizeof g_ModIndex; i++ )
- {
- if( g_szKind[ Winner ] < g_szKind[ i ])
- Winner = i;
- }
- set_task( 6.0, "changemap_", _, g_MapNames[ g_ModIndex[ Winner ] ], 30 )
- ColorChat( 0, "The next map will be ^4%s^1.", g_MapNames[ g_ModIndex[ Winner ] ] );
- set_task(1.0, "countdown", DMAP_TASKID_COUNTDOWN, "", 0, "a", 6);
- client_cmd(0, "speak ^"loading environment on to your computer^"");
- changeMap = false;
- }
- public countdown() {
- new Winner = 0;
- for( new i = 0; i < sizeof g_ModIndex; i++ )
- {
- if( g_szKind[ Winner ] < g_szKind[ i ])
- Winner = i;
- }
- new players[32], inum, i;
- get_players(players, inum, "c");
- for (i = 0; i < inum; ++i) {
- if(is_user_connected(players[i]))
- {
- message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, players[i])
- write_short(1<<10)
- write_short(1<<10)
- write_short(0x0000)
- write_byte(0)
- write_byte(0)
- write_byte(0)
- write_byte(255)
- message_end()
- }
- }
- countnum++;
- set_hudmessage(150, 120, 0, -1.0, 0.3, 0, 0.5, 1.1, 0.1, 0.1);
- show_hudmessage(0, "Next Map: %s ^nTime To Change The Map: %i", g_MapNames[ g_ModIndex[ Winner ] ], 5 - countnum);
- return PLUGIN_HANDLED;
- }
- /* Admin Start Vote */
- public admin( iPlayer )
- {
- if( !( get_user_flags( iPlayer ) & ADMIN_IMMUNITY ) )
- {
- ColorChat( iPlayer, "You have no access to this ^4command^1." );
- }
- if(g_AdminStart)
- {
- ColorChat(0, "ADMIN: ^3%s^1 Started ^4VoteMap", GetName(iPlayer))
- set_task(0.0, "Admin_TimeLeft")
- set_task(10.0, "RandomItem")
- set_task(10.0, "Sound")
- time_s = 10
- g_VoteStarted = false
- TimeVote[iPlayer] = false
- }
- if(g_VoteOff)
- ColorChat( iPlayer, "The^3 VoteMap^1 has already^4 started^1.")
- if(g_AutoVote) {
- ColorChat( iPlayer, "Currently active voting")
- }
- if(g_AdminVote)
- ColorChat( iPlayer, "You can not turn on the ^4VoteMap^1 will try to map")
- return PLUGIN_HANDLED;
- return PLUGIN_CONTINUE
- }
- public Admin_TimeLeft()
- {
- num_to_word(time_s, Spk, charsmax(Spk));
- client_cmd(0, "spk vox/%s", Spk);
- set_hudmessage(255, 255, 255, -1.0, 0.12, 0, 0.02, 1.0, 0.01, 0.1, 10);
- show_hudmessage(0, "Admin Started^nVoteMap Will be Start In More ^"%i^" Seconds", time_s);
- if(time_s >= 1)
- {
- set_task(1.0, "Admin_TimeLeft")
- }
- --time_s;
- g_Started = true
- g_VoteOff = true
- g_AdminStart = false
- g_WaitVote = true
- }
- /* Timers */
- public reset()
- {
- g_MTimer = 0;
- g_STimer = 60;
- set_task( 60.0, "MTimer");
- set_task( 1.0, "STimer" );
- TimeVote[id] = false
- }
- public MTimer()
- {
- if(g_VoteStarted)
- {
- if(g_MTimer <= 0)
- {
- set_task(1.0, "TimeLeft")
- g_MTimer = 0
- }
- time_s = 10
- set_task( 60.0, "MTimer");
- set_task(10.0, "RandomItem")
- set_task(10.0, "Sound")
- }
- }
- public STimer(id)
- {
- g_STimer--
- if(g_STimer <= 0)
- {
- g_MTimer--
- g_STimer = 60
- }
- set_task( 1.0, "STimer", id );
- }
- public TimeLeft()
- {
- num_to_word(time_s, Spk, charsmax(Spk));
- client_cmd(0, "spk vox/%s", Spk);
- set_hudmessage(255, 255, 255, -1.0, 0.12, 0, 0.02, 1.0, 0.01, 0.1, 10);
- show_hudmessage(0, "VoteMap Will be Start In More ^"%i^" Seconds", time_s);
- if(time_s >= 1)
- {
- set_task(1.0, "TimeLeft")
- }
- --time_s;
- g_VoteOff = false
- g_AutoVote = true
- g_Started = true
- g_AdminStart = false
- g_WaitVote = true
- }
- public Sound()
- {
- client_cmd(0, "spk Gman/Gman_Choose2");
- }
- public ShowTime( id )
- {
- if( g_Started )
- return ColorChat(id, "The^3 VoteMap^1 has already^4 started^1.")
- if( g_HasVote )
- {
- ColorChat( id, "The vote map will start in ^4Next Map");
- }
- else
- {
- ColorChat( id, "The vote map will start in^4 %i.%i^1 minutes.",g_MTimer,g_STimer);
- }
- }
- public NextMap( id )
- {
- new Winner = 0;
- for( new i = 0; i < sizeof g_ModIndex; i++ )
- {
- if( g_szKind[ Winner ] < g_szKind[ i ])
- Winner = i;
- }
- if( g_DontVote )
- {
- ColorChat( id, "the next map: ^"^4%s^1^"", g_MapNames[ g_ModIndex[ Winner ] ]);
- }
- if( g_WaitVote )
- {
- ColorChat( id, "Wait voting ends");
- }
- else
- {
- ColorChat( id, "the next map: ^"^4Dont Selected^1^"");
- }
- }
- public Time()
- {
- g_szRoundMap == 9 ? set_task( 0.1, "RandomItem" ) : set_task( 0.6, "ShowTime" );
- }
- public RandomItem()
- {
- new count, bitsum;
- while ( count < sizeof g_ModIndex ) {
- new randomnum = random(sizeof g_MapNames);
- if ( ! ( bitsum & (1 << randomnum) ) ) {
- g_ModIndex[count++] = randomnum;
- bitsum |= (1 << randomnum);
- }
- }
- Timers = 21
- Timer()
- for (new i = 1; i <= get_maxplayers(); i++)
- {
- dddVote(i)
- g_Voted[i] = false
- }
- g_VoteStarted = false
- g_VoteOff = true
- g_AutoVote = false
- g_TotalVotes = 0;
- }
- public Timer()
- {
- if(Timers == 0)
- {
- checkvotesd( )
- return PLUGIN_HANDLED;
- }
- Timers--;
- set_task( 1.0, "Timer" );
- for (new i = 1; i <= get_maxplayers(); i++)
- {
- dddVote(i)
- Voted[id] = false;
- g_Status[id] = false;
- }
- return PLUGIN_CONTINUE
- }
- /* Vote Menu */
- public dddVote( client )
- {
- new strFunc[ 3 ]
- static szMap[ 200 ]
- formatex( szMap, charsmax( szMap ), "\r// \wStatus: %s \w| \w| Players Voted: \r%d|%d^n\r// \wTime to choose: \y%i Sec \w| Status Vote Now: %s",
- Voted[client] ? "\yVoted" : "\rNot Voted", // Status
- g_TotalVotes, get_playersnum(), // Players Voted
- Timers,// Timers
- g_Status[client] ? "\rOff" : "\yOn") // Status Vote
- new szMenu = menu_create( szMap, "handlerdddd")
- for( new k = 0; k < MAX_MAPS; k++ ) // show selected maps + votes
- {
- num_to_str( k, strFunc, 2 )
- formatex(szMap, charsmax( szMap ), "%s\r -\d (\y%i Votes\d)", g_MapNames[g_ModIndex[ k ]], g_szKind[ k ])
- menu_additem( szMenu, szMap, strFunc )
- }
- menu_setprop( szMenu, MPROP_EXIT, MEXIT_NEVER )
- menu_display( client, szMenu )
- }
- public handlerdddd( client, menu, item )
- {
- if( Voted[ client ] == true )
- {
- dddVote( client );
- return
- }
- ColorChat( 0, "^3%s^1 has voted for^4 %s^1", GetName(client), g_MapNames[g_ModIndex[ item ]])
- if( !g_Vote[ client ] )
- {
- g_Vote[ client ] = true;
- g_szKind[item]++;
- Sum++;
- }
- client_cmd (0, "spk sound/buttons/lightswitch2.wav" )
- g_Voted[ client ] = true
- Voted[client] = true
- g_Status[client] = true
- g_WaitVote = true
- g_TotalVotes += 1
- dddVote( client );
- return;
- }
- /* Check Vote */
- public checkvotesd( )
- {
- new players[ 32 ], num, iPlayer;
- get_players( players, num, "ach" );
- for( new i; i < num; i++ )
- {
- iPlayer = players[ i ];
- remove_task( iPlayer );
- show_menu( iPlayer, 0, "^n", 1 );
- show_menu( iPlayer, 0, "^n", 1 );
- set_task( 0.1, "DestroyMenu", iPlayer );
- }
- new Winner = 0;
- for( new i = 0; i < sizeof g_ModIndex; i++ )
- {
- if( g_szKind[ Winner ] < g_szKind[ i ])
- Winner = i;
- }
- set_hudmessage(random(255), random(255), random(255), -1.0, 0.26, 2, 6.0, 12.0)
- show_hudmessage(0, "The map %s Won^nLast Round", g_MapNames[ g_ModIndex[ Winner ] ])
- ColorChat( 0, "The map ^4%s ^1won, the map will be changed in the next round.", g_MapNames[ g_ModIndex[ Winner ] ] );
- changeMap = true;
- g_HasVote = true
- g_DontVote = true
- g_AdminStart = false
- g_Started = false
- g_VoteOff = false
- g_WaitVote = false
- g_AdminVote = true
- }
- /* ChangeLevel */
- public changemap_( param[] )
- {
- server_cmd("changelevel %s", param)
- }
- /* Destroy Menu */
- public DestroyMenu( client )
- {
- show_menu( client, 0, "^n", 1 );
- }
- /* Name */
- public GetName(id)
- {
- new szName[ 32 ];
- get_user_name( id, szName, 31 )
- return szName;
- }
- /* Color Chat */
- stock ColorChat( const client, const string[ ], { Float, Sql, Resul, _ } :... )
- {
- new msg[ 191 ], players[ 32 ], count = 1;
- static len; len = formatex( msg, charsmax(msg), "^4[^1%s^4]^1 ", szPrefix );
- 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( );
- }
- }
- }
Add Comment
Please, Sign In to add comment