Raised This Month: $ Target: $400
 0% 

Knife round vote


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
niiii
Member
Join Date: Sep 2013
Old 11-02-2013 , 13:42   Knife round vote
Reply With Quote #1

Hi, i have installed this plugin on my server which allows vip players to use command /voteknife that starts knife round if players voted for. Id like to modify this plugin that you can you /voteknife command only 1 per map... thanks

Code:
/****************************************************************************** 
 *  
 *                     Knife Mod Vote 
 *                                 - Shooting King 
 *  
 *             Cvars: 
 *                     - amx_sk_kvote_rounds - After how many rounds can the voting be started. Default: 10 
 *  
 *             Cmds: 
 *                     - say /voteknife - Start Vote. 
 *  
 * ***************************************************************************/ 
  
#include <amxmodx> 

#define PLUGIN        "Knife Mod Vote" 
#define VERSION        "1.0" 
#define AUTHOR        "Shooting King" 

#define VOTE_LEVEL    ADMIN_LEVEL_H

new g_VoteMenu; 
new g_Voting; 
new g_VoteTimes; 
new g_VoteRounds; 
new g_Votes[2]; 
new g_Voted[33][2]; 

new pcvar_rounds; 

new bool:bKnifeRound = false; 
new bool:bKnifeOnly = false; 

public plugin_init() 
{ 
    register_plugin( PLUGIN, VERSION, AUTHOR ); 
     
    register_clcmd( "say /voteknife", "StartVote" ); 
    register_event( "HLTV", "Event_NewRound", "a", "1=0", "2=0" ); 
    register_event( "CurWeapon", "Event_Weapon", "be", "1=1" ); 
     
    pcvar_rounds = register_cvar( "amx_sk_kvote_rounds", "10" ); 
} 

public client_disconnect(id) 
{ 
    if( g_Voted[id][0] ) 
    { 
        g_Votes[g_Voted[id][1]]--; // Do not count his Vote. 
    } 
} 

public Event_NewRound() 
{ 
    bKnifeOnly = false; 
    g_VoteRounds--; 
     
    if( bKnifeRound ) 
    { 
        bKnifeOnly = true; 
        bKnifeRound = false; 
    } 
} 

public Event_Weapon(id) 
{ 
    if( bKnifeOnly && (read_data(2) != CSW_KNIFE)) 
    { 
        engclient_cmd( id, "weapon_knife" ); 
        //if(!is_user_bot(id)) 
        FixAmmoHud(id); 
        return PLUGIN_HANDLED; 
    } 
    return PLUGIN_CONTINUE; 
} 

public StartVote( id ) 
{ 
    if( !(get_user_flags(id) & VOTE_LEVEL) ) 
    { 
        client_print( id, print_chat, "Musis byt VIP." ); 
        return PLUGIN_HANDLED; 
    } 
     
    if( g_Voting ) 
    { 
        client_print( id, print_chat, "Hlasovanie prave prebieha." ); 
        return PLUGIN_HANDLED; 
    } 
         
    if( g_VoteRounds > 0 ) 
    { 
        client_print( id, print_chat, "Musis pockat %d kolo.", g_VoteRounds ); 
        return PLUGIN_HANDLED; 
    } 
     
    g_VoteRounds = get_pcvar_num( pcvar_rounds );     
         
    new szPlayers[32], szName[32], iNum, iPlayer; 
    get_user_name( id, szName, charsmax(szName)); 
    client_print( 0, print_chat, "%s spustil hlasovanie.", szName ); 
     
    g_Votes[0] = g_Votes[1] = 0; 
    g_VoteMenu = menu_create( "\rChcete dalsie kolo na noze?", "menu_handler" ); 
     
    menu_additem( g_VoteMenu, "Ano", "", 0 ); 
    menu_additem( g_VoteMenu, "Nie", "", 0 ); 
     
    get_players( szPlayers, iNum ); 

    for( new i; i < iNum; i++ ) 
    { 
        iPlayer = szPlayers[i]; 
        menu_display( iPlayer, g_VoteMenu, 0 ); 
        g_Voting++; 
    } 

    set_task(10.0, "EndVote" ); 
    g_VoteTimes--; 
    return PLUGIN_HANDLED; 
} 
  
public menu_handler( id, menu, item ) 
{ 
    if( item == MENU_EXIT || !g_Voting ) 
    { 
        return PLUGIN_HANDLED; 
    } 
     
    g_Voted[id][0] = 1; 
    g_Voted[id][1] = item; 
    g_Votes[item]++; 
    return PLUGIN_HANDLED; 
} 

public EndVote() 
{     
    if( g_Votes[0] > g_Votes[1] ) 
    { 
        client_print(0, print_chat, "Dalsie kolo bude na noze." ); 
        bKnifeRound = true;  
    }         
    else  
    { 
        client_print(0, print_chat, "Hlasovanie neuspesne." ); 
    } 

    menu_destroy( g_VoteMenu ); 
    for( new i; i < 33; i++ ) 
    { 
        g_Voted[i][0] = 0; 
        g_Voted[i][1] = 0; 
    } 
    g_Voting = 0; 
} 

stock FixAmmoHud(id) 
{ 
    message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("CurWeapon"), { 0, 0, 0 }, id);  
    write_byte(1); 
    write_byte(29); 
    write_byte(-1); 
    message_end(); 
}

Last edited by niiii; 11-02-2013 at 13:43.
niiii is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode