AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   New map (https://forums.alliedmods.net/showthread.php?t=143230)

LostSkill 11-16-2010 13:32

New map
 
How i could make vote when new map start's. After one minute players get vote : Do u whana HS mode? and if yes its turn on cvar aim_prac 1 if no then 0

fysiks 11-16-2010 20:36

Re: New map
 
set a task in plugin_ini() to the function that puts up the vote. If the result is yes then set the cvar to 1 else 0.

GXLZPGX 11-16-2010 21:21

Re: New map
 
Quote:

Originally Posted by fysiks (Post 1350969)
set a task in plugin_ini() to the function that puts up the vote. If the result is yes then set the cvar to 1 else 0.

"LostSkill: can u please show example?"

fysiks 11-16-2010 23:54

Re: New map
 
PHP Code:

public plugin_init()
{
    
// ...
    
set_task(60.0"start_vote_function")
}

public 
start_vote_function()
{
    
// start vote / show menu here.  See link.


http://forums.alliedmods.net/showthread.php?t=46364

If your "Yes" option wins use set_cvar_num("aim_prac", 1).

Quote:

Originally Posted by GXLZPGX (Post 1350988)
"LostSkill: can u please show example?"

Where was this? Just curious.

ARES[ro] 11-16-2010 23:56

Re: New map
 
Quote:

Originally Posted by GXLZPGX (Post 1350988)
"LostSkill: can u please show example?"

Impersonator! Watch out trying steal your identity!
Nib,its not fooling me...

LostSkill 11-17-2010 04:28

Re: New map
 
PHP Code:

#include <amxmodx>
#include <fun>

new gVoteMenu;
new 
gVotes[2];
new 
gVoting;

public 
plugin_init() 

    
register_plugin("Vote Hs mode","1.0","James Romeril")
    
register_concmd("aim_prac""aim_prac"ADMIN_LEVEL_A"aim_prac <on|off> or <1|0>")
    
set_task(60.0"hs_mode"


public 
aim_prac(id)
{
    if (
id && !((get_user_flags(id) & ADMIN_LEVEL_A)))
    {
        
client_print(idprint_console"[AMXX] You do not have access to this command")
        return 
PLUGIN_CONTINUE
    
}
    new 
arg[8]
    
read_argv(1arg7)

    if((
equali(arg"on"))||(equali(arg"1")))
    {
        
set_user_hitzones(,02)
        
client_print(idprint_console"[AMXX] ENABLED Headshot only mode")
        
client_print(0print_chat"[AMXX] ENABLED Headshot only mode")
    }
    else
    {
        
set_user_hitzones(00255)
        
client_print(idprint_console"[AMXX] DISABLED Headshot only mode")
        
client_print(0print_chat"[AMXX] DISABLED Headshot only mode")
    }
    return 
PLUGIN_HANDLED
}

public 
hs_mode(id

    
gVoteMenu menu_create("\rIjunkti HS moda?""menu_handler");

    
menu_additem(gVoteMenu"Taip""0"0);
    
menu_additem(gVoteMenu"Ne""1"0); 
    
    new 
players[32], pnumtempid;
    
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i];

        
menu_display(tempidgVoteMenu0);

        
gVoting++;
    }

    
set_task(15.0"EndVote");

    return 
PLUGIN_HANDLED;


public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT || !gVoting )
    {
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);

    new 
voteid str_to_num(data);

    
gVotes[voteid]++;

    return 
PLUGIN_HANDLED;
}

public 
EndVote()
{
    if( 
gVotes[0] > gVotes[1] )
    
client_print(0print_chat"Uz TAIP balsavo (%d) dabar bus ijunktas hs mode"gVotes[0] );
    
set_cvar_num("aim_prac"1)
    else if( 
gVotes[0] < gVotes[1] )
    
client_print(0print_chat"Uz NE balsavo (%d) todel HS mode nebus ijunktas"gVotes[1] );
    
set_cvar_num("aim_prac"0)
    else
    
client_print(0print_chat"Buvo lygiosios %d todel nebus ijunktas HS mode."gVotes[0] );
    
set_cvar_num("aim_prac"0);
    
    
menu_destroy(gVoteMenu);

    
gVoting 0;


After this:
PHP Code:

set_cvar_num("aim_prac"1

I lose identification on this line and compile fails :\
PHP Code:

else if( gVotes[0] < gVotes[1] ) 


ARES[ro] 11-17-2010 09:24

Re: New map
 
PHP Code:

if( gVotes[0] > gVotes[1] ) 
{
    
client_print(0print_chat"Uz TAIP balsavo (%d) dabar bus ijunktas hs mode"gVotes[0] ); 
    
set_cvar_num("aim_prac"1
}
else if( 
gVotes[0] < gVotes[1] ) 
{
    
client_print(0print_chat"Uz NE balsavo (%d) todel HS mode nebus ijunktas"gVotes[1] ); 
    
set_cvar_num("aim_prac"0
}
else 
{
    
client_print(0print_chat"Buvo lygiosios %d todel nebus ijunktas HS mode."gVotes[0] ); 
    
set_cvar_num("aim_prac"0);


NOTE: When theres more then one instructions use brackets... Without brackets it will only take in count the first line.In your case it failed to compile.


All times are GMT -4. The time now is 11:25.

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