Skip to content

Commit 2b2d789

Browse files
committed
Items: New feature to set level for a specific item via ini file only
1 parent b99e94f commit 2b2d789

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

configs/plugins-ze.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ze_coins_system.amxx
4848
ze_items_manager.amxx
4949
ze_items_cost.amxx
5050
ze_items_limit.amxx
51+
ze_items_level.amxx
5152

5253
# Grenades
5354
ze_frost.amxx

scripting/ze_items_level.sma

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include <amxmodx>
2+
#include <ze_core>
3+
#include <ze_levels>
4+
#define LIBRARY_LEVELS "ze_levels"
5+
6+
public plugin_natives()
7+
{
8+
set_module_filter("fw_module_filter")
9+
set_native_filter("fw_native_filter")
10+
}
11+
12+
public fw_module_filter(const module[], LibType:libtype)
13+
{
14+
if (equali(module, LIBRARY_LEVELS))
15+
return PLUGIN_HANDLED
16+
return PLUGIN_CONTINUE
17+
}
18+
19+
public fw_native_filter(const name[], index, trap)
20+
{
21+
if (!trap)
22+
return PLUGIN_HANDLED
23+
return PLUGIN_CONTINUE
24+
}
25+
26+
public plugin_init()
27+
{
28+
// Load Plug-In.
29+
register_plugin("[ZE] Items: Level", ZE_VERSION, ZE_AUTHORS)
30+
}
31+
32+
public ze_select_item_pre(id, iItem, bool:bIgnoreCost, bool:bInMenu)
33+
{
34+
new const iReqLevel = ze_item_get_level(iItem)
35+
36+
if (iReqLevel > 0)
37+
{
38+
new const iLevel = ze_get_user_level(id)
39+
40+
if (iLevel < iReqLevel)
41+
{
42+
if (bInMenu)
43+
{
44+
ze_item_add_text("\d[\r%L\d: \y%d\d]", LANG_PLAYER, "MENU_LEVEL", iReqLevel)
45+
}
46+
else
47+
{
48+
ze_colored_print(id, "%L", LANG_PLAYER, "MSG_LVL_NOT_ENOUGH")
49+
}
50+
51+
return ZE_ITEM_UNAVAILABLE
52+
}
53+
}
54+
55+
return ZE_ITEM_AVAILABLE
56+
}

0 commit comments

Comments
 (0)