Hi, you can do the following:
1. Make a global for limit for player: new g_iLimit[33];
2. Set g_iLimit[id] to 0 on client_disconnected & client_putinserver.
3. Now, when on selection case put g_iLimit[id]++ it will add +1 to limit for example if its for limit 1
4. Before selection case make a check like
if(g_iLimit[id] == 1) {
client_print(id,print_chat, "Oops seems like you've hit the limit!")
return PLUGIN_HANDLED ;
}
5. Done.
An example is given here.
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <hamsandwich>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Author"
new g_iLimit[33]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /menu", "menux")
RegisterHam(Ham_Spawn, "player", "fw_Spawn", 1)
}
public client_putinserver(id) {
g_iLimit[id] = 0
}
public client_disconnected(id) {
g_iLimit[id] = 0
}
public fw_Spawn(id) {
g_iLimit[id] = 0
}
public menux(id) {
new menu = menu_create("example menu", "menu_handler")
menu_additem(menu, "ITEM", "", 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)
}
if(is_user_connected(id))
{
switch(item) {
case 1: {
if(g_iLimit[id] == 1) // if want limit 1 then == 1 if 2 == 2 and increase like this so on
{
client_print(id, print_chat, "Oops! Seems like you've hit the item limit!")
return PLUGIN_HANDLED;
}
g_iLimit[id]++
// Here give the Item
client_print(id, print_chat, "You've selected the item for %d time", g_iLimit[id])
}
}
}
return PLUGIN_HANDLED;
}