AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   HOW CAN I ADD MENU TO A MENU! (https://forums.alliedmods.net/showthread.php?t=174581)

tobbiass 12-22-2011 08:51

HOW CAN I ADD MENU TO A MENU!
 
How can i do, then i write /shop there comming 3 menus like:
Weapon menu
Grenade menu
Item menu
And when you click on weapon menu there will come: M4A1, AK47, DEAGLE
and when you click on grenade menu there will come: HE,FLASH, SMOKE
and when you click on item menu there will come: Armor, and something else.

Please help me !:)

here is my script:

#include < cstrike >
#include < hamsandwich >
#include < fun >
#include < fakemeta >
#include < ColorChat >

public plugin_init() {
register_clcmd("say /shop","Menu2");
register_clcmd("say_team /shop","Menu2");
register_clcmd("say shop","Menu2");
register_clcmd("say_team shop","Menu2");
}

public Menu2(id)
{
new menu = menu_create( "\rSHOP! Tobias:", "menu_handler");
menu_additem(menu, "\r#1 \wAK47", "1", 0);
menu_additem(menu, "\r#2 \wM4A1", "2", 0);
menu_additem(menu, "\r#3 \wAWP", "3", 0);
menu_additem(menu, "\r#4 \wDEAGLE", "4", 0);
menu_additem(menu, "\r#5 \wHE", "5", 0 );
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
}

public menu_handler(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 key = str_to_num(data);
switch(key)
{
case 1:
{
ColorChat(id, GREEN, "^03You have just bought an ^04AK47" )
cs_set_user_money ( id, cs_get_user_money ( id ) - 5000 )
cs_set_weapon_ammo ( give_item ( id, "weapon_ak47" ), 90 )
}
case 2:
{
ColorChat(id, GREEN, "^03You have just bought a ^04M4A1" )
cs_set_user_money ( id, cs_get_user_money ( id ) - 5000 )
cs_set_weapon_ammo ( give_item ( id, "weapon_m4a1" ), 90 )
}
case 3:
{
ColorChat(id, GREEN, "^03You have just bought an ^04AWP" )
cs_set_user_money ( id, cs_get_user_money ( id ) - 10000 )
cs_set_weapon_ammo ( give_item ( id, "weapon_awp" ), 30 )
}
case 4:
{
ColorChat(id, GREEN, "^03You have just bought a ^04Deagle" )
cs_set_user_money(id, cs_get_user_money(id) - 3500)
cs_set_weapon_ammo( give_item (id, "weapon_deagle"), 20 )
}
case 5:
{
ColorChat(id, GREEN, "^03You have just bought a ^04HE Grenade" )
cs_set_user_money( id, cs_get_user_money (id ) - 300 )
cs_set_weapon_ammo( give_item ( id, "weapon_hegrenade"), 1 )
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}

Devil259 12-22-2011 08:56

Re: HOW CAN I ADD MENU TO A MENU!
 
Use [php] to add code.

tobbiass 12-22-2011 09:43

Re: HOW CAN I ADD MENU TO A MENU!
 
Can you write it in the code? I didnt understand what you said, im beginner with coding :)

Emp` 12-22-2011 10:53

Re: HOW CAN I ADD MENU TO A MENU!
 
https://forums.alliedmods.net/showth...=46364#SubMenu

Heartbeat 12-22-2011 11:22

Re: HOW CAN I ADD MENU TO A MENU!
 
Can you please add the code like this?

PHP Code:

#include < cstrike >
#include < hamsandwich >
#include < fun >
#include < fakemeta >
#include < ColorChat >

public plugin_init() {
register_clcmd("say /shop","Menu2");
register_clcmd("say_team /shop","Menu2");
register_clcmd("say shop","Menu2");
register_clcmd("say_team shop","Menu2");
}

public 
Menu2(id
{
new 
menu menu_create"\rSHOP! Tobias:""menu_handler");
menu_additem(menu"\r#1 \wAK47""1"0);
menu_additem(menu"\r#2 \wM4A1""2"0);
menu_additem(menu"\r#3 \wAWP""3"0);
menu_additem(menu"\r#4 \wDEAGLE""4"0);
menu_additem(menu"\r#5 \wHE""5");
menu_setprop(menuMPROP_EXITMEXIT_ALL);
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(menuitemaccessdata,charsmax(data), szNamecharsmax(szName), callback);
new 
key str_to_num(data);
switch(
key)
{
case 
1:
{
ColorChat(idGREEN"^03You have just bought an ^04AK47" )
cs_set_user_money idcs_get_user_money id ) - 5000 )
cs_set_weapon_ammo give_item id"weapon_ak47" ), 90 )
}
case 
2:
{
ColorChat(idGREEN"^03You have just bought a ^04M4A1" )
cs_set_user_money idcs_get_user_money id ) - 5000 )
cs_set_weapon_ammo give_item id"weapon_m4a1" ), 90 )
}
case 
3:
{
ColorChat(idGREEN"^03You have just bought an ^04AWP" )
cs_set_user_money idcs_get_user_money id ) - 10000 )
cs_set_weapon_ammo give_item id"weapon_awp" ), 30 )
}
case 
4:
{
ColorChat(idGREEN"^03You have just bought a ^04Deagle" )
cs_set_user_money(idcs_get_user_money(id) - 3500)
cs_set_weapon_ammogive_item (id"weapon_deagle"), 20 )
}
case 
5:
{
ColorChat(idGREEN"^03You have just bought a ^04HE Grenade" )
cs_set_user_moneyidcs_get_user_money (id ) - 300 )
cs_set_weapon_ammogive_item id"weapon_hegrenade"), 
}
}
menu_destroy(menu);
return 
PLUGIN_HANDLED


Thank you very much!

fysiks 12-22-2011 13:38

Re: HOW CAN I ADD MENU TO A MENU!
 
This kid hasn't learned his lesson. It's getting annoying.

Devil259 12-22-2011 13:45

Re: HOW CAN I ADD MENU TO A MENU!
 
Indent the code.

tobbiass 12-22-2011 15:19

Re: HOW CAN I ADD MENU TO A MENU!
 
Sorry fysiks, but do you have some good links, where i can learn about it? :)

fysiks 12-22-2011 15:38

Re: HOW CAN I ADD MENU TO A MENU!
 
Quote:

Originally Posted by tobbiass (Post 1617900)
Sorry fysiks, but do you have some good links, where i can learn about it? :)

I was refering to this:

Quote:

Originally Posted by fysiks (Post 1616747)
when posting code, use [php][/php] around your code.

Also, you've already been give what you need to add a menu to a menu (aka submenu).


All times are GMT -4. The time now is 11:54.

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