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

How to detect if selection of a menu is complete


Post New Thread Reply   
 
Thread Tools Display Modes
TheSpaniard
Senior Member
Join Date: Jul 2017
Location: Hell
Old 09-23-2017 , 07:18   Re: How to detect if selection of a menu is complete
Reply With Quote #11

This is the code not working

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#include <fakemeta_util>

#define PLUGIN "VipMenu"
#define VERSION "2.0"
#define AUTHOR "TheSpaniard"


public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	RegisterHam(Ham_Spawn, "player", "Fwd_PlayerSpawn_Post", 1);
	register_clcmd("say /vip", "vipmenu")
}

public Fwd_PlayerSpawn_Post(id)
{
	if(!(get_user_flags(id) & ADMIN_LEVEL_H))
	{
		return PLUGIN_HANDLED
	}
	if(is_user_alive(id) && !is_user_bot(id))
	{
		fm_strip_user_weapons(id);
		set_pdata_int(id, 116, 0);
		fm_give_item(id, "weapon_knife");
	}
	vipmenu(id)
	return PLUGIN_CONTINUE
}
public vipmenu(id)
{
	new menu = menu_create("\rPrimary Weapon's Menu", "menu_handler")
	menu_additem(menu, "\wAWP", "1", 0)
	menu_additem(menu, "\wM4A1", "2", 0)
	menu_additem(menu, "\wAK47", "3", 0)
	menu_additem(menu, "\wSG552 [Assault-Rifle]", "4", 0)
	menu_additem(menu, "\wFAMAS", "5", 0)
	menu_additem(menu, "\wSG550 [Sniper]", "6", 0)
	menu_additem(menu, "\wGALIL", "7", 0)
	menu_additem(menu, "\wD3AU1 [Auto-Snipe]", "8", 0)
	menu_additem(menu, "\wSCOUT", "9", 0)
	menu_additem(menu, "\wBULLPUP", "10", 0)
	menu_additem(menu, "\wMP5", "11", 0)
	menu_additem(menu, "\wTMP", "12", 0)
	menu_additem(menu, "\wMAC 10", "13", 0)
	menu_additem(menu, "\wUMP45", "14", 0)
	menu_additem(menu, "\wP90", "15", 0)
	menu_additem(menu, "\wM249 [Machine Gun]", "16", 0)
	menu_additem(menu, "\wXM1014", "17", 0)
	menu_additem(menu, "\wM3", "18", 0)
	
	menu_setprop( menu, MPROP_EXIT, MEXIT_ALL )
	menu_display( id, menu, 0 )
	
	
	
	return PLUGIN_CONTINUE
}

public menu_handler(id, menu, item)
{
	if(item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}
	switch(item)
	{
		case 1:
		{
			give_item(id, "weapon_awp")
			cs_set_user_bpammo(id, CSW_AWP, 30)
		}
		case 2:
		{
			give_item(id, "weapon_m4a1")
			cs_set_user_bpammo(id, CSW_M4A1, 90)
		}
		case 3:
		{
			give_item(id, "weapon_ak47")
			cs_set_user_bpammo(id, CSW_AK47, 90)
		}
		case 4:
		{
			give_item(id, "weapon_sg552")
			cs_set_user_bpammo(id, CSW_SG552, 90)
		}
		case 5:
		{
			give_item(id, "weapon_famas")
			cs_set_user_bpammo(id, CSW_FAMAS, 90)
		}
		case 6:
		{
			give_item(id, "weapon_sg550")
			cs_set_user_bpammo(id, CSW_SG550, 90)
		}
		case 7:
		{
			give_item(id, "weapon_galil")
			cs_set_user_bpammo(id, CSW_GALIL, 90)
		}
		case 8:
		{
			give_item(id, "weapon_g3sg1")
			cs_set_user_bpammo(id, CSW_G3SG1, 90)
		}
		case 9:
		{
			give_item(id, "weapon_scout")
			cs_set_user_bpammo(id, CSW_SCOUT, 90)
		}
		case 10:
		{
			give_item(id, "weapon_aug")
			cs_set_user_bpammo(id, CSW_AUG, 90)
		}
		case 11:
		{
			give_item(id, "weapon_mp5navy")
			cs_set_user_bpammo(id, CSW_MP5NAVY, 120)
		}
		case 12:
		{
			give_item(id, "weapon_tmp")
			cs_set_user_bpammo(id, CSW_TMP, 120)
		}
		case 13:
		{
			give_item(id, "weapon_mac10")
			cs_set_user_bpammo(id, CSW_MAC10, 120)
		}
		case 14:
		{
			give_item(id, "weapon_ump45")
			cs_set_user_bpammo(id, CSW_UMP45, 100)
			
		}
		case 15:
		{
			give_item(id, "weapon_p90")
			cs_set_user_bpammo(id, CSW_P90, 100)
			
		}
		case 16:
		{
			give_item(id, "weapon_m249")
			cs_set_user_bpammo(id, CSW_M249, 90)
		}
		case 17:
		{
			give_item(id, "weapon_m3")
			cs_set_user_bpammo(id, CSW_M3, 90)
		}
		case 18:
		{
			give_item(id, "weapon_xm1014")
			cs_set_user_bpammo(id, CSW_XM1014, 90)
		}
		case MENU_EXIT:
		{
			menu_destroy(menu)
			return PLUGIN_HANDLED
		}
	}
	set_task(1.0, "repeat", id, _, _, "a", 1)
	return PLUGIN_CONTINUE
}

