Raised This Month: $51 Target: $400
 12% 

Opening menu in certain round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 04-13-2020 , 10:34   Opening menu in certain round
Reply With Quote #1

Hi,

I made this code to open a menu in a specific round:
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fun >
#include < hamsandwich >

#define MAX_PLAYERS 32 + 1
new round[33]
new 
cvar_open_round

public plugin_init( )
{
    
register_plugin"New Plugin""1.0""Author" )
    
    
cvar_open_round register_cvar"menu_open_round""1" )
    
    
RegisterHamHam_Spawn"player""Ham_Player_Spawn"
}

public 
client_connectedid )
{
    
roundid ] = 0
}

public 
newRound( )
{
    for(new 
0MAX_PLAYERSi++)
    {
        
round] ++;
    }
}

public 
custom_menuid )
{
    new 
Temp[64]
    
formatexTempcharsmax(Temp), "\wChoose your \rWeapons" )
    new 
szMenu menu_createTemp"custom_menu_handler" )
    
menu_additemszMenu"Gun Nr.1""1" )
    
menu_additemszMenu"Gun Nr.2""2" )
    
menu_additemszMenu"Gun Nr.3""3" )
    
    
menu_displayidszMenu)
}

public 
custom_menu_handleridszMenuitem )
{
    if( 
item == MENU_EXIT || !is_user_aliveid ) )
        return 
1
        
    
switch( item )
    {
        case 
0:
        {
            
//do some stuff
        
}
        case 
1:
        {
            
//do some stuff
        
}
        case 
2:
        {
            
//do some stuff
        
}
    }
    
    return 
1
}

public 
Ham_Player_Spawnid )
{
    if( !
is_user_aliveid ) )
        return 
1
        
    
if( get_pcvar_numcvar_open_round ) == 1)
    {
        if( 
roundid ] >= 3
            
custom_menuid );
        
        
roundid ] ++;    
    }
    
    return 
1

The problem is when player spawn second time, it opens the menu.
Where did I wrong?
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 04-13-2020 , 12:05   Re: Opening menu in certain round
Reply With Quote #2

newRound() never gets called.
__________________
gabuch2 is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 04-13-2020 , 12:28   Re: Opening menu in certain round
Reply With Quote #3

Updated the code still nothing:
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fun >
#include < hamsandwich >

#define MAX_PLAYERS 32 + 1

new round[33]
new 
cvar_open_round

public plugin_init( )
{
    
register_plugin"New Plugin""1.0""Author" )
    
    
cvar_open_round register_cvar"menu_open_round""1" )

    
register_event("HLTV""newRound""a""1=0""2=0");

    
RegisterHamHam_Spawn"player""Ham_Player_Spawn"
}

public 
client_connectedid )
{
    
roundid ] = 0
}

public 
newRound( )
{
    for(new 
0MAX_PLAYERSi++)
    {
        
round] ++;
    }
}

public 
custom_menuid )
{
    new 
Temp[64]
    
formatexTempcharsmax(Temp), "\wChoose your \rWeapons" )
    new 
szMenu menu_createTemp"custom_menu_handler" )
    
menu_additemszMenu"Gun Nr.1""1" )
    
menu_additemszMenu"Gun Nr.2""2" )
    
menu_additemszMenu"Gun Nr.3""3" )
    
    
menu_displayidszMenu)
}

public 
custom_menu_handleridszMenuitem )
{
    if( 
item == MENU_EXIT || !is_user_aliveid ) )
        return 
1
        
    
switch( item )
    {
        case 
0:
        {
            
//do some stuff
        
}
        case 
1:
        {
            
//do some stuff
        
}
        case 
2:
        {
            
//do some stuff
        
}
    }
    
    return 
1
}

public 
Ham_Player_Spawnid )
{
    if( !
is_user_aliveid ) )
        return 
1
        
    
if( get_pcvar_numcvar_open_round ) == 1)
    {
        if( 
roundid ] >= 3
            
custom_menuid );
        
        
roundid ] ++;    
    }
    
    return 
1

__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-14-2020 , 12:49   Re: Opening menu in certain round
Reply With Quote #4

suggestion 1: count spawns instead of rounds. players spawn once per round anyway and this way you add support for csdm too.
suggestion 2: use the cvar as a setting for after how many spawns the player will see the menu.
suggestion 3: add a command to manually access the menu in case the player accidentally closes it on automatic show
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Reply



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 03:27.


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