Limit Item ( Extra Items )

Unpaid Requests, Public Plugins
Post Reply
User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

Limit Item ( Extra Items )

#1

Post by VicKy » 2 years ago

Hi I tried To Add Limit To Extra Items
But Not Working
  1. #include <zombie_escape>
  2.  
  3. // Keys
  4. const OFFSET_CSMENUCODE = 205
  5. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
  6. new bool:g_iBuyTimes[33], g_pCvarBuyTimes
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
  11.    
  12.     // Commands
  13.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
  14.     register_clcmd("jointeam", "Cmd_ChooseTeam")
  15.     register_clcmd("say /ze", "Cmd_ChooseTeam")
  16.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
  17.     g_pCvarBuyTimes = register_cvar("items_buy_limit", "2")
  18.    
  19.     // Register Menus
  20.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
  21. }
  22.  
  23. public ze_user_humanized(id)
  24. {
  25.     g_iBuyTimes[id] = 0
  26. }
  27.  
  28. public ze_user_infected(Victim)
  29. {
  30.     g_iBuyTimes[Victim] = 0
  31. }
  32.  
  33. public client_putinserver(id)
  34. {
  35.     g_iBuyTimes[id] = 0
  36. }
  37.  
  38. public client_disconnected(id)
  39. {
  40.     g_iBuyTimes[id] = 0
  41. }
  42.  
  43. public Cmd_ChooseTeam(id)
  44. {
  45.     if (!is_user_connected(id))
  46.         return PLUGIN_CONTINUE;
  47.    
  48.     if (get_member(id, m_iTeam) == TEAM_TERRORIST || get_member(id, m_iTeam) == TEAM_CT)
  49.     {
  50.         Show_Menu_Main(id)
  51.         return PLUGIN_HANDLED // Kill the Choose Team Command
  52.     }
  53.    
  54.     // Player in Spec? Allow him to open choose team menu so he can join
  55.     return PLUGIN_CONTINUE
  56. }
  57.  
  58. // Main Menu
  59. public Show_Menu_Main(id)
  60. {
  61.     static szMenu[250]
  62.     new iLen
  63.    
  64.     // Title
  65.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
  66.    
  67.     // 1. Buy Weapons
  68.     if (!ze_is_auto_buy_enabled(id)) // AutoBuy not enabled - normal case
  69.     {
  70.         if (is_user_alive(id))
  71.         {
  72.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
  73.         }
  74.         else
  75.         {
  76.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
  77.         }
  78.     }
  79.     else
  80.     {
  81.         // Auto-Buy enabled - Re-enable case
  82.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY_RE_ENABLE")
  83.     }
  84.    
  85.     // 2. Extra Items
  86.     if (is_user_alive(id))
  87.     {
  88.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
  89.     }
  90.     else
  91.     {
  92.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
  93.     }
  94.    
  95.     // 0. Exit
  96.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
  97.    
  98.     // Fix for AMXX custom menus
  99.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  100.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
  101. }
  102.  
  103. // Main Menu
  104. public Main_Menu(id, key)
  105. {
  106.     // Player disconnected?
  107.     if (!is_user_connected(id))
  108.         return PLUGIN_HANDLED
  109.    
  110.     switch (key)
  111.     {
  112.         case 0: // Buy Weapons
  113.         {
  114.             if (!ze_is_auto_buy_enabled(id))
  115.             {
  116.                 ze_show_weapon_menu(id)
  117.             }
  118.             else
  119.             {
  120.                 ze_disable_auto_buy(id)
  121.                 Show_Menu_Main(id)
  122.             }
  123.         }
  124.         case 1: // Extra Items
  125.         {
  126.                 if (g_iBuyTimes[id] >= get_pcvar_num(g_pCvarBuyTimes))
  127.                           {
  128.                                     ze_colored_print(id, "!tMaximum have been reached !y[!g%d!y]!", get_pcvar_num(g_pCvarBuyTimes))
  129.                              return PLUGIN_HANDLED
  130.                            }
  131.  
  132.             if (is_user_alive(id))
  133.             {
  134.                 ze_show_items_menu(id)
  135.             }
  136.             else
  137.             {
  138.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
  139.             }
  140.         }
  141.     }
  142.     return PLUGIN_HANDLED
  143. }
Image

User avatar
Evillious Energy
Member
Member
Nepal
Posts: 22
Joined: 3 years ago
Contact:

#2

Post by Evillious Energy » 2 years ago

VicKy wrote: 2 years ago Hi I tried To Add Limit To Extra Items
But Not Working
  1. #include <zombie_escape>
  2.  
  3. // Keys
  4. const OFFSET_CSMENUCODE = 205
  5. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
  6. new bool:g_iBuyTimes[33], g_pCvarBuyTimes
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
  11.    
  12.     // Commands
  13.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
  14.     register_clcmd("jointeam", "Cmd_ChooseTeam")
  15.     register_clcmd("say /ze", "Cmd_ChooseTeam")
  16.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
  17.     g_pCvarBuyTimes = register_cvar("items_buy_limit", "2")
  18.    
  19.     // Register Menus
  20.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
  21. }
  22.  
  23. public ze_user_humanized(id)
  24. {
  25.     g_iBuyTimes[id] = 0
  26. }
  27.  
  28. public ze_user_infected(Victim)
  29. {
  30.     g_iBuyTimes[Victim] = 0
  31. }
  32.  
  33. public client_putinserver(id)
  34. {
  35.     g_iBuyTimes[id] = 0
  36. }
  37.  
  38. public client_disconnected(id)
  39. {
  40.     g_iBuyTimes[id] = 0
  41. }
  42.  
  43. public Cmd_ChooseTeam(id)
  44. {
  45.     if (!is_user_connected(id))
  46.         return PLUGIN_CONTINUE;
  47.    
  48.     if (get_member(id, m_iTeam) == TEAM_TERRORIST || get_member(id, m_iTeam) == TEAM_CT)
  49.     {
  50.         Show_Menu_Main(id)
  51.         return PLUGIN_HANDLED // Kill the Choose Team Command
  52.     }
  53.    
  54.     // Player in Spec? Allow him to open choose team menu so he can join
  55.     return PLUGIN_CONTINUE
  56. }
  57.  
  58. // Main Menu
  59. public Show_Menu_Main(id)
  60. {
  61.     static szMenu[250]
  62.     new iLen
  63.    
  64.     // Title
  65.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
  66.    
  67.     // 1. Buy Weapons
  68.     if (!ze_is_auto_buy_enabled(id)) // AutoBuy not enabled - normal case
  69.     {
  70.         if (is_user_alive(id))
  71.         {
  72.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
  73.         }
  74.         else
  75.         {
  76.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
  77.         }
  78.     }
  79.     else
  80.     {
  81.         // Auto-Buy enabled - Re-enable case
  82.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY_RE_ENABLE")
  83.     }
  84.    
  85.     // 2. Extra Items
  86.     if (is_user_alive(id))
  87.     {
  88.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
  89.     }
  90.     else
  91.     {
  92.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
  93.     }
  94.    
  95.     // 0. Exit
  96.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
  97.    
  98.     // Fix for AMXX custom menus
  99.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  100.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
  101. }
  102.  
  103. // Main Menu
  104. public Main_Menu(id, key)
  105. {
  106.     // Player disconnected?
  107.     if (!is_user_connected(id))
  108.         return PLUGIN_HANDLED
  109.    
  110.     switch (key)
  111.     {
  112.         case 0: // Buy Weapons
  113.         {
  114.             if (!ze_is_auto_buy_enabled(id))
  115.             {
  116.                 ze_show_weapon_menu(id)
  117.             }
  118.             else
  119.             {
  120.                 ze_disable_auto_buy(id)
  121.                 Show_Menu_Main(id)
  122.             }
  123.         }
  124.         case 1: // Extra Items
  125.         {
  126.                 if (g_iBuyTimes[id] >= get_pcvar_num(g_pCvarBuyTimes))
  127.                           {
  128.                                     ze_colored_print(id, "!tMaximum have been reached !y[!g%d!y]!", get_pcvar_num(g_pCvarBuyTimes))
  129.                              return PLUGIN_HANDLED
  130.                            }
  131.  
  132.             if (is_user_alive(id))
  133.             {
  134.                 ze_show_items_menu(id)
  135.             }
  136.             else
  137.             {
  138.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
  139.             }
  140.         }
  141.     }
  142.     return PLUGIN_HANDLED
  143. }
I believe that u can limit extra items from ini file in configs folder of extra items..

ze_extraitems.ini..

For example after u go to ini file...

this is one of the item named gungnir
[Gungnir]
NAME = Gungnir
COST = 350
LIMIT = 0
GLOBAL LIMIT = 0

So if we change "LIMIT = 0" to
[Gungnir]
NAME = Gungnir
COST = 350
LIMIT = 1
GLOBAL LIMIT = 0

Also LIMIT = 0 Means user can buy unlimited time per round...

Then user can buy it once a round..
51.79.157.106:27017

User avatar
Evillious Energy
Member
Member
Nepal
Posts: 22
Joined: 3 years ago
Contact:

#3

Post by Evillious Energy » 2 years ago

Evillious Energy wrote: 2 years ago
VicKy wrote: 2 years ago Hi I tried To Add Limit To Extra Items
But Not Working
  1. #include <zombie_escape>
  2.  
  3. // Keys
  4. const OFFSET_CSMENUCODE = 205
  5. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
  6. new bool:g_iBuyTimes[33], g_pCvarBuyTimes
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
  11.    
  12.     // Commands
  13.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
  14.     register_clcmd("jointeam", "Cmd_ChooseTeam")
  15.     register_clcmd("say /ze", "Cmd_ChooseTeam")
  16.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
  17.     g_pCvarBuyTimes = register_cvar("items_buy_limit", "2")
  18.    
  19.     // Register Menus
  20.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
  21. }
  22.  
  23. public ze_user_humanized(id)
  24. {
  25.     g_iBuyTimes[id] = 0
  26. }
  27.  
  28. public ze_user_infected(Victim)
  29. {
  30.     g_iBuyTimes[Victim] = 0
  31. }
  32.  
  33. public client_putinserver(id)
  34. {
  35.     g_iBuyTimes[id] = 0
  36. }
  37.  
  38. public client_disconnected(id)
  39. {
  40.     g_iBuyTimes[id] = 0
  41. }
  42.  
  43. public Cmd_ChooseTeam(id)
  44. {
  45.     if (!is_user_connected(id))
  46.         return PLUGIN_CONTINUE;
  47.    
  48.     if (get_member(id, m_iTeam) == TEAM_TERRORIST || get_member(id, m_iTeam) == TEAM_CT)
  49.     {
  50.         Show_Menu_Main(id)
  51.         return PLUGIN_HANDLED // Kill the Choose Team Command
  52.     }
  53.    
  54.     // Player in Spec? Allow him to open choose team menu so he can join
  55.     return PLUGIN_CONTINUE
  56. }
  57.  
  58. // Main Menu
  59. public Show_Menu_Main(id)
  60. {
  61.     static szMenu[250]
  62.     new iLen
  63.    
  64.     // Title
  65.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
  66.    
  67.     // 1. Buy Weapons
  68.     if (!ze_is_auto_buy_enabled(id)) // AutoBuy not enabled - normal case
  69.     {
  70.         if (is_user_alive(id))
  71.         {
  72.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
  73.         }
  74.         else
  75.         {
  76.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
  77.         }
  78.     }
  79.     else
  80.     {
  81.         // Auto-Buy enabled - Re-enable case
  82.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY_RE_ENABLE")
  83.     }
  84.    
  85.     // 2. Extra Items
  86.     if (is_user_alive(id))
  87.     {
  88.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
  89.     }
  90.     else
  91.     {
  92.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
  93.     }
  94.    
  95.     // 0. Exit
  96.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
  97.    
  98.     // Fix for AMXX custom menus
  99.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  100.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
  101. }
  102.  
  103. // Main Menu
  104. public Main_Menu(id, key)
  105. {
  106.     // Player disconnected?
  107.     if (!is_user_connected(id))
  108.         return PLUGIN_HANDLED
  109.    
  110.     switch (key)
  111.     {
  112.         case 0: // Buy Weapons
  113.         {
  114.             if (!ze_is_auto_buy_enabled(id))
  115.             {
  116.                 ze_show_weapon_menu(id)
  117.             }
  118.             else
  119.             {
  120.                 ze_disable_auto_buy(id)
  121.                 Show_Menu_Main(id)
  122.             }
  123.         }
  124.         case 1: // Extra Items
  125.         {
  126.                 if (g_iBuyTimes[id] >= get_pcvar_num(g_pCvarBuyTimes))
  127.                           {
  128.                                     ze_colored_print(id, "!tMaximum have been reached !y[!g%d!y]!", get_pcvar_num(g_pCvarBuyTimes))
  129.                              return PLUGIN_HANDLED
  130.                            }
  131.  
  132.             if (is_user_alive(id))
  133.             {
  134.                 ze_show_items_menu(id)
  135.             }
  136.             else
  137.             {
  138.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
  139.             }
  140.         }
  141.     }
  142.     return PLUGIN_HANDLED
  143. }
I believe that u can limit extra items from ini file in configs folder of extra items..

ze_extraitems.ini..

For example after u go to ini file...

this is one of the item named gungnir
[Gungnir]
NAME = Gungnir
COST = 350
LIMIT = 0
GLOBAL LIMIT = 0

So if we change "LIMIT = 0" to
[Gungnir]
NAME = Gungnir
COST = 350
LIMIT = 1
GLOBAL LIMIT = 0

Also LIMIT = 0 Means user can buy unlimited time per round...

Then user can buy it once a round..
And if you want to make the limit of whole extra item menu 2 times per round instead if try use looping statement...
51.79.157.106:27017

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#4

Post by VicKy » 2 years ago

yes i want to add limit to whole extra items menu i just add 2 just for testing but i not working
Image

User avatar
Evillious Energy
Member
Member
Nepal
Posts: 22
Joined: 3 years ago
Contact:

#5

Post by Evillious Energy » 2 years ago

VicKy wrote: 2 years ago yes i want to add limit to whole extra items menu i just add 2 just for testing but i not working
wait...
51.79.157.106:27017

User avatar
Evillious Energy
Member
Member
Nepal
Posts: 22
Joined: 3 years ago
Contact:

#6

Post by Evillious Energy » 2 years ago

VicKy wrote: 2 years ago Hi I tried To Add Limit To Extra Items
But Not Working
  1. #include <zombie_escape>
  2.  
  3. // Keys
  4. const OFFSET_CSMENUCODE = 205
  5. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
  6. new bool:g_iBuyTimes[33], g_pCvarBuyTimes
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
  11.    
  12.     // Commands
  13.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
  14.     register_clcmd("jointeam", "Cmd_ChooseTeam")
  15.     register_clcmd("say /ze", "Cmd_ChooseTeam")
  16.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
  17.     g_pCvarBuyTimes = register_cvar("items_buy_limit", "2")
  18.    
  19.     // Register Menus
  20.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
  21. }
  22.  
  23. public ze_user_humanized(id)
  24. {
  25.     g_iBuyTimes[id] = 0
  26. }
  27.  
  28. public ze_user_infected(Victim)
  29. {
  30.     g_iBuyTimes[Victim] = 0
  31. }
  32.  
  33. public client_putinserver(id)
  34. {
  35.     g_iBuyTimes[id] = 0
  36. }
  37.  
  38. public client_disconnected(id)
  39. {
  40.     g_iBuyTimes[id] = 0
  41. }
  42.  
  43. public Cmd_ChooseTeam(id)
  44. {
  45.     if (!is_user_connected(id))
  46.         return PLUGIN_CONTINUE;
  47.    
  48.     if (get_member(id, m_iTeam) == TEAM_TERRORIST || get_member(id, m_iTeam) == TEAM_CT)
  49.     {
  50.         Show_Menu_Main(id)
  51.         return PLUGIN_HANDLED // Kill the Choose Team Command
  52.     }
  53.    
  54.     // Player in Spec? Allow him to open choose team menu so he can join
  55.     return PLUGIN_CONTINUE
  56. }
  57.  
  58. // Main Menu
  59. public Show_Menu_Main(id)
  60. {
  61.     static szMenu[250]
  62.     new iLen
  63.    
  64.     // Title
  65.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
  66.    
  67.     // 1. Buy Weapons
  68.     if (!ze_is_auto_buy_enabled(id)) // AutoBuy not enabled - normal case
  69.     {
  70.         if (is_user_alive(id))
  71.         {
  72.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
  73.         }
  74.         else
  75.         {
  76.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
  77.         }
  78.     }
  79.     else
  80.     {
  81.         // Auto-Buy enabled - Re-enable case
  82.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY_RE_ENABLE")
  83.     }
  84.    
  85.     // 2. Extra Items
  86.     if (is_user_alive(id))
  87.     {
  88.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
  89.     }
  90.     else
  91.     {
  92.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
  93.     }
  94.    
  95.     // 0. Exit
  96.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
  97.    
  98.     // Fix for AMXX custom menus
  99.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  100.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
  101. }
  102.  
  103. // Main Menu
  104. public Main_Menu(id, key)
  105. {
  106.     // Player disconnected?
  107.     if (!is_user_connected(id))
  108.         return PLUGIN_HANDLED
  109.    
  110.     switch (key)
  111.     {
  112.         case 0: // Buy Weapons
  113.         {
  114.             if (!ze_is_auto_buy_enabled(id))
  115.             {
  116.                 ze_show_weapon_menu(id)
  117.             }
  118.             else
  119.             {
  120.                 ze_disable_auto_buy(id)
  121.                 Show_Menu_Main(id)
  122.             }
  123.         }
  124.         case 1: // Extra Items
  125.         {
  126.                 if (g_iBuyTimes[id] >= get_pcvar_num(g_pCvarBuyTimes))
  127.                           {
  128.                                     ze_colored_print(id, "!tMaximum have been reached !y[!g%d!y]!", get_pcvar_num(g_pCvarBuyTimes))
  129.                              return PLUGIN_HANDLED
  130.                            }
  131.  
  132.             if (is_user_alive(id))
  133.             {
  134.                 ze_show_items_menu(id)
  135.             }
  136.             else
  137.             {
  138.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
  139.             }
  140.         }
  141.     }
  142.     return PLUGIN_HANDLED
  143. }
Try this..

Code: Select all

#include <zombie_escape>

new cvar_item_buy_limit
new item_buy_limit[33]

// Keys
const OFFSET_CSMENUCODE = 205
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0

public plugin_init()
{
	register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
	
	// Commands
	register_clcmd("chooseteam", "Cmd_ChooseTeam")
	register_clcmd("jointeam", "Cmd_ChooseTeam")
	register_clcmd("say /ze", "Cmd_ChooseTeam")
	register_clcmd("say_team /ze", "Cmd_ChooseTeam")

	cvar_item_buy_limit = register_cvar("ze_item_buy_limit", "2")
	
	// Register Menus
	register_menu("Main Menu", KEYSMENU, "Main_Menu")
}

public event_round_start()
{
	arrayset(item_buy_limit, 0, sizeof item_buy_limit)
}

public Cmd_ChooseTeam(id)
{
	if (!is_user_connected(id))
		return PLUGIN_CONTINUE;
	
	if (get_member(id, m_iTeam) == TEAM_TERRORIST || get_member(id, m_iTeam) == TEAM_CT)
	{
		Show_Menu_Main(id)
		return PLUGIN_HANDLED // Kill the Choose Team Command
	}
	
	// Player in Spec? Allow him to open choose team menu so he can join
	return PLUGIN_CONTINUE
}

// Main Menu
public Show_Menu_Main(id)
{
	static szMenu[250]
	new iLen
    
	// Title
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
	
	// 1. Buy Weapons
	if (!ze_is_auto_buy_enabled(id)) // AutoBuy not enabled - normal case
	{
		if (is_user_alive(id))
		{
			iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
		}
		else
		{
			iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
		}
	}
	else
	{
		// Auto-Buy enabled - Re-enable case
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY_RE_ENABLE")
	}
	
	// 2. Extra Items
	if (is_user_alive(id))
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
	}
	else
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
	}
	
	// 3. Knife menu
	if (is_user_alive(id))
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w3.\r Knife menu^n")
	}
	else
	{
		iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d3. Knife menu^n")
	}
    
	// 0. Exit
	iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
	

    
	// Fix for AMXX custom menus
	set_pdata_int(id, OFFSET_CSMENUCODE, 0)
	show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
}

// Main Menu
public Main_Menu(id, key)
{
	// Player disconnected?
	if (!is_user_connected(id))
		return PLUGIN_HANDLED
    
	switch (key)
	{
		case 0: // Buy Weapons
		{
			if (!ze_is_auto_buy_enabled(id))
			{
				ze_show_weapon_menu(id)
			}
			else
			{
				ze_disable_auto_buy(id)
				Show_Menu_Main(id)
			}
		}
		case 1: // Extra Items
		{
			if (is_user_alive(id))
			{
				if(item_buy_limit[id] < get_pcvar_num(cvar_item_buy_limit))
				{
					item_buy_limit[id]++;
					ze_show_items_menu(id)
				}
				else
				{
					ze_colored_print(id, "Maximum purchased limit reached")
				}
			}
			else
			{
				ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
			}
		}
	}
	return PLUGIN_HANDLED
}
Add

Code: Select all

register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
In plugin_init() i forgot to add it so add it then it will work.. still not tested if will not work reply here...
51.79.157.106:27017

User avatar
Evillious Energy
Member
Member
Nepal
Posts: 22
Joined: 3 years ago
Contact:

#7

Post by Evillious Energy » 2 years ago

VicKy wrote: 2 years ago Hi I tried To Add Limit To Extra Items
But Not Working
  1. #include <zombie_escape>
  2.  
  3. // Keys
  4. const OFFSET_CSMENUCODE = 205
  5. const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
  6. new bool:g_iBuyTimes[33], g_pCvarBuyTimes
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin("[ZE] Main Menu", ZE_VERSION, AUTHORS)
  11.    
  12.     // Commands
  13.     register_clcmd("chooseteam", "Cmd_ChooseTeam")
  14.     register_clcmd("jointeam", "Cmd_ChooseTeam")
  15.     register_clcmd("say /ze", "Cmd_ChooseTeam")
  16.     register_clcmd("say_team /ze", "Cmd_ChooseTeam")
  17.     g_pCvarBuyTimes = register_cvar("items_buy_limit", "2")
  18.    
  19.     // Register Menus
  20.     register_menu("Main Menu", KEYSMENU, "Main_Menu")
  21. }
  22.  
  23. public ze_user_humanized(id)
  24. {
  25.     g_iBuyTimes[id] = 0
  26. }
  27.  
  28. public ze_user_infected(Victim)
  29. {
  30.     g_iBuyTimes[Victim] = 0
  31. }
  32.  
  33. public client_putinserver(id)
  34. {
  35.     g_iBuyTimes[id] = 0
  36. }
  37.  
  38. public client_disconnected(id)
  39. {
  40.     g_iBuyTimes[id] = 0
  41. }
  42.  
  43. public Cmd_ChooseTeam(id)
  44. {
  45.     if (!is_user_connected(id))
  46.         return PLUGIN_CONTINUE;
  47.    
  48.     if (get_member(id, m_iTeam) == TEAM_TERRORIST || get_member(id, m_iTeam) == TEAM_CT)
  49.     {
  50.         Show_Menu_Main(id)
  51.         return PLUGIN_HANDLED // Kill the Choose Team Command
  52.     }
  53.    
  54.     // Player in Spec? Allow him to open choose team menu so he can join
  55.     return PLUGIN_CONTINUE
  56. }
  57.  
  58. // Main Menu
  59. public Show_Menu_Main(id)
  60. {
  61.     static szMenu[250]
  62.     new iLen
  63.    
  64.     // Title
  65.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%L^n^n", id, "MAIN_MENU_TITLE")
  66.    
  67.     // 1. Buy Weapons
  68.     if (!ze_is_auto_buy_enabled(id)) // AutoBuy not enabled - normal case
  69.     {
  70.         if (is_user_alive(id))
  71.         {
  72.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY")
  73.         }
  74.         else
  75.         {
  76.             iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d1. %L^n", id, "MENU_WEAPONBUY")
  77.         }
  78.     }
  79.     else
  80.     {
  81.         // Auto-Buy enabled - Re-enable case
  82.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w1.\r %L^n", id, "MENU_WEAPONBUY_RE_ENABLE")
  83.     }
  84.    
  85.     // 2. Extra Items
  86.     if (is_user_alive(id))
  87.     {
  88.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w2.\r %L^n", id, "MENU_EXTRABUY")
  89.     }
  90.     else
  91.     {
  92.         iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d2. %L^n", id, "MENU_EXTRABUY")
  93.     }
  94.    
  95.     // 0. Exit
  96.     iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\r %L", id, "EXIT")
  97.    
  98.     // Fix for AMXX custom menus
  99.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  100.     show_menu(id, KEYSMENU, szMenu, -1, "Main Menu")
  101. }
  102.  
  103. // Main Menu
  104. public Main_Menu(id, key)
  105. {
  106.     // Player disconnected?
  107.     if (!is_user_connected(id))
  108.         return PLUGIN_HANDLED
  109.    
  110.     switch (key)
  111.     {
  112.         case 0: // Buy Weapons
  113.         {
  114.             if (!ze_is_auto_buy_enabled(id))
  115.             {
  116.                 ze_show_weapon_menu(id)
  117.             }
  118.             else
  119.             {
  120.                 ze_disable_auto_buy(id)
  121.                 Show_Menu_Main(id)
  122.             }
  123.         }
  124.         case 1: // Extra Items
  125.         {
  126.                 if (g_iBuyTimes[id] >= get_pcvar_num(g_pCvarBuyTimes))
  127.                           {
  128.                                     ze_colored_print(id, "!tMaximum have been reached !y[!g%d!y]!", get_pcvar_num(g_pCvarBuyTimes))
  129.                              return PLUGIN_HANDLED
  130.                            }
  131.  
  132.             if (is_user_alive(id))
  133.             {
  134.                 ze_show_items_menu(id)
  135.             }
  136.             else
  137.             {
  138.                 ze_colored_print(id, "%L", id, "DEAD_CANT_BUY_WEAPON")
  139.             }
  140.         }
  141.     }
  142.     return PLUGIN_HANDLED
  143. }
And you shouldn't use bool when defining something new boolean [new bool: name[33]] it denotes the array or what ever the name is it make it false... there is no use of booleans that u used in ur editing...
51.79.157.106:27017

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#8

Post by VicKy » 2 years ago

Worked Thanks
Image

User avatar
Evillious Energy
Member
Member
Nepal
Posts: 22
Joined: 3 years ago
Contact:

#9

Post by Evillious Energy » 2 years ago

VicKy wrote: 2 years agoWorked Thanks
<3
51.79.157.106:27017

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: Ahrefs [Bot] and 11 guests