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

menu handle destroy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yagami
Senior Member
Join Date: Jan 2021
Old 02-12-2023 , 12:46   menu handle destroy
Reply With Quote #1

Can someone help me with this menu here,
what I did here was the following, when the player destroys only one dispenser is destroyed now when there are two more dispensers he can choose which dispenser he wants to destroy that this function here

but I also put another thing when the admin needs to destroy a dispenser he can
So when admin destroy a dispenser all dispensers need to appear for him, but I do not know how to do this in handle can anyone help me ?

PHP Code:
public menu_admin_dispenser_destroy(id)
{
    new 
menu menu_create("Destruir Dispenser Menu:""menu_admin_dispenser_destroy_handler");

    new 
iEnt  = -1;
    new 
iLeveliHealthiOwnersEntId[6];

    while ((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"dispenser_classname)))
    {
        if (!
pev_valid(iEnt))
        {
            
iOwner != id && is_user_admin(id)

            if(
iOwner != id && is_user_admin(id))
            {
                continue;
            }
        }

        
iLevel  pev(iEntDISPENSER_LEVEL);
        
iHealth pev(iEntpev_health);
        
iOwner  pev(iEntDISPENSER_OWNER);
        
num_to_str(iEntsEntIdcharsmax(sEntId));

        if(
is_user_admin(id))
            
menu_additem(menufmt("Level: [%2d], Vida: [%4d] Dono: [%n]"iLeveliHealthiOwner), sEntId);
        else 
            
menu_additem(menufmt("Level: [%2d], Vida:[%4d]"iLeveliHealth), sEntId);

    }
    
menu_display(idmenu0);
}

public 
menu_admin_dispenser_destroy_handler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return;
    }

    new 
szData[6], szName[64], accesscallback;
    
menu_item_getinfo(menuitemaccessszDatacharsmax(szData), szNamecharsmax(szName), callback);

    new 
ent str_to_num(szData);

    if(
pev_valid(ent))
    {
        if()
            
            
        new 
iOwner pev(entDISPENSER_OWNER);

        
client_print_color(0print_team_default"%s ^3Você destruiu seu próprio ^4Dispenser^3"PREFIX_CHAT)
        
g_DispPlayerCount[iOwner]--;
        
xLimitGlobal[cs_get_user_team(iOwner)]--
        
isEnt[ent] = false
        xRemoveEntFix
(ent);
        
    }

yagami is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2023 , 16:32   Re: menu handle destroy
Reply With Quote #2

Your title and your post are confusing because there are two different context that could be referenced by "menu handle destroy". "menu handle destroy" could be referencing destroying the menu handle/reference with menu_destroy() or it could be referencing your functional context of destroying this "dispenser".

In the context of menu_destroy(), if you create a menu just before showing it you should destroy that menu when the user closes it or selects an option. So, you are missing a menu_destroy() at the end of your menu_admin_dispenser_destroy_handler() function.

If what you're asking for is how to show a menu to someone just after they selected an item, then you just do exactly that. Call the function that shows the menu with the updated data when they select an item but make sure to use menu_destroy() on the menu in the handler as noted above. Similar to the pseudo code here:

PHP Code:
public show_my_menu(id)
{
    
// Create the menu
    
new menu menu_create("My Menu""my_menu_handler")

    
/*
        Add items to the menu as needed
    */

    // Show the menu
    
menu_display(idmenu)
}

public 
my_menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu)
        return
    }

    
// Process the menu selection

    
if( /* show menu again */ )
    {
        
show_my_menu(id)
    }

    
menu_destroy(menu)

__________________
fysiks 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 03:47.


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