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

menu destroy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 04-09-2022 , 17:09   menu destroy
Reply With Quote #1

PHP Code:
public Event_RoundStart() 

    
g_RespawnAllowed true
    set_task
(20.0,"DisableRespawn"


public 
H_PlayerDeath(victimattackershouldgib

    
set_task(0.1"respawnmenu"victim


public 
DisableRespawn(id

    
g_RespawnAllowed false

public 
respawnmenu(id)
{
    if(
g_RespawnAllowed
    { 
        new 
menu menu_create("\wDeathrun Shop:^nWould you like a respawn for \yFREE?""rspmenu");
        
        
menu_additem(menu"\wYes""1"0);
        
menu_additem(menu"\rNo""2"0);
        
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
menu_display(idmenu0);
    }

how can I destroy the menu to the people that died before those 20 seconds but didn't used the menu? I mean, if someone's using this menu before those 20 seconds, it works ok, but if someone dies before 20 seconds but doesn't use the menu, after those 20 seconds if he uses it, it will respawn him to the SPEC, he's at spectator but respawned, and can walk, kill and etc, like a player! All i want to once the RespawnAllowed is done, the menu to be destroyed for those who didnt used it! thanks
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 04-09-2022 , 22:07   Re: menu destroy
Reply With Quote #2

You just need to check if the user is alive or dead

Last edited by amirwolf; 04-09-2022 at 22:19.
amirwolf is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 04-09-2022 , 23:31   Re: menu destroy
Reply With Quote #3

Deny spectators from using this menu...?
bigdaddy424 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-09-2022 , 23:38   Re: menu destroy
Reply With Quote #4

A way to hide a menu is documented in the New Menus tutorial here as follows:

Code:
show_menu( id, 0, "^n", 1 );
Call this when they die.
__________________

Last edited by fysiks; 04-09-2022 at 23:38.
fysiks is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 04-10-2022 , 01:23   Re: menu destroy
Reply With Quote #5

Wont work to create menu var in a global var and then then use menu_destroy?
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 04-10-2022 , 06:59   Re: menu destroy
Reply With Quote #6

Quote:
Originally Posted by amirwolf View Post
You just need to check if the user is alive or dead
they has to be dead to use the menu, its a menu asking if they want to respawn or not, the problem is that they use the menu after those 20 seconds

Quote:
Originally Posted by bigdaddy424 View Post
Deny spectators from using this menu...?
they aren't spectators, they're on CT side, when using the menu after those 20 seconds they respawn at spectator

Quote:
Originally Posted by fysiks View Post
A way to hide a menu is documented in the New Menus tutorial here as follows:

Code:
show_menu( id, 0, "^n", 1 );
Call this when they die.
yeah, but won't it destroy the menu at all when they die? I mean, it has to destroy only if they are dead after those 20 seconds
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-10-2022 , 09:04   Re: menu destroy
Reply With Quote #7

There mate free respawn tickets...

Code:
/* Sublime AMXX Editor v2.2 */

#include <amxmodx>
#include <hamsandwich>

#define PLUGIN  "Free ticket respawn"
#define VERSION "1.0"
#define AUTHOR  "Natsheh"

#define TASK_FREE_RESPAWNING 100
#define FREE_RESPAWNING_DURATION 20.0

#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif

new HamHook:g_fwPlayerKilledPost, g_user_has_respawn_menu[ MAX_PLAYERS + 1 ];

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);

    register_event("HLTV", "event_hltv", "a", "1=0", "2=0");
    DisableHamForward( (g_fwPlayerKilledPost = RegisterHam(Ham_Killed, "player", "fwPlayerKilledPost", .Post=true)) );
}

public event_hltv()
{
    remove_task(TASK_FREE_RESPAWNING);
    EnableHamForward(g_fwPlayerKilledPost);

    set_task( FREE_RESPAWNING_DURATION, "Disable_free_respawning", TASK_FREE_RESPAWNING);
}

public Disable_free_respawning( taskid )
{
    DisableHamForward(g_fwPlayerKilledPost);

    new players[32], pnum;
    get_players(players, pnum, "ch");

    for(new i, id; i < pnum; i ++)
    {
        id = players[i];
        if(g_user_has_respawn_menu[id])
        {
            g_user_has_respawn_menu[id] = false;
            menu_cancel(id);
            show_menu(id, 0, " ^n ");
        }
    }
}

#if AMXX_VERSION_NUM > 182
public client_disconnected(id)
#else
public client_disconnect(id)
#endif
{
    remove_task( id );
}

public fwPlayerKilledPost( iVictim )
{
    set_task(1.0, "DisplayRespawnMenu", iVictim);
}

public DisplayRespawnMenu( id )
{
    g_user_has_respawn_menu[ id ] = true;

    new menu = menu_create("Would you like to respawn for \yFREE?", "rspmenu");

    menu_additem(menu, "\wYes");
    menu_additem(menu, "\rNo");

    menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER);
    menu_display(id, menu);
}

public rspmenu( id, menu, item )
{
    g_user_has_respawn_menu[ id ] = false;

    menu_destroy(menu);

    switch( item + 1 )
    {
        case 1 : ExecuteHamB(Ham_Spawn, id);
        case 2 : client_print(id, print_chat, "Your lost!");
    }

    return PLUGIN_HANDLED;
}
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-10-2022 at 09:09.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 04-10-2022 , 10:43   Re: menu destroy
Reply With Quote #8

Quote:
Originally Posted by Natsheh View Post
There mate free respawn tickets...

Code:
/* Sublime AMXX Editor v2.2 */

#include <amxmodx>
#include <hamsandwich>

#define PLUGIN  "Free ticket respawn"
#define VERSION "1.0"
#define AUTHOR  "Natsheh"

#define TASK_FREE_RESPAWNING 100
#define FREE_RESPAWNING_DURATION 20.0

#if !defined MAX_PLAYERS
#define MAX_PLAYERS 32
#endif

new HamHook:g_fwPlayerKilledPost, g_user_has_respawn_menu[ MAX_PLAYERS + 1 ];

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);

    register_event("HLTV", "event_hltv", "a", "1=0", "2=0");
    DisableHamForward( (g_fwPlayerKilledPost = RegisterHam(Ham_Killed, "player", "fwPlayerKilledPost", .Post=true)) );
}

public event_hltv()
{
    remove_task(TASK_FREE_RESPAWNING);
    EnableHamForward(g_fwPlayerKilledPost);

    set_task( FREE_RESPAWNING_DURATION, "Disable_free_respawning", TASK_FREE_RESPAWNING);
}

public Disable_free_respawning( taskid )
{
    DisableHamForward(g_fwPlayerKilledPost);

    new players[32], pnum;
    get_players(players, pnum, "ch");

    for(new i, id; i < pnum; i ++)
    {
        id = players[i];
        if(g_user_has_respawn_menu[id])
        {
            g_user_has_respawn_menu[id] = false;
            menu_cancel(id);
            show_menu(id, 0, " ^n ");
        }
    }
}

#if AMXX_VERSION_NUM > 182
public client_disconnected(id)
#else
public client_disconnect(id)
#endif
{
    remove_task( id );
}

public fwPlayerKilledPost( iVictim )
{
    set_task(1.0, "DisplayRespawnMenu", iVictim);
}

public DisplayRespawnMenu( id )
{
    g_user_has_respawn_menu[ id ] = true;

    new menu = menu_create("Would you like to respawn for \yFREE?", "rspmenu");

    menu_additem(menu, "\wYes");
    menu_additem(menu, "\rNo");

    menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER);
    menu_display(id, menu);
}

public rspmenu( id, menu, item )
{
    g_user_has_respawn_menu[ id ] = false;

    menu_destroy(menu);

    switch( item + 1 )
    {
        case 1 : ExecuteHamB(Ham_Spawn, id);
        case 2 : client_print(id, print_chat, "Your lost!");
    }

    return PLUGIN_HANDLED;
}
thanks, it works
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Reply


Thread Tools
Display Modes

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 07:34.


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