Raised This Month: $ Target: $400
 0% 

How come this menu won't pop up?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iloverain
Junior Member
Join Date: Jun 2012
Old 06-25-2012 , 15:52   How come this menu won't pop up?
Reply With Quote #1

Well... I have a menu that will get the players alive, team, and skip bots. the team = terrorists. It will give health to terrorists to who ever you select.

Code:
public HMenu(id) {    
    new menu = menu_create ( "\rWee", "menu_handler_2" );

    new players[32], pnum, tempid;

    new szName[32], szTempid[10];

    get_players( players, pnum, "ceh", "TERRORIST" );

    for( new i; i<pnum; i++ )
    {
        tempid = players[i];
    
        get_user_name( tempid, szName, charsmax( szName ) );
        num_to_str( tempid, szTempid, charsmax( szTempid ) );

        menu_additem( menu, szName, szTempid, 0 );

    }

    menu_display( id, menu, 0 );
}
 
public menu_handler_2(id, menu, item) {
    if( item == MENU_EXIT )
    {
        menu_destroy( menu );
        return PLUGIN_HANDLED;
    }

    new data[6], szName[64];
    new access, callback;
    menu_item_getinfo( menu, item, access, data,charsmax( data ), szName,charsmax( szName ), callback );

    new tempid = str_to_num( data );
   
    if ( is_user_alive ( tempid ) ) {
    set_user_health( tempid, 1000 )
 } 

    menu_destroy( menu );
    return PLUGIN_HANDLED;
}
__________________
Just A n00b Learning. ^-^

Last edited by iloverain; 06-25-2012 at 15:54.
iloverain is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-25-2012 , 17:34   Re: How come this menu won't pop up?
Reply With Quote #2

how do you call HMenu() function?
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2012 , 19:06   Re: How come this menu won't pop up?
Reply With Quote #3

Show the whole code. If it's a long plugin (greater than 100 lines) then post it as an attachment.
__________________
fysiks is offline
iloverain
Junior Member
Join Date: Jun 2012
Old 06-25-2012 , 19:19   Re: How come this menu won't pop up?
Reply With Quote #4

Heres the code;

Code:
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd ( "say /hpp", "GetH" )
    register_clcmd ( "say_team /hpp", "GetH" )
}

public GetH(id) {
    if ( cs_get_user_team( id ) == CS_TEAM_CT ) {
    HMenu( id )
    } else {
    ColorChat( id, GREEN, "You are not a^x03 CT^x01!" )    
    }
}
then the above!

thats it o.0
__________________
Just A n00b Learning. ^-^

Last edited by iloverain; 06-25-2012 at 19:21.
iloverain is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2012 , 19:23   Re: How come this menu won't pop up?
Reply With Quote #5

Why can't people just post the whole freakin' code????? That's not the whole code.

On topic: Debug it. Find out what functions/conditions are actually being executed.
__________________
fysiks is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-25-2012 , 19:50   Re: How come this menu won't pop up?
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
On topic: Debug it. Find out what functions/conditions are actually being executed.
What he said.

And just put the checks in GetH right into HMenu. and return PLUGIN_HANDLED under your ColorChat statement.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
iloverain
Junior Member
Join Date: Jun 2012
Old 06-25-2012 , 20:28   Re: How come this menu won't pop up?
Reply With Quote #7

First off it is the whole code. Want me to put it together for you?
Here.
Spoiler

that's it bro.

debuging ; editing later on.
__________________
Just A n00b Learning. ^-^
iloverain is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-25-2012 , 21:56   Re: How come this menu won't pop up?
Reply With Quote #8

That will work fine. Are you testing in a server with other players ... non bot players since that's what you've specified in your player return?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
iloverain
Junior Member
Join Date: Jun 2012
Old 06-25-2012 , 22:39   Re: How come this menu won't pop up?
Reply With Quote #9

I've been testing mostly by myself. I thought the menu should still pop-up even if there's no terrorists? I will try as soon as my friend comes online. Thanks. I'll edit this post if it works fine then.
__________________
Just A n00b Learning. ^-^
iloverain is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-25-2012 , 23:12   Re: How come this menu won't pop up?
Reply With Quote #10

A menu will only show if it has an item to show. And since there is no players on Terrorist nothing will come up. Try commenting out the CT team check just for the purpose of testing - Then go Terrorist, type /hpp, and you'll find that your name will come up in the menu and then you can use it on yourself.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet 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 06:10.


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