public repeat(id)
{
	vipmenu(id)
}
Help Appreciated.
__________________
And I Am Back.
TheSpaniard is offline
killerZM
Senior Member
Join Date: Sep 2016
Old 09-23-2017 , 08:24   Re: How to detect if selection of a menu is complete
Reply With Quote #12

you need when user exit menu or when user buy item ?
killerZM is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-23-2017 , 08:41   Re: How to detect if selection of a menu is complete
Reply With Quote #13

1st item id is 0....
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
TheSpaniard
Senior Member
Join Date: Jul 2017
Location: Hell
Old 09-23-2017 , 09:29   Re: How to detect if selection of a menu is complete
Reply With Quote #14

How to repeat the menu only 2 times so user can get 2 primary weapons because with above code its repeating indefinitely.
__________________
And I Am Back.
TheSpaniard is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-23-2017 , 13:42   Re: How to detect if selection of a menu is complete
Reply With Quote #15

Your code is quite terrible... :X

Code:
        case 18:         {             give_item(id, "weapon_xm1014")             cs_set_user_bpammo(id, CSW_XM1014, 90)         }         // Remove this case!!!         case MENU_EXIT:         {             menu_destroy(menu)             return PLUGIN_HANDLED         }     }     set_task(1.0, "repeat", id, _, _, "a", 1) // replaced that with vipmenu(id);     // here add menu_destory(menu);     return PLUGIN_CONTINUE }

Last edited by KiLLeR.; 09-23-2017 at 13:43.
KiLLeR. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-23-2017 , 14:43   Re: How to detect if selection of a menu is complete
Reply With Quote #16

Quote:
Originally Posted by TheSpaniard View Post
How to repeat the menu only 2 times so user can get 2 primary weapons because with above code its repeating indefinitely.
You need to add logic that determines how many times the other menu is called per player. If you the player chooses an item on the second menu, then don't show the new menu.
__________________
fysiks is offline
TheSpaniard
Senior Member
Join Date: Jul 2017
Location: Hell
Old 09-25-2017 , 11:37   Re: How to detect if selection of a menu is complete
Reply With Quote #17

Quote:
Originally Posted by fysiks View Post
You need to add logic that determines how many times the other menu is called per player. If you the player chooses an item on the second menu, then don't show the new menu.
Got your idea, but still, i am a beginner, can you show me how to do it, i don't know how to add logic.
And the code is unfinished i want to display the primary weapons 2 times then secondary menu 1 time.
I didn't have the time to make secondary menu.
@brief there is no second menu till now, I want to display the first menu 2 times
Now are you getting me.
__________________
And I Am Back.
TheSpaniard is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-25-2017 , 12:04   Re: How to detect if selection of a menu is complete
Reply With Quote #18

Did you try what i told you?!
KiLLeR. is offline
TheSpaniard
Senior Member
Join Date: Jul 2017
Location: Hell
Old 09-25-2017 , 12:12   Re: How to detect if selection of a menu is complete
Reply With Quote #19

Quote:
Originally Posted by KiLLeR. View Post
Did you try what i told you?!
I did thought about it before you told me but didn't try it yet but don't you think by replacing set task by vipmenu it will loop indefinitely because there is no limit to how many times it should be repeated.

EDIT : I was Right.
__________________
And I Am Back.

Last edited by TheSpaniard; 09-25-2017 at 12:22.
TheSpaniard is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 09-25-2017 , 13:50   Re: How to detect if selection of a menu is complete
Reply With Quote #20

Yeah, I did not pay attention, that this is recursion.
Okay, it's simple then.
Code:
new first_menu_done[33]; // you can call it whatever you want // in vipmenu if(first_menu_done[id]) return PLUGIN_HANDLED // this in beginning at function // in vipmenu handler: first_menu_done[id] = true; // add this above calling a vipmenu(id)

