AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Knife round vote (https://forums.alliedmods.net/showthread.php?t=229162)

niiii 11-02-2013 13:42

Knife round vote
 
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();
}


akcaliberg 11-02-2013 17:26

Re: Knife round vote
 
this section is not for requesting.

Shooting King 11-03-2013 02:48

Re: Knife round vote
 
PHP Code:

/******************************************************************************
 * 
 *                     Knife Mod Vote
 *                                 - Shooting King
 *  
 *             Cmds:
 *                     - say /voteknife - Start Vote.
 * 
 * ***************************************************************************/
 
#include <amxmodx>

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

#define VOTE_LEVEL    ADMIN_LEVEL_H

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

new 
bool:g_VotedForMap;
new 
bool:bKnifeRound false;
new 
bool:bKnifeOnly false;

public 
plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_clcmd"say /voteknife""StartVote" );
    
register_event"HLTV""Event_NewRound""a""1=0""2=0" );
    
register_event"CurWeapon""Event_Weapon""be""1=1" );
}

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;
    
    if( 
bKnifeRound )
    {
        
bKnifeOnly true;
        
bKnifeRound false;
    }
}

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

public 
StartVoteid )
{
    if( !(
get_user_flags(id) & VOTE_LEVEL) )
    {
        
client_printidprint_chat"You dont have access to this command." );
        return 
PLUGIN_HANDLED;
    }
    
    if( 
g_Voting )
    {
        
client_printidprint_chat"Voting is already going on." );
        return 
PLUGIN_HANDLED;
    }
        
    if( 
g_VotedForMap )
    {
        
client_printidprint_chat"Voting for this Map is Done." );
        return 
PLUGIN_HANDLED;
    }
    
    
g_VotedForMap true;
        
    new 
szPlayers[32], szName[32], iNumiPlayer;
    
get_user_nameidszNamecharsmax(szName));
    
client_print0print_chat"%s started the vote."szName );
    
    
g_Votes[0] = g_Votes[1] = 0;
    
g_VoteMenu menu_create"\rKnife Round ?? :""menu_handler" );
    
    
menu_additemg_VoteMenu"Yes""");
    
menu_additemg_VoteMenu"No""");
    
    
get_playersszPlayersiNum );

    for( new 
iiNumi++ )
    {
        
iPlayer szPlayers[i];
        
menu_displayiPlayerg_VoteMenu);
        
g_Voting++;
    }

    
set_task(10.0"EndVote" );
    return 
PLUGIN_HANDLED;
}
 
public 
menu_handleridmenuitem )
{
    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(0print_chat"Next Round will be a Knife Round." );
        
bKnifeRound true
    }        
    else 
    {
        
client_print(0print_chat"Voting Failed." );
    }

    
menu_destroyg_VoteMenu );
    for( new 
i33i++ )
    {
        
g_Voted[i][0] = 0;
        
g_Voted[i][1] = 0;
    }
    
g_Voting 0;
}

stock FixAmmoHud(id)
{
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("CurWeapon"), { 00}, id); 
    
write_byte(1);
    
write_byte(29);
    
write_byte(-1);
    
message_end();


Translate it if you want. I am poor in Slovak.

niiii 11-03-2013 06:27

Re: Knife round vote
 
Quote:

Originally Posted by akcaliberg (Post 2056161)
this section is not for requesting.

Im looking for a help... even this forums name is Scripting help...

niiii 11-03-2013 06:29

Re: Knife round vote
 
Quote:

Originally Posted by Shooting King (Post 2056305)
PHP Code:

/******************************************************************************
 * 
 *                     Knife Mod Vote
 *                                 - Shooting King
 *  
 *             Cmds:
 *                     - say /voteknife - Start Vote.
 * 
 * ***************************************************************************/
 
#include <amxmodx>

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

#define VOTE_LEVEL    ADMIN_LEVEL_H

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

new 
bool:g_VotedForMap;
new 
bool:bKnifeRound false;
new 
bool:bKnifeOnly false;

public 
plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_clcmd"say /voteknife""StartVote" );
    
register_event"HLTV""Event_NewRound""a""1=0""2=0" );
    
register_event"CurWeapon""Event_Weapon""be""1=1" );
}

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;
    
    if( 
bKnifeRound )
    {
        
bKnifeOnly true;
        
bKnifeRound false;
    }
}

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

public 
StartVoteid )
{
    if( !(
get_user_flags(id) & VOTE_LEVEL) )
    {
        
client_printidprint_chat"You dont have access to this command." );
        return 
PLUGIN_HANDLED;
    }
    
    if( 
g_Voting )
    {
        
client_printidprint_chat"Voting is already going on." );
        return 
PLUGIN_HANDLED;
    }
        
    if( 
g_VotedForMap )
    {
        
client_printidprint_chat"Voting for this Map is Done." );
        return 
PLUGIN_HANDLED;
    }
    
    
g_VotedForMap true;
        
    new 
szPlayers[32], szName[32], iNumiPlayer;
    
get_user_nameidszNamecharsmax(szName));
    
client_print0print_chat"%s started the vote."szName );
    
    
g_Votes[0] = g_Votes[1] = 0;
    
g_VoteMenu menu_create"\rKnife Round ?? :""menu_handler" );
    
    
menu_additemg_VoteMenu"Yes""");
    
menu_additemg_VoteMenu"No""");
    
    
get_playersszPlayersiNum );

    for( new 
iiNumi++ )
    {
        
iPlayer szPlayers[i];
        
menu_displayiPlayerg_VoteMenu);
        
g_Voting++;
    }

    
set_task(10.0"EndVote" );
    return 
PLUGIN_HANDLED;
}
 
public 
menu_handleridmenuitem )
{
    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(0print_chat"Next Round will be a Knife Round." );
        
bKnifeRound true
    }        
    else 
    {
        
client_print(0print_chat"Voting Failed." );
    }

    
menu_destroyg_VoteMenu );
    for( new 
i33i++ )
    {
        
g_Voted[i][0] = 0;
        
g_Voted[i][1] = 0;
    }
    
g_Voting 0;
}

stock FixAmmoHud(id)
{
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("CurWeapon"), { 00}, id); 
    
write_byte(1);
    
write_byte(29);
    
write_byte(-1);
    
message_end();


Translate it if you want. I am poor in Slovak.

thank you, all of those people should be like you :)

YamiKaitou 11-04-2013 08:51

Re: Knife round vote
 
Quote:

Originally Posted by niiii (Post 2056352)
Im looking for a help... even this forums name is Scripting help...

This section is for people who have tried it themselves but are having problems.


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

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