Raised This Month: $ Target: $400
 0% 

playermenu help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
plowed
Senior Member
Join Date: Oct 2010
Location: germany
Old 10-01-2011 , 18:46   playermenu help
Reply With Quote #1

hi there.

I start making a menu that listen all players on the server. After a player on the menu is choosen a submenu open (which is not fully included here) where the submenu show some amounts ( 5, 10, 20, 50, 100 )

My problem is: I cant hold the id (in my code the var: tempid) of the player I choose in the menu through to the submenu.

PHP Code:
#include <amxmodx>
#include <fun>
#include <zp50_ammopacks>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "plowed"

#define MAXAMOUNT 5

new g_ammoAmount[MAXAMOUNT][] = {
    
5,
    
10
    
20,
    
50
    
100
}


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /menu""donateMenu")    
}

public 
donateMenu(id) {
    new 
menu menu_create("Donate menu:","menu_handler")
    
    new 
players[32], pnumtempid
    
new szName[32], szTempid[10]
    new 
ammos[32]
    new 
desc[64]
    
get_players(playerspnum)
    
    for(new 
0pnumi++) {
        
tempid players[i]
        
ammos[tempid] = zp_ammopacks_get(tempid)
        
        
get_user_name(tempidszNamecharsmax(szName))
        
formatex(desccharsmax(desc), "\w%s      \rAmmos: \y%d"szNameammos[tempid])
        
num_to_str(tempidszTempidcharsmax(szTempid))
        
menu_additem(menudescszTempid0)
    }
    
menu_display(idmenu0)
}
    
public  
menu_handler(idmenuitem) {
    if(
item == MENU_EXIT) {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], szName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdatacharsmax(data), szNamecharsmax(szName), callback)
    new 
tempid str_to_num(data)
    new 
Title[128], name[32], Auswahl[20]
    
get_user_name(tempidnamecharsmax(name))
    
formatex(Titlecharsmax(Title), "Donate ammos to %s"name)
    
    
    new 
submenu menu_create(Title"submenu_handler")
    
    for(new 
isizeof g_ammoAmount;i++) {
    
formatex(Auswahlcharsmax(Auswahl),"\y%d\w HP"g_ammoAmount[i])
    
menu_additem(submenuAuswahl"i"0)
    }
    
menu_setprop(submenuMPROP_EXITMEXIT_ALL)
    
menu_display(idsubmenu0)
    
    return 
PLUGIN_HANDLED
}

public 
submenu_handler(idsubmenuitem) {
    
    if(
item == MENU_EXIT) {
        
menu_destroy(submenu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], szName[64]
    new 
accesscallback
    
    menu_item_getinfo
(submenuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    
    new 
key str_to_num(data)
    
    switch(
key)
    {
     case 
1:
    {
    
//ex set_user_health of the player I choose..BUT I dont know how to get on that playerid I choose :S:DSX
    
}
    case 
2:
    {
        
    }
    case 
3
    {

    }
    case 
4
    {

    }
    case 
5
    {

    }
    }

some help or advices would be nice !
__________________
Zombie Mod + gameMe stats :

Last edited by plowed; 10-01-2011 at 18:50.
plowed is offline
[PUPPETS] Scooter
Member
Join Date: May 2009
Old 10-02-2011 , 07:33   Re: playermenu help
Reply With Quote #2

Quote:
menu_additem(submenu, Auswahl, "i", 0)

You have to pass the ID as part of the data, which is the third parameter.
[PUPPETS] Scooter is offline
plowed
Senior Member
Join Date: Oct 2010
Location: germany
Old 10-02-2011 , 13:59   Re: playermenu help
Reply With Quote #3

I think that part of data is needed to catch which menu item a player selectet or am I wrong?

Anyway Ive tried with a global variable that hold every menu choice for every player. And the menu just works fine

thanks andy
__________________
Zombie Mod + gameMe stats :

Last edited by plowed; 10-02-2011 at 14:10.
plowed is offline
[PUPPETS] Scooter
Member
Join Date: May 2009
Old 10-02-2011 , 15:38   Re: playermenu help
Reply With Quote #4

As data is an array, you can pass whatever you want and split it later.
You're welcome
[PUPPETS] Scooter is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-02-2011 , 19:25   Re: playermenu help
Reply With Quote #5

i acutally have no idea what it is you want.. but there is a section on here that explains menus pretty good. you should look into that.
Doc-Holiday is offline
plowed
Senior Member
Join Date: Oct 2010
Location: germany
Old 10-05-2011 , 15:04   Re: playermenu help
Reply With Quote #6

Quote:
Originally Posted by [PUPPETS] Scooter View Post
As data is an array, you can pass whatever you want and split it later.
You're welcome
Ah now I understand sounds really useful.

But I dont get how to use this.

For example I want to pass 3 things

data[0] = id
data[1] = name
data[2] = steamid

Could you or someone else give me a quick example please?
__________________
Zombie Mod + gameMe stats :
plowed is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-05-2011 , 15:30   Re: playermenu help
Reply With Quote #7

Creating a global variable that holds the index of the selected player is also a valid option.

Code:
new g_playerid[ 33 ]; // in menu_handler // instead of new tempid = str_to_num(data): g_playerid[ id ] = str_to_num( data ); // then use g_playerid[ id ] to retrieve the selected player index // get_user_name(g_playerid[ id ], name, charsmax( name ) ); // etc... // and then in submenu_handler // use the global variable to retrieve the index new key = str_to_num( data ); set_user_ammo( g_playerid[ id ], g_ammoAmount[ key ] ); // just an example, set_user_ammo does not exist as an amxx native
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
plowed
Senior Member
Join Date: Oct 2010
Location: germany
Old 10-05-2011 , 15:33   Re: playermenu help
Reply With Quote #8

see post #3. Im Just interest how to script the other way

Quote:
// just an example, set_user_ammo does not exist as an amxx native
cuz the native is from zombie plague
__________________
Zombie Mod + gameMe stats :

Last edited by plowed; 10-05-2011 at 15:36.
plowed is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-05-2011 , 15:47   Re: playermenu help
Reply With Quote #9

Quote:
Originally Posted by plowed View Post
see post #3. Im Just interest how to script the other way

cuz the native is from zombie plague
Aha. I see. set_user_ammo is not a default native, it probably exists in a mod or include file, but not official includes.

I'm not entirely sure if data can be passed as an array in menu_additem, most likely not. You can try it out if you want to however.

EDIT: It can be passed as a long string however.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
plowed
Senior Member
Join Date: Oct 2010
Location: germany
Old 10-05-2011 , 16:56   Re: playermenu help
Reply With Quote #10

Ive got confused first but now I think I can use it thx. Forgot Scooter's advice tho ;)
__________________
Zombie Mod + gameMe stats :
plowed 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 22:33.


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