EDIT: Ignore that above, and try this: (Remember, item id start from 0)
Code:
#include <amxmodx> #include <hamsandwich> #include <fun> #include <cstrike> #define PLUGIN "primary_wep_menu" #define VERSION "2.0" #define AUTHOR "TheSpaniard" new count[33]; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     RegisterHam(Ham_Spawn, "player", "Fwd_PlayerSpawn_Post", 1);     register_clcmd("say /vip", "primary_wep_menu") } public Fwd_PlayerSpawn_Post(id) {     if(!is_user_alive(id) || is_user_bot(id))         return PLUGIN_HANDLED;             if(!(get_user_flags(id) & ADMIN_LEVEL_H))         return PLUGIN_HANDLED             count[id] = 0;         strip_user_weapons(id);     set_pdata_int(id, 116, 0);     give_item(id, "weapon_knife");     primary_wep_menu(id);         return PLUGIN_CONTINUE; } public primary_wep_menu(id) {     new menu = menu_create("\rPrimary Weapon's Menu", "menu_handler");         menu_additem(menu, "\wAWP", "1", 0)     menu_additem(menu, "\wM4A1", "2", 0)     menu_additem(menu, "\wAK47", "3", 0)     menu_additem(menu, "\wSG552 [Assault-Rifle]", "4", 0)     menu_additem(menu, "\wFAMAS", "5", 0)     menu_additem(menu, "\wSG550 [Sniper]", "6", 0)     menu_additem(menu, "\wGALIL", "7", 0)     menu_additem(menu, "\wD3AU1 [Auto-Snipe]", "8", 0)     menu_additem(menu, "\wSCOUT", "9", 0)     menu_additem(menu, "\wBULLPUP", "10", 0)     menu_additem(menu, "\wMP5", "11", 0)     menu_additem(menu, "\wTMP", "12", 0)     menu_additem(menu, "\wMAC 10", "13", 0)     menu_additem(menu, "\wUMP45", "14", 0)     menu_additem(menu, "\wP90", "15", 0)     menu_additem(menu, "\wM249 [Machine Gun]", "16", 0)     menu_additem(menu, "\wXM1014", "17", 0)     menu_additem(menu, "\wM3", "18", 0)         menu_setprop( menu, MPROP_EXIT, MEXIT_ALL )     menu_display( id, menu, 0 )         return PLUGIN_CONTINUE; } public menu_handler(id, menu, item) {     if(item == MENU_EXIT)     {         menu_destroy(menu);         return PLUGIN_HANDLED;     }         switch(item)     {         case 1:         {             give_item(id, "weapon_awp")             cs_set_user_bpammo(id, CSW_AWP, 30)         }         case 2:         {             give_item(id, "weapon_m4a1")             cs_set_user_bpammo(id, CSW_M4A1, 90)         }         case 3:         {             give_item(id, "weapon_ak47")             cs_set_user_bpammo(id, CSW_AK47, 90)         }         case 4:         {             give_item(id, "weapon_sg552")             cs_set_user_bpammo(id, CSW_SG552, 90)         }         case 5:         {             give_item(id, "weapon_famas")             cs_set_user_bpammo(id, CSW_FAMAS, 90)         }         case 6:         {             give_item(id, "weapon_sg550")             cs_set_user_bpammo(id, CSW_SG550, 90)         }         case 7:         {             give_item(id, "weapon_galil")             cs_set_user_bpammo(id, CSW_GALIL, 90)         }         case 8:         {             give_item(id, "weapon_g3sg1")             cs_set_user_bpammo(id, CSW_G3SG1, 90)         }         case 9:         {             give_item(id, "weapon_scout")             cs_set_user_bpammo(id, CSW_SCOUT, 90)         }         case 10:         {             give_item(id, "weapon_aug")             cs_set_user_bpammo(id, CSW_AUG, 90)         }         case 11:         {             give_item(id, "weapon_mp5navy")             cs_set_user_bpammo(id, CSW_MP5NAVY, 120)         }         case 12:         {             give_item(id, "weapon_tmp")             cs_set_user_bpammo(id, CSW_TMP, 120)         }         case 13:         {             give_item(id, "weapon_mac10")             cs_set_user_bpammo(id, CSW_MAC10, 120)         }         case 14:         {             give_item(id, "weapon_ump45")             cs_set_user_bpammo(id, CSW_UMP45, 100)                     }         case 15:         {             give_item(id, "weapon_p90")             cs_set_user_bpammo(id, CSW_P90, 100)                     }         case 16:         {             give_item(id, "weapon_m249")             cs_set_user_bpammo(id, CSW_M249, 90)         }         case 17:         {             give_item(id, "weapon_m3")             cs_set_user_bpammo(id, CSW_M3, 90)         }         case 18:         {             give_item(id, "weapon_xm1014")             cs_set_user_bpammo(id, CSW_XM1014, 90)         }     }         if(++count[id] < 2)     {         primary_wep_menu(id);     }     else     {         // call here your secondary weapon menu >>> secondary_wep_menu(id);     }         menu_destroy(menu);     return PLUGIN_CONTINUE; }

Last edited by KiLLeR.; 09-25-2017 at 14:03.
KiLLeR. 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 14:37.


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