AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu help. (https://forums.alliedmods.net/showthread.php?t=156258)

GarbageBox 05-03-2011 13:01

Menu help.
 
If i am using new amxx menu, how can I change the no.8 button to be a values.
When admin press the player's name, increase the player's health by what number is.
Also, its default in the code.
1. XXX
2. XXX
...
8. Add: %s
0. Exit

If you still dont know what exactly I am talking about, I talk it easily.
I am using new amxx menu, and I want 1 to 7 is player's name and the 8 is a choose. Just like the ban menu, when you press it once, it will change the ban time.

JocAnis 05-03-2011 14:18

Re: Menu help.
 
for ~10 mins i will post the code..

SonicSonedit 05-03-2011 14:37

Re: Menu help.
 
Quote:

how can I change the no.8 button to be a values.
You can't. But you can use button 6 for this.

JocAnis 05-03-2011 15:04

Re: Menu help.
 
PHP Code:

#include <amxmodx>
#include <amxmisc>

native set_user_healthindexhealth )

new 
add_hp 10page

public plugin_init() 
{
    
register_plugin"HP Menu""007""amxmodx.org")
    
    
register_clcmd"say /hpmenu""HealthMenu" )
}
public 
HealthMenuid )
{
    new 
p32 ], nplayertempid15 ], name32 ], name_hp120 ], add_keyname30 ], addtext60 ]
    new 
menu menu_create"Health Menu""hp_keys" )
    
    
get_playerspn"c" )
    
    for( new 
zljzlj nzlj++ )
    {
        
player pzlj ]
        
        
num_to_strplayertempid14 )
        
get_user_nameplayernamecharsmaxname ) )
        
        
formatname_hp119"\w%s \d(\w %d\d HP )"nameget_user_healthplayer ) )
        switch( 
player )//dunno this
        
{
            case 
7142128:
            {
                
tempidplayer ] += 1
            
}
        }
        if( 
)
        {
            
addname_hpcharsmaxname_hp ), "^n" )
        }
        
menu_additemmenuname_hptempid 
    }
    
menu_setpropmenuMPROP_PERPAGE)
    
formatadd_keyname29"Add HP:\y %d"add_hp )
    
menu_additemmenuadd_keyname"7" )
    
    
menu_displayidmenupage )
    return 
PLUGIN_HANDLED
}
public 
hp_keysidmenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroymenu )
        return 
PLUGIN_HANDLED
    

    
    new 
data], name64 ];
    new 
accesscallback;
    
menu_item_getinfomenuitemaccessdata5name63callback )

    new 
p_key str_to_numdata )
    
    
HealthMenuid )
    switch( 
p_key )
    {
        case 
7:
        {
            if( 
add_hp 50 )
            {
                
add_hp += 10 
            
}
            else if( 
add_hp 50 )
            {
                
add_hp += 25
            
}
            else if ( 
add_hp >= 100 )
            {
                
add_hp += 50 
            
}
            else if ( 
add_hp >= 250 )
            {
                
add_hp 
            
}
        }
        case 
MENU_MORE:
        {
            
menu_displayidmenupage )
        }
        case 
MENU_BACK:
        {
            
menu_displayidmenupage )
        }
    }
    if( 
is_user_alivep_key ) )
    {
        
set_user_healthp_keyget_user_healthp_key ) + add_hp )
    }
    
    return 
PLUGIN_CONTINUE


tested and doesnt work very well...

fysiks 05-03-2011 18:17

Re: Menu help.
 
To make that successfully you would need to use the original menu style because the new menu style does pages automatically and thus requires 8, 9, and 0 for navigating the menu options.

GarbageBox 05-08-2011 13:48

Re: Menu help.
 
Quote:

Originally Posted by fysiks (Post 1462805)
To make that successfully you would need to use the original menu style because the new menu style does pages automatically and thus requires 8, 9, and 0 for navigating the menu options.

Can you make it out?
I don't really good at menu.
Thank!

fysiks 05-08-2011 13:59

Re: Menu help.
 
You can look at the amx_slapmenu to see how it's done (in plmenu.sma)

GarbageBox 05-09-2011 10:10

Re: Menu help.
 
Why my code can not heal player's hp correctly?

Mine:
Code:

set_user_health(player, (get_user_health(player) + g_menuSettings[id]) ? g_menuSettings[id] : 0)
Original:
Code:

user_slap(player, (get_user_health(player) > g_menuSettings[id]) ? g_menuSettings[id] : 0)

SonicSonedit 05-09-2011 10:14

Re: Menu help.
 
I'm not sure what your trying to do, but it's probably should look like this:
PHP Code:

new hp=get_user_health(player)
set_user_health(player, (hp g_menuSettings[id]) ? g_menuSettings[id] : hp


fysiks 05-09-2011 14:29

Re: Menu help.
 
If you just want to add the selected heatlh like you say in your first post then:

PHP Code:

set_user_health(playerget_user_health(player) + g_menuSettings[id]) 



All times are GMT -4. The time now is 04:26.

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