HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <amx_settings_api>
  4. #include <zp50_core>
  5. #include <zp50_items>
  6.  
  7. #define PLUGIN "[ZP50] Class unlocker"
  8. #define VERSION "1.1"
  9. #define AUTHOR "Catastrophe"
  10.  
  11. #define MAX_LIST 128
  12. #define PLUGIN_MODE 1
  13.  
  14. new const EXTRAS_FILE[] = "zp_extra_limit.ini"
  15.  
  16. new Array:extra_id
  17. new Array:extra_limit
  18.  
  19. #if defined PLUGIN_MODE 1
  20. new extra_count[33][MAX_LIST]
  21. #endif
  22.  
  23. #if defined PLUGIN_MODE 2
  24. new extra_count_global[MAX_LIST]
  25. #endif
  26.  
  27. new zpel_cvars[3]
  28.  
  29. public plugin_init()
  30. {
  31. register_plugin(PLUGIN, VERSION, AUTHOR)
  32. register_event("HLTV", "event_newround", "a", "1=0", "2=0")
  33. register_cvar("ZPEL","1",(FCVAR_SERVER|FCVAR_SPONLY))
  34.  
  35. zpel_cvars[0] = register_cvar("zp_extra_limit_mode", "1")
  36. }
  37.  
  38. public plugin_precache()
  39. {
  40. extra_id = ArrayCreate(64, 1)
  41. extra_limit = ArrayCreate(4, 1)
  42.  
  43. amx_load_setting_string_arr(EXTRAS_FILE, "LIMIT", "item_id", extra_id)
  44. amx_load_setting_string_arr(EXTRAS_FILE, "LIMIT", "item_limit", extra_limit)
  45.  
  46. }
  47.  
  48. public event_newround()
  49. {
  50. if(get_pcvar_num(zpel_cvars[0]) != 0)
  51. return
  52.  
  53. #if defined PLUGIN_MODE 1
  54. for(new i = 1; i <= get_maxplayers(); i++)
  55. {
  56. arrayset(extra_count[i], 0, MAX_LIST - 1)
  57. }
  58. #endif
  59.  
  60. #if defined PLUGIN_MODE 2
  61. for(new j = 0; j <= MAX_LIST - 1; j++)
  62. {
  63. extra_count_global[j] = 0
  64. }
  65. #endif
  66. }
  67.  
  68. public zp_fw_items_select_pre(id, itemid, ignorecost)
  69. {
  70. new txt[32]
  71.  
  72. for(new i = 0; i <= ArraySize(extra_id) - 1; i++)
  73. {
  74. new e_id[64], e_lim[4]
  75. new e_lim_num
  76. ArrayGetString(extra_id, i, e_id, charsmax(e_id))
  77. ArrayGetString(extra_limit, i, e_lim, charsmax(e_lim))
  78. e_lim_num = str_to_num(e_lim)
  79.  
  80. if(itemid == zp_items_get_id(e_id))
  81. {
  82. #if defined PLUGIN_MODE 1
  83. if(extra_count[id][i] >= e_lim_num)
  84. {
  85. format(txt, charsmax(txt), "\d[%d/%d]", extra_count[id][i],e_lim_num)
  86. zp_items_menu_text_add(txt)
  87. return ZP_ITEM_NOT_AVAILABLE
  88. }
  89.  
  90. else
  91. {
  92. format(txt, charsmax(txt), "\w[%d/%d]", extra_count[id][i],e_lim_num)
  93. zp_items_menu_text_add(txt)
  94. return ZP_ITEM_AVAILABLE
  95. }
  96. #endif
  97.  
  98. #if defined PLUGIN_MODE 2
  99. if(extra_count_global[i] >= e_lim_num)
  100. {
  101. format(txt, charsmax(txt), "\d[%d/%d]", extra_count[i],e_lim_num)
  102. zp_items_menu_text_add(txt)
  103. return ZP_ITEM_NOT_AVAILABLE
  104. }
  105.  
  106. else
  107. {
  108. format(txt, charsmax(txt), "\w[%d/%d]", extra_count[i],e_lim_num)
  109. zp_items_menu_text_add(txt)
  110. return ZP_ITEM_AVAILABLE
  111. }
  112. #endif
  113. }
  114.  
  115. }
  116. return ZP_ITEM_AVAILABLE
  117. }
  118.  
  119. public zp_fw_items_select_post(id, itemid, ignorecost)
  120. {
  121.  
  122. for(new i = 0; i <= ArraySize(extra_id) - 1; i++)
  123. {
  124. new e_id[64]
  125. ArrayGetString(extra_id, i, e_id, charsmax(e_id))
  126.  
  127. if(itemid == zp_items_get_id(e_id))
  128. {
  129. #if defined PLUGIN_MODE 1
  130. extra_count[id][i]++
  131. #endif
  132.  
  133. #if defined PLUGIN_MODE 2
  134. extra_count_global[i]++
  135. #endif
  136. }
  137. }
  138. }
  139. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  140. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
  141. */
  142.