RAAASENGAN
Join Date: Mar 2012
Location: India
|
07-25-2013
, 09:11
Re: [REQ] Respawn Mod vote at the map beginning
|
#2
|
Respawn Mod Vote
PHP Code:
#include <amxmodx>
#define PLUGIN "Respawn Mod Vote" #define VERSION "1.5" #define AUTHOR "Shooting King"
new gizRound = 0; new gizVoting; new gizVoteMenu; new gizVotes[2];
new pcvar_round; new pcvar_voteetime; new pcvar_voterestime; new pcvar_revote; new pcvar_loop; new pcvar_hname;
public plugin_init() { register_plugin( PLUGIN, VERSION, AUTHOR ); register_logevent("Event_Roundstart", 2, "1=Round_Start"); register_event( "TextMsg", "ResetValues", "a", "2&#Game_will_restart_in", "2&#Game_Commencing" );
pcvar_round = register_cvar( "amx_sk_round", "3" ); pcvar_voteetime = register_cvar( "amx_sk_vote_endtime", "20" ); pcvar_voterestime = register_cvar( "amx_sk_vote_restarttime", "10" ); pcvar_revote = register_cvar( "amx_sk_vote_restart", "1" ); pcvar_loop = register_cvar( "amx_sk_vote_loop", "0" ); pcvar_hname = register_cvar( "amx_sk_sv_name", "Shooting King's Pro Server" ); }
public Event_Roundstart() { gizRound++; if( gizRound == get_pcvar_num(pcvar_round)) { StartVote(); if(get_pcvar_num(pcvar_loop)) { gizRound = 0; } } }
public StartVote() { if( gizVoting ) { client_print( 0, print_chat, "There is already a vote going." ); return PLUGIN_HANDLED; } gizVotes[0] = 0; gizVotes[1] = 0; gizVoteMenu = menu_create( "\r[Public Mod] Do you want to enable Respawn Mod?", "menu_handler" );
menu_additem( gizVoteMenu, "Yes", "", 0 ); menu_additem( gizVoteMenu, "No", "", 0 ); new szPlayers[32], iNum, iPlayer, i; get_players( szPlayers, iNum );
for( i = 0; i < iNum; i++ ) { iPlayer = szPlayers[i]; menu_display( iPlayer, gizVoteMenu, 0 ); } gizVoting++;
set_task(get_pcvar_float(pcvar_voteetime), "EndVote" ); return PLUGIN_HANDLED; }
public menu_handler( id, menu, item ) { if( item == MENU_EXIT || !gizVoting ) { return PLUGIN_HANDLED; } gizVotes[item]++; new szPlayer[33]; get_user_name(id, szPlayer, charsmax(szPlayer)); client_print(0, print_chat, "%s choose %s", szPlayer, item); return PLUGIN_HANDLED; }
public EndVote() { if( gizVotes[0] > gizVotes[1] ) { client_print(0, print_chat, "Respawn Mod (%d) of votes, Its Enabled", gizVotes[0] ); set_cvar_num( "amx_respawn_on", 1 ); MsgServerName(); } else if( gizVotes[0] < gizVotes[1] ) { client_print(0, print_chat, "Respawn Mod is Disabled with (%d) of votes", gizVotes[1] ); set_cvar_num( "amx_respawn_on", 0 ); } else { client_print(0, print_chat, "The vote tied at %d votes each, Vote will start again in %d seconds", gizVotes[0], get_pcvar_num(pcvar_voterestime) ); if(get_pcvar_num(pcvar_revote)) { set_task(get_pcvar_float(pcvar_voterestime), "StartVote" ); } } menu_destroy( gizVoteMenu ); gizVoting = 0; }
public MsgServerName() { new szHName[64]; get_pcvar_string(pcvar_hname , szHName, 64);
message_begin(MSG_BROADCAST, get_user_msgid("ServerName")); write_string(szHName); message_end(); }
public ResetValues() { gizRound = 0; gizVoting = 0; gizVoteMenu = 0; gizVotes[0] = 0; gizVotes[1] = 0; }
Cvars:
Time is Seconds.
amx_sk_round - How many rounds after should the vote start ? Default: 3
amx_sk_vote_endtime - How much time should the vote prolong ? Default: 20
amx_sk_vote_restart - If the vote has been tied, should the vote restart ? Default: 1
amx_sk_vote_restarttime - If the vote has been tied, After how much time should the vote begin ? Default:10
amx_sk_vote_loop - Do you want to loop vote ? If set to 1 the vote loops for every amx_sk_round cvar's rounds. Default: 0
amx_sk_sv_name - What name do you want to set to your server after Respawn Mod is enabled.
Note:
1. Don't forget to change or else ..
__________________
Last edited by Shooting King; 07-27-2013 at 11:39.
|
|