Raised This Month: $ Target: $400
 0% 

Need some help with menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dasha
Senior Member
Join Date: Apr 2012
Location: \%STEAM -> $_SESSION
Old 07-06-2012 , 21:43   Need some help with menu
Reply With Quote #1

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
dasha is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-06-2012 , 21:50   Re: Need some help with menu
Reply With Quote #2

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.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
dasha
Senior Member
Join Date: Apr 2012
Location: \%STEAM -> $_SESSION
Old 07-06-2012 , 22:00   Re: Need some help with menu
Reply With Quote #3

Quote:
Originally Posted by Liverwiz View Post
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!

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
dasha is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 07-06-2012 , 22:07   Re: Need some help with menu
Reply With Quote #4

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)
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
dasha
Senior Member
Join Date: Apr 2012
Location: \%STEAM -> $_SESSION
Old 07-06-2012 , 22:10   Re: Need some help with menu
Reply With Quote #5

Quote:
Originally Posted by hornet View Post
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?

Last edited by dasha; 07-06-2012 at 22:11. Reason: ps
dasha is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-06-2012 , 22:15   Re: Need some help with menu
Reply With Quote #6

Quote:
Originally Posted by dasha View Post
ps. so it's impossible to refresh the hp?
nothing is impossible to the determined programmer. I'm just not too determined.

EDIT: actually....maybe after you call menu_destroy call menu again to show it, effectively refreshing it. ;)
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 07-06-2012 at 22:17.
Liverwiz is offline
dasha
Senior Member
Join Date: Apr 2012
Location: \%STEAM -> $_SESSION
Old 07-06-2012 , 22:18   Re: Need some help with menu
Reply With Quote #7

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).
dasha is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 07-06-2012 , 22:21   Re: Need some help with menu
Reply With Quote #8

Quote:
Originally Posted by dasha View Post
=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.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
dasha
Senior Member
Join Date: Apr 2012
Location: \%STEAM -> $_SESSION
Old 07-06-2012 , 22:31   Re: Need some help with menu
Reply With Quote #9

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?
dasha is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-06-2012 , 22:46   Re: Need some help with menu
Reply With Quote #10

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.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
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 15:15.


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