hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.03.28. 16:39



Jelenlévő felhasználók

Jelenleg 223 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 221 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Google [Bot], MateaBoss az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 2 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: ZM item
HozzászólásElküldve: 2018.06.09. 21:40 
Offline
Tud valamit

Csatlakozott: 2016.12.25. 12:43
Hozzászólások: 129
Megköszönt másnak: 35 alkalommal
Megköszönték neki: 4 alkalommal
Sziasztok!

Hogyan lehet meg oldani hogyha nincs elég ammo-ja akkor írja neki chatbe hogy kevés az ammoja?
  1. /*================================================================================
  2.    
  3.     --------------------------
  4.     -*- [ZP] Items Manager -*-
  5.     --------------------------
  6.    
  7.     This plugin is part of Zombie Plague Mod and is distributed under the
  8.     terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
  9.    
  10. ================================================================================*/
  11.  
  12. #include <amxmodx>
  13. #include <fakemeta>
  14. #include <amx_settings_api>
  15. #include <zp50_colorchat>
  16. #include <zp50_core_const>
  17. #include <zp50_items_const>
  18.  
  19. // Extra Items file
  20. new const ZP_EXTRAITEMS_FILE[] = "zp_extraitems.ini"
  21.  
  22. // CS Player PData Offsets (win32)
  23. const OFFSET_CSMENUCODE = 205
  24.  
  25. #define MAXPLAYERS 32
  26.  
  27. // For item list menu handlers
  28. #define MENU_PAGE_ITEMS g_menu_data[id]
  29. new g_menu_data[MAXPLAYERS+1]
  30.  
  31. enum _:TOTAL_FORWARDS
  32. {
  33.     FW_ITEM_SELECT_PRE = 0,
  34.     FW_ITEM_SELECT_POST
  35. }
  36. new g_Forwards[TOTAL_FORWARDS]
  37. new g_ForwardResult
  38.  
  39. // Items data
  40. new Array:g_ItemRealName
  41. new Array:g_ItemName
  42. new Array:g_ItemCost
  43. new g_ItemCount
  44. new g_AdditionalMenuText[32]
  45.  
  46. public plugin_init()
  47. {
  48.     register_plugin("[ZP] Items Manager", ZP_VERSION_STRING, "ZP Dev Team")
  49.    
  50.     register_clcmd("say /items", "clcmd_items")
  51.     register_clcmd("say items", "clcmd_items")
  52.    
  53.     g_Forwards[FW_ITEM_SELECT_PRE] = CreateMultiForward("zp_fw_items_select_pre", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL)
  54.     g_Forwards[FW_ITEM_SELECT_POST] = CreateMultiForward("zp_fw_items_select_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
  55. }
  56.  
  57. public plugin_natives()
  58. {
  59.     register_library("zp50_items")
  60.     register_native("zp_items_register", "native_items_register")
  61.     register_native("zp_items_get_id", "native_items_get_id")
  62.     register_native("zp_items_get_name", "native_items_get_name")
  63.     register_native("zp_items_get_real_name", "native_items_get_real_name")
  64.     register_native("zp_items_get_cost", "native_items_get_cost")
  65.     register_native("zp_items_show_menu", "native_items_show_menu")
  66.     register_native("zp_items_force_buy", "native_items_force_buy")
  67.     register_native("zp_items_menu_text_add", "native_items_menu_text_add")
  68.    
  69.     // Initialize dynamic arrays
  70.     g_ItemRealName = ArrayCreate(32, 1)
  71.     g_ItemName = ArrayCreate(32, 1)
  72.     g_ItemCost = ArrayCreate(1, 1)
  73. }
  74.  
  75. public native_items_register(plugin_id, num_params)
  76. {
  77.     new name[32], cost = get_param(2)
  78.     get_string(1, name, charsmax(name))
  79.    
  80.     if (strlen(name) < 1)
  81.     {
  82.         log_error(AMX_ERR_NATIVE, "[ZP] Can't register item with an empty name")
  83.         return ZP_INVALID_ITEM;
  84.     }
  85.    
  86.     new index, item_name[32]
  87.     for (index = 0; index < g_ItemCount; index++)
  88.     {
  89.         ArrayGetString(g_ItemRealName, index, item_name, charsmax(item_name))
  90.         if (equali(name, item_name))
  91.         {
  92.             log_error(AMX_ERR_NATIVE, "[ZP] Item already registered (%s)", name)
  93.             return ZP_INVALID_ITEM;
  94.         }
  95.     }
  96.    
  97.     // Load settings from extra items file
  98.     new real_name[32]
  99.     copy(real_name, charsmax(real_name), name)
  100.     ArrayPushString(g_ItemRealName, real_name)
  101.    
  102.     // Name
  103.     if (!amx_load_setting_string(ZP_EXTRAITEMS_FILE, real_name, "NAME", name, charsmax(name)))
  104.         amx_save_setting_string(ZP_EXTRAITEMS_FILE, real_name, "NAME", name)
  105.     ArrayPushString(g_ItemName, name)
  106.    
  107.     // Cost
  108.     if (!amx_load_setting_int(ZP_EXTRAITEMS_FILE, real_name, "COST", cost))
  109.         amx_save_setting_int(ZP_EXTRAITEMS_FILE, real_name, "COST", cost)
  110.     ArrayPushCell(g_ItemCost, cost)
  111.    
  112.     g_ItemCount++
  113.     return g_ItemCount - 1;
  114. }
  115.  
  116. public native_items_get_id(plugin_id, num_params)
  117. {
  118.     new real_name[32]
  119.     get_string(1, real_name, charsmax(real_name))
  120.    
  121.     // Loop through every item
  122.     new index, item_name[32]
  123.     for (index = 0; index < g_ItemCount; index++)
  124.     {
  125.         ArrayGetString(g_ItemRealName, index, item_name, charsmax(item_name))
  126.         if (equali(real_name, item_name))
  127.             return index;
  128.     }
  129.    
  130.     return ZP_INVALID_ITEM;
  131. }
  132.  
  133. public native_items_get_name(plugin_id, num_params)
  134. {
  135.     new item_id = get_param(1)
  136.    
  137.     if (item_id < 0 || item_id >= g_ItemCount)
  138.     {
  139.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
  140.         return false;
  141.     }
  142.    
  143.     new name[32]
  144.     ArrayGetString(g_ItemName, item_id, name, charsmax(name))
  145.    
  146.     new len = get_param(3)
  147.     set_string(2, name, len)
  148.     return true;
  149. }
  150.  
  151. public native_items_get_real_name(plugin_id, num_params)
  152. {
  153.     new item_id = get_param(1)
  154.    
  155.     if (item_id < 0 || item_id >= g_ItemCount)
  156.     {
  157.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
  158.         return false;
  159.     }
  160.    
  161.     new real_name[32]
  162.     ArrayGetString(g_ItemRealName, item_id, real_name, charsmax(real_name))
  163.    
  164.     new len = get_param(3)
  165.     set_string(2, real_name, len)
  166.     return true;
  167. }
  168.  
  169. public native_items_get_cost(plugin_id, num_params)
  170. {
  171.     new item_id = get_param(1)
  172.    
  173.     if (item_id < 0 || item_id >= g_ItemCount)
  174.     {
  175.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
  176.         return -1;
  177.     }
  178.    
  179.     return ArrayGetCell(g_ItemCost, item_id);
  180. }
  181.  
  182. public native_items_show_menu(plugin_id, num_params)
  183. {
  184.     new id = get_param(1)
  185.    
  186.     if (!is_user_connected(id))
  187.     {
  188.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  189.         return false;
  190.     }
  191.    
  192.     clcmd_items(id)
  193.     return true;
  194. }
  195.  
  196. public native_items_force_buy(plugin_id, num_params)
  197. {
  198.     new id = get_param(1)
  199.    
  200.     if (!is_user_connected(id))
  201.     {
  202.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  203.         return false;
  204.     }
  205.    
  206.     new item_id = get_param(2)
  207.    
  208.     if (item_id < 0 || item_id >= g_ItemCount)
  209.     {
  210.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
  211.         return false;
  212.     }
  213.    
  214.     new ignorecost = get_param(3)
  215.    
  216.     buy_item(id, item_id, ignorecost)
  217.     return true;
  218. }
  219.  
  220. public native_items_menu_text_add(plugin_id, num_params)
  221. {
  222.     static text[32]
  223.     get_string(1, text, charsmax(text))
  224.     format(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "%s%s", g_AdditionalMenuText, text)
  225. }
  226.  
  227. public client_disconnect(id)
  228. {
  229.     // Reset remembered menu pages
  230.     MENU_PAGE_ITEMS = 0
  231. }
  232.  
  233. public clcmd_items(id)
  234. {
  235.     // Player dead
  236.     if (!is_user_alive(id))
  237.         return;
  238.    
  239.     show_items_menu(id)
  240. }
  241.  
  242. // Items Menu
  243. show_items_menu(id)
  244. {
  245.     static menu[128], name[32], cost, transkey[64]
  246.     new menuid, index, itemdata[2]
  247.    
  248.     // Title
  249.     formatex(menu, charsmax(menu), "%L:\r", id, "MENU_EXTRABUY")
  250.     menuid = menu_create(menu, "menu_extraitems")
  251.    
  252.     // Item List
  253.     for (index = 0; index < g_ItemCount; index++)
  254.     {
  255.         // Additional text to display
  256.         g_AdditionalMenuText[0] = 0
  257.        
  258.         // Execute item select attempt forward
  259.         ExecuteForward(g_Forwards[FW_ITEM_SELECT_PRE], g_ForwardResult, id, index, 0)
  260.        
  261.         // Show item to player?
  262.         if (g_ForwardResult >= ZP_ITEM_DONT_SHOW)
  263.             continue;
  264.        
  265.         // Add Item Name and Cost
  266.         ArrayGetString(g_ItemName, index, name, charsmax(name))
  267.         cost = ArrayGetCell(g_ItemCost, index)
  268.        
  269.         // ML support for item name
  270.         formatex(transkey, charsmax(transkey), "ITEMNAME %s", name)
  271.         if (GetLangTransKey(transkey) != TransKey_Bad) formatex(name, charsmax(name), "%L", id, transkey)
  272.        
  273.         // Item available to player?
  274.         if (g_ForwardResult >= ZP_ITEM_NOT_AVAILABLE)
  275.             formatex(menu, charsmax(menu), "\d%s %d %s", name, cost, g_AdditionalMenuText)
  276.         else
  277.             formatex(menu, charsmax(menu), "%s \y%d \w%s", name, cost, g_AdditionalMenuText)
  278.        
  279.         itemdata[0] = index
  280.         itemdata[1] = 0
  281.         menu_additem(menuid, menu, itemdata)
  282.     }
  283.    
  284.     // No items to display?
  285.     if (menu_items(menuid) <= 0)
  286.     {
  287.         zp_colored_print(id, "%L", id, "NO_EXTRA_ITEMS")
  288.         menu_destroy(menuid)
  289.         return;
  290.     }
  291.    
  292.     // Back - Next - Exit
  293.     formatex(menu, charsmax(menu), "%L", id, "MENU_BACK")
  294.     menu_setprop(menuid, MPROP_BACKNAME, menu)
  295.     formatex(menu, charsmax(menu), "%L", id, "MENU_NEXT")
  296.     menu_setprop(menuid, MPROP_NEXTNAME, menu)
  297.     formatex(menu, charsmax(menu), "%L", id, "MENU_EXIT")
  298.     menu_setprop(menuid, MPROP_EXITNAME, menu)
  299.    
  300.     // If remembered page is greater than number of pages, clamp down the value
  301.     MENU_PAGE_ITEMS = min(MENU_PAGE_ITEMS, menu_pages(menuid)-1)
  302.    
  303.     // Fix for AMXX custom menus
  304.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  305.     menu_display(id, menuid, MENU_PAGE_ITEMS)
  306. }
  307.  
  308. // Items Menu
  309. public menu_extraitems(id, menuid, item)
  310. {
  311.     // Menu was closed
  312.     if (item == MENU_EXIT)
  313.     {
  314.         MENU_PAGE_ITEMS = 0
  315.         menu_destroy(menuid)
  316.         return PLUGIN_HANDLED;
  317.     }
  318.    
  319.     // Remember items menu page
  320.     MENU_PAGE_ITEMS = item / 7
  321.    
  322.     // Dead players are not allowed to buy items
  323.     if (!is_user_alive(id))
  324.     {
  325.         menu_destroy(menuid)
  326.         return PLUGIN_HANDLED;
  327.     }
  328.    
  329.     // Retrieve item id
  330.     new itemdata[2], dummy, itemid
  331.     menu_item_getinfo(menuid, item, dummy, itemdata, charsmax(itemdata), _, _, dummy)
  332.     itemid = itemdata[0]
  333.    
  334.     // Attempt to buy the item
  335.     buy_item(id, itemid)
  336.     menu_destroy(menuid)
  337.     return PLUGIN_HANDLED;
  338. }
  339.  
  340. // Buy Item
  341. buy_item(id, itemid, ignorecost = 0)
  342. {
  343.     // Execute item select attempt forward
  344.     ExecuteForward(g_Forwards[FW_ITEM_SELECT_PRE], g_ForwardResult, id, itemid, ignorecost)
  345.    
  346.     // Item available to player?
  347.     if (g_ForwardResult >= ZP_ITEM_NOT_AVAILABLE)
  348.         return;
  349.    
  350.     // Execute item selected forward
  351.     ExecuteForward(g_Forwards[FW_ITEM_SELECT_POST], g_ForwardResult, id, itemid, ignorecost)
  352. }


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: ZM item
HozzászólásElküldve: 2018.06.09. 22:54 
Offline
Jómunkásember
Avatar

Csatlakozott: 2016.02.10. 12:46
Hozzászólások: 429
Megköszönt másnak: 61 alkalommal
Megköszönték neki: 157 alkalommal
Szia. Parancsolj. Ha bármi gondot tapasztaltsz, írj.

  1. /*================================================================================
  2.    
  3.     --------------------------
  4.     -*- [ZP] Items Manager -*-
  5.     --------------------------
  6.    
  7.     This plugin is part of Zombie Plague Mod and is distributed under the
  8.     terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
  9.    
  10. ================================================================================*/
  11.  
  12. #include <amxmodx>
  13. #include <fakemeta>
  14. #include <amx_settings_api>
  15. #include <zp50_colorchat>
  16. #include <zp50_core_const>
  17. #include <zp50_items_const>
  18. #include <zp50_ammopacks>
  19.  
  20. // Extra Items file
  21. new const ZP_EXTRAITEMS_FILE[] = "zp_extraitems.ini"
  22.  
  23. // CS Player PData Offsets (win32)
  24. const OFFSET_CSMENUCODE = 205
  25.  
  26. #define MAXPLAYERS 32
  27.  
  28. // For item list menu handlers
  29. #define MENU_PAGE_ITEMS g_menu_data[id]
  30. new g_menu_data[MAXPLAYERS+1]
  31.  
  32. enum _:TOTAL_FORWARDS
  33. {
  34.     FW_ITEM_SELECT_PRE = 0,
  35.     FW_ITEM_SELECT_POST
  36. }
  37. new g_Forwards[TOTAL_FORWARDS]
  38. new g_ForwardResult
  39.  
  40. // Items data
  41. new Array:g_ItemRealName
  42. new Array:g_ItemName
  43. new Array:g_ItemCost
  44. new g_ItemCount
  45. new g_AdditionalMenuText[32]
  46.  
  47. public plugin_init()
  48. {
  49.     register_plugin("[ZP] Items Manager", ZP_VERSION_STRING, "ZP Dev Team")
  50.    
  51.     register_clcmd("say /items", "clcmd_items")
  52.     register_clcmd("say items", "clcmd_items")
  53.    
  54.     g_Forwards[FW_ITEM_SELECT_PRE] = CreateMultiForward("zp_fw_items_select_pre", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL)
  55.     g_Forwards[FW_ITEM_SELECT_POST] = CreateMultiForward("zp_fw_items_select_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
  56. }
  57.  
  58. public plugin_natives()
  59. {
  60.     register_library("zp50_items")
  61.     register_native("zp_items_register", "native_items_register")
  62.     register_native("zp_items_get_id", "native_items_get_id")
  63.     register_native("zp_items_get_name", "native_items_get_name")
  64.     register_native("zp_items_get_real_name", "native_items_get_real_name")
  65.     register_native("zp_items_get_cost", "native_items_get_cost")
  66.     register_native("zp_items_show_menu", "native_items_show_menu")
  67.     register_native("zp_items_force_buy", "native_items_force_buy")
  68.     register_native("zp_items_menu_text_add", "native_items_menu_text_add")
  69.    
  70.     // Initialize dynamic arrays
  71.     g_ItemRealName = ArrayCreate(32, 1)
  72.     g_ItemName = ArrayCreate(32, 1)
  73.     g_ItemCost = ArrayCreate(1, 1)
  74. }
  75.  
  76. public native_items_register(plugin_id, num_params)
  77. {
  78.     new name[32], cost = get_param(2)
  79.     get_string(1, name, charsmax(name))
  80.    
  81.     if (strlen(name) < 1)
  82.     {
  83.         log_error(AMX_ERR_NATIVE, "[ZP] Can't register item with an empty name")
  84.         return ZP_INVALID_ITEM;
  85.     }
  86.    
  87.     new index, item_name[32]
  88.     for (index = 0; index < g_ItemCount; index++)
  89.     {
  90.         ArrayGetString(g_ItemRealName, index, item_name, charsmax(item_name))
  91.         if (equali(name, item_name))
  92.         {
  93.             log_error(AMX_ERR_NATIVE, "[ZP] Item already registered (%s)", name)
  94.             return ZP_INVALID_ITEM;
  95.         }
  96.     }
  97.    
  98.     // Load settings from extra items file
  99.     new real_name[32]
  100.     copy(real_name, charsmax(real_name), name)
  101.     ArrayPushString(g_ItemRealName, real_name)
  102.    
  103.     // Name
  104.     if (!amx_load_setting_string(ZP_EXTRAITEMS_FILE, real_name, "NAME", name, charsmax(name)))
  105.         amx_save_setting_string(ZP_EXTRAITEMS_FILE, real_name, "NAME", name)
  106.     ArrayPushString(g_ItemName, name)
  107.    
  108.     // Cost
  109.     if (!amx_load_setting_int(ZP_EXTRAITEMS_FILE, real_name, "COST", cost))
  110.         amx_save_setting_int(ZP_EXTRAITEMS_FILE, real_name, "COST", cost)
  111.     ArrayPushCell(g_ItemCost, cost)
  112.    
  113.     g_ItemCount++
  114.     return g_ItemCount - 1;
  115. }
  116.  
  117. public native_items_get_id(plugin_id, num_params)
  118. {
  119.     new real_name[32]
  120.     get_string(1, real_name, charsmax(real_name))
  121.    
  122.     // Loop through every item
  123.     new index, item_name[32]
  124.     for (index = 0; index < g_ItemCount; index++)
  125.     {
  126.         ArrayGetString(g_ItemRealName, index, item_name, charsmax(item_name))
  127.         if (equali(real_name, item_name))
  128.             return index;
  129.     }
  130.    
  131.     return ZP_INVALID_ITEM;
  132. }
  133.  
  134. public native_items_get_name(plugin_id, num_params)
  135. {
  136.     new item_id = get_param(1)
  137.    
  138.     if (item_id < 0 || item_id >= g_ItemCount)
  139.     {
  140.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
  141.         return false;
  142.     }
  143.    
  144.     new name[32]
  145.     ArrayGetString(g_ItemName, item_id, name, charsmax(name))
  146.    
  147.     new len = get_param(3)
  148.     set_string(2, name, len)
  149.     return true;
  150. }
  151.  
  152. public native_items_get_real_name(plugin_id, num_params)
  153. {
  154.     new item_id = get_param(1)
  155.    
  156.     if (item_id < 0 || item_id >= g_ItemCount)
  157.     {
  158.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
  159.         return false;
  160.     }
  161.    
  162.     new real_name[32]
  163.     ArrayGetString(g_ItemRealName, item_id, real_name, charsmax(real_name))
  164.    
  165.     new len = get_param(3)
  166.     set_string(2, real_name, len)
  167.     return true;
  168. }
  169.  
  170. public native_items_get_cost(plugin_id, num_params)
  171. {
  172.     new item_id = get_param(1)
  173.    
  174.     if (item_id < 0 || item_id >= g_ItemCount)
  175.     {
  176.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
  177.         return -1;
  178.     }
  179.    
  180.     return ArrayGetCell(g_ItemCost, item_id);
  181. }
  182.  
  183. public native_items_show_menu(plugin_id, num_params)
  184. {
  185.     new id = get_param(1)
  186.    
  187.     if (!is_user_connected(id))
  188.     {
  189.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  190.         return false;
  191.     }
  192.    
  193.     clcmd_items(id)
  194.     return true;
  195. }
  196.  
  197. public native_items_force_buy(plugin_id, num_params)
  198. {
  199.     new id = get_param(1)
  200.    
  201.     if (!is_user_connected(id))
  202.     {
  203.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
  204.         return false;
  205.     }
  206.    
  207.     new item_id = get_param(2)
  208.    
  209.     if (item_id < 0 || item_id >= g_ItemCount)
  210.     {
  211.         log_error(AMX_ERR_NATIVE, "[ZP] Invalid item id (%d)", item_id)
  212.         return false;
  213.     }
  214.    
  215.     new ignorecost = get_param(3)
  216.    
  217.     buy_item(id, item_id, ignorecost)
  218.     return true;
  219. }
  220.  
  221. public native_items_menu_text_add(plugin_id, num_params)
  222. {
  223.     static text[32]
  224.     get_string(1, text, charsmax(text))
  225.     format(g_AdditionalMenuText, charsmax(g_AdditionalMenuText), "%s%s", g_AdditionalMenuText, text)
  226. }
  227.  
  228. public client_disconnect(id)
  229. {
  230.     // Reset remembered menu pages
  231.     MENU_PAGE_ITEMS = 0
  232. }
  233.  
  234. public clcmd_items(id)
  235. {
  236.     // Player dead
  237.     if (!is_user_alive(id))
  238.         return;
  239.    
  240.     show_items_menu(id)
  241. }
  242.  
  243. // Items Menu
  244. show_items_menu(id)
  245. {
  246.     static menu[128], name[32], cost, transkey[64]
  247.     new menuid, index, itemdata[2]
  248.    
  249.     // Title
  250.     formatex(menu, charsmax(menu), "%L:\r", id, "MENU_EXTRABUY")
  251.     menuid = menu_create(menu, "menu_extraitems")
  252.    
  253.     // Item List
  254.     for (index = 0; index < g_ItemCount; index++)
  255.     {
  256.         // Additional text to display
  257.         g_AdditionalMenuText[0] = 0
  258.        
  259.         // Execute item select attempt forward
  260.         ExecuteForward(g_Forwards[FW_ITEM_SELECT_PRE], g_ForwardResult, id, index, 0)
  261.        
  262.         // Show item to player?
  263.         if (g_ForwardResult >= ZP_ITEM_DONT_SHOW)
  264.             continue;
  265.        
  266.         // Add Item Name and Cost
  267.         ArrayGetString(g_ItemName, index, name, charsmax(name))
  268.         cost = ArrayGetCell(g_ItemCost, index)
  269.        
  270.         // ML support for item name
  271.         formatex(transkey, charsmax(transkey), "ITEMNAME %s", name)
  272.         if (GetLangTransKey(transkey) != TransKey_Bad) formatex(name, charsmax(name), "%L", id, transkey)
  273.        
  274.         // Item available to player?
  275.         if (g_ForwardResult >= ZP_ITEM_NOT_AVAILABLE)
  276.             formatex(menu, charsmax(menu), "\d%s %d %s", name, cost, g_AdditionalMenuText)
  277.         else
  278.             formatex(menu, charsmax(menu), "%s \y%d \w%s", name, cost, g_AdditionalMenuText)
  279.        
  280.         itemdata[0] = index
  281.         itemdata[1] = 0
  282.         menu_additem(menuid, menu, itemdata)
  283.     }
  284.    
  285.     // No items to display?
  286.     if (menu_items(menuid) <= 0)
  287.     {
  288.         zp_colored_print(id, "%L", id, "NO_EXTRA_ITEMS")
  289.         menu_destroy(menuid)
  290.         return;
  291.     }
  292.    
  293.     // Back - Next - Exit
  294.     formatex(menu, charsmax(menu), "%L", id, "MENU_BACK")
  295.     menu_setprop(menuid, MPROP_BACKNAME, menu)
  296.     formatex(menu, charsmax(menu), "%L", id, "MENU_NEXT")
  297.     menu_setprop(menuid, MPROP_NEXTNAME, menu)
  298.     formatex(menu, charsmax(menu), "%L", id, "MENU_EXIT")
  299.     menu_setprop(menuid, MPROP_EXITNAME, menu)
  300.    
  301.     // If remembered page is greater than number of pages, clamp down the value
  302.     MENU_PAGE_ITEMS = min(MENU_PAGE_ITEMS, menu_pages(menuid)-1)
  303.    
  304.     // Fix for AMXX custom menus
  305.     set_pdata_int(id, OFFSET_CSMENUCODE, 0)
  306.     menu_display(id, menuid, MENU_PAGE_ITEMS)
  307. }
  308.  
  309. // Items Menu
  310. public menu_extraitems(id, menuid, item)
  311. {
  312.     // Menu was closed
  313.     if (item == MENU_EXIT)
  314.     {
  315.         MENU_PAGE_ITEMS = 0
  316.         menu_destroy(menuid)
  317.         return PLUGIN_HANDLED;
  318.     }
  319.    
  320.     // Remember items menu page
  321.     MENU_PAGE_ITEMS = item / 7
  322.    
  323.     // Dead players are not allowed to buy items
  324.     if (!is_user_alive(id))
  325.     {
  326.         menu_destroy(menuid)
  327.         return PLUGIN_HANDLED;
  328.     }
  329.    
  330.     // Retrieve item id
  331.     new itemdata[2], dummy, itemid, cost
  332.     menu_item_getinfo(menuid, item, dummy, itemdata, charsmax(itemdata), _, _, dummy)
  333.     itemid = itemdata[0]
  334.  
  335.     cost = ArrayGetCell(g_ItemCost, itemid)
  336.  
  337.     // Attempt to buy the item
  338.     if(cost <= zp_ammopacks_get(id))
  339.        buy_item(id, itemid)
  340.     else
  341.        client_print(id, print_chat, "Nincs elég lőszercsomagod a tárgy megvásárlásához!")
  342.     menu_destroy(menuid)
  343.     return PLUGIN_HANDLED;
  344. }
  345.  
  346. // Buy Item
  347. buy_item(id, itemid, ignorecost = 0)
  348. {
  349.     // Execute item select attempt forward
  350.     ExecuteForward(g_Forwards[FW_ITEM_SELECT_PRE], g_ForwardResult, id, itemid, ignorecost)
  351.    
  352.     // Item available to player?
  353.     if (g_ForwardResult >= ZP_ITEM_NOT_AVAILABLE)
  354.         return;
  355.    
  356.     // Execute item selected forward
  357.     ExecuteForward(g_Forwards[FW_ITEM_SELECT_POST], g_ForwardResult, id, itemid, ignorecost)
  358. }

Ők köszönték meg Dooz nek ezt a hozzászólást: KillerBoy12 (2018.06.09. 23:49)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 2 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 22 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole