AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need some help with menu (https://forums.alliedmods.net/showthread.php?t=189414)

dasha 07-06-2012 21:43

Need some help with menu
 
Is possible to see the hp of players in menu?
I'm talking about this:

PHP Code:

public menu(id){

    new 
menu menu_create("\wPlayers Menu""handler")
    
    new 
players[32], pnumtempid
    
new szName[32], szTempid[10]
    
get_players(playerspnum)

    for( new 
ii<pnumi++ ){
        
    
tempid players[i]

    
get_user_name(tempidszNamecharsmax(szName))
    
num_to_str(tempidszTempidcharsmax(szTempid))

    
menu_additem(menuszNameszTempid0)
    }

    
menu_display(idmenu0)
}

public 
handler(idmenuitem){

    new 
data[6], szName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback)

    new 
tempid str_to_num(data);
    if( 
is_user_alive(tempid) ){
        
    new 
spower[32]
    
read_argv(2spower31)
    
    new 
damage str_to_num(spower)
    
user_slap(tempiddamage)
    }



What I need is this:

Player name [%s HP]
another player [%s HP]
etc [%s HP]

Every time you slap some player, in the menu the hp will refresh to see the left hp

Liverwiz 07-06-2012 21:50

Re: Need some help with menu
 
format(szName, charsmax(szName), "%s (%dhp)", szName, get_user_health(id) )

Not sure how to refresh the menu list each time you select something, though.

dasha 07-06-2012 22:00

Re: Need some help with menu
 
Quote:

Originally Posted by Liverwiz (Post 1745079)
format(szName, charsmax(szName), "%s (%dhp)", szName, get_user_health(id) )

Not sure how to refresh the menu list each time you select something, though.

Thankyou! :3

well, not sure if the hp is auto refreshed, because when i slap the menu is closed

i was some weeks without scripting and i forgot a lot of things :oops:

hornet 07-06-2012 22:07

Re: Need some help with menu
 
It will not auto refresh. Also when a menu item is selected, the menu is hidden by default.

And I don't see what this is being used for:
Code:
 new spower[32]     read_argv(2, spower, 31)           new damage = str_to_num(spower)

dasha 07-06-2012 22:10

Re: Need some help with menu
 
Quote:

Originally Posted by hornet (Post 1745085)
And I don't see what this is being used for:
Code:
 new spower[32]     read_argv(2, spower, 31)           new damage = str_to_num(spower)


fixed.

new damage = str_to_num(szName)
user_slap(tempid, damage)

ps. so it's impossible to refresh the hp?

Liverwiz 07-06-2012 22:15

Re: Need some help with menu
 
Quote:

Originally Posted by dasha (Post 1745086)
ps. so it's impossible to refresh the hp?

nothing is impossible to the determined programmer. I'm just not too determined. :P

EDIT: actually....maybe after you call menu_destroy call menu again to show it, effectively refreshing it. ;)

dasha 07-06-2012 22:18

Re: Need some help with menu
 
I know that nothing is impossible and I always think about it.
But here i'm talking about possible or not in amxx (or current version of it).

hornet 07-06-2012 22:21

Re: Need some help with menu
 
Quote:

Originally Posted by dasha (Post 1745086)
=ps. so it's impossible to refresh the hp?

You either need to rebuild the menu or use menu_item_setname() to change the item and then display the menu again.

dasha 07-06-2012 22:31

Re: Need some help with menu
 
It can be this: (but if you are in page 2 or 3.., then isn't good...)

PHP Code:

public handler(idmenuitem){

    new 
data[6], szName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback)
    
    new 
tempid str_to_num(data);
    if( 
is_user_alive(tempid) ){
    
    new 
damage str_to_num(szName)
    
user_slap(tempiddamage)
    
menu(id)
    }



What about menu_item_setname(menu, item, const name[]) ? Never used it and has i think it change the name of item or anything after selecting it, right?

Liverwiz 07-06-2012 22:46

Re: Need some help with menu
 
Like this....

PHP Code:

if(is_user_alive(tempid) )
{
    new 
damage str_to_num(szName)
    
user_slap(tempiddamage)
}
else
    
client_print(idprint_chat"The selected user is invalid.")
menu_destroy(menu)
menu(id

i added that else statement just for the reason that the print suggests....if the user is invalid.
but you want to destroy the menu before you create an identical one.


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

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