Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #define VERSION "0.1"
- enum{
- NORMAL,
- BOOST,
- TASK_VOTE = 1337
- };
- new g_iVotes[2 * BOOST] = 0;
- new bool:g_bVotedAlready[33] = false;
- new pCvarGameStyleCommand, pCvarVoteDelay, pCvarVoteTime;
- new g_iVoteTimer;
- public plugin_init() {
- register_plugin("Game Style Vote", VERSION, "diablix")
- register_menucmd(register_menuid("VoteMenu"), 1023, "handleVoteMenu");
- pCvarGameStyleCommand = register_cvar("vote_command", "hns_semiclip");
- pCvarVoteDelay = register_cvar("vote_delay", "120");
- pCvarVoteTime = register_cvar("vote_time", "30");
- g_iVoteTimer = get_pcvar_num(pCvarVoteTime);
- }
- public plugin_cfg()
- set_task(float(get_pcvar_num(pCvarVoteDelay)), "taskBegin");
- public taskBegin()
- set_task(1.0, "taskVote", TASK_VOTE, _, _, "a", get_pcvar_num(pCvarVoteTime));
- public taskVote(){
- g_iVoteTimer --;
- set_hudmessage(85, 255, 85, 0.0, 0.18, 0, 1.2, 1.2, 0.1, 0.1, 4);
- show_hudmessage(0, "%d seconds left to begin the vote!", g_iVoteTimer);
- new iPlayers[32], iNum;
- get_players(iPlayers, iNum);
- for(new i ; i < iNum ; i ++){
- showVoteMenu(iPlayers[i]);
- }
- if(g_iVoteTimer == 1){
- g_iVoteTimer = 0;
- remove_task(TASK_VOTE);
- set_hudmessage(85, 255, 85, 0.0, 0.18, 0, 6.2, 6.2, 1.1, 1.1, 4);
- show_hudmessage(0, "Game Style changed to %s !", g_iVotes[BOOST] >= g_iVotes[NORMAL] ? "boost" : "normal");
- new s_pCvarString[32];
- get_pcvar_string(pCvarGameStyleCommand, s_pCvarString, sizeof s_pCvarString - 1);
- set_cvar_num(s_pCvarString, g_iVotes[BOOST] >= g_iVotes[NORMAL] ? 0 : 1);
- }
- }
- public showVoteMenu(id){
- new szMenuBody[256], iLen, bit_Keys;
- iLen = formatex(szMenuBody, sizeof szMenuBody -1, "[HNS]\y Pick Game Style^n\y %d\w seconds left", g_iVoteTimer);
- iLen += formatex(szMenuBody[iLen], sizeof szMenuBody -1, "^n^n\r1. \wBoost\r |\w Votes :\y %d", g_iVotes[BOOST]);
- iLen += formatex(szMenuBody[iLen], sizeof szMenuBody -1, "^n\r2. \wNormal\r |\w Votes :\y %d", g_iVotes[NORMAL]);
- bit_Keys = (1<<0)|(1<<1);
- show_menu(id, bit_Keys, szMenuBody, -1, "VoteMenu");
- return 1;
- }
- public handleVoteMenu(id, iKey){
- if(!g_bVotedAlready[id]){
- g_iVotes[iKey] ++;
- client_print(id, 3, "You voted for %s game style.", iKey == BOOST ? "boost" : "normal");
- g_bVotedAlready[id] = !g_bVotedAlready[id];
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement