1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--Factis' inventory script for my Friend HeadHunter
--//Config
Items = {
[1] = {
name = "Item 1";
func = function(id) msg(player(id, 'name') .." used an item 1!") end;
};
}
InventorySlots = 5
--//End of the config
Player = {}
function OpenInventory(id, page)
local page = page or 1
local pages = 5
if page < 1 then page = pages end
if page > pages then page = 1 end
local m = "Inventory P".. page
for i = 6 * page - 5, 6 * page do
if Player[id].inventory[i] then m = m ..', '.. Items[Player[id].inventory[i][1]].name ..'|'.. Player[id].inventory[i][1] else m = m ..',' end
end
if page == pages then m = m ..',,<<- First page' else m = m ..',,Next page -->' end
if page == 1 then m = m ..',Last page ->>' else m = m ..',<-- Previvius page' end
menu(id, m)
end
function AddItem(id, itemid)
for n, w in pairs(Player[id].inventory) do
if w[1] == itemid then
	 w[2] = w[2] + 1
	 else
	 table.insert(Player[id].inventory, {itemid, 1})
	 end
end
end
function RemoveItem(id, itemid, ammount)
for n, w in pairs(Player[id].inventory) do
if w[1] == itemid then
	 w[2] = w[2] - ammount
	 if w[2] <= 0 then
	 table.remove(Player[id].inventory, n)
end
break
end
end
end
addhook("join", "JoinHook")
function JoinHook(id)
Player[id] = {inventory = {}}
for k = 1, 17 do
AddItem(id, 1)
end
end
addhook('serveraction', 'ServerActionHook')
function ServerActionHook(id, action)
if action == 1 then
OpenInventory(id)
end
end
addhook('menu', 'MenuHook')
function MenuHook(id, title, button)
if title:sub(1, 11) == 'Inventory P' then
local page = tonumber(title:sub(12))
if button == 8 then OpenInventory(id, page + 1) end
if button == 9 then OpenInventory(id, page - 1) end
if button <= 6 then
local x = (page - 1) * 6 + button
Items[Player[id].inventory[x]].func(id)
end
end
end
Should work