English lua request(kind of inventory)

23 replies
Goto Page
To the start Previous 1 2 Next To the start
Up
loldlold123
User
Offline Off
hello guys,i need something that we can call it as inventory
there are already 2 inventory script in file archive i already know that,but im looking for something that is more basic, these features what im looking for;
-doesnt need to images of items
-doesnt need to drop items
-f4 to see your inventory
-f3 to get items from shop(basicly you can make asd item and gives you 100 hp boost)
-items will be saved...

i'll create lots of items so needed tables but god damn im not good at those things...
07.07.12 10:58:21 am
Up
Avo
User
Offline Off
Check out my http://unrealsoftware.de/files_show.php?file=10938 . It has got little bug, but whatever. I give you permission to edit and even a upload, but add me in credits.
07.07.12 07:36:14 pm
Up
Infinite Rain
Reviewer
Offline Off
user Avo has written:
Check out my http://unrealsoftware.de/files_show.php?file=10938 . It has got little bug, but whatever. I give you permission to edit and even a upload, but add me in credits.
Haha, really funny.

@user loldlold123: Listen, I cn do to you an easy example with infinite menus. Function for each item and item exparation, if you want.
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
07.07.12 07:46:28 pm
Up
Alistaire
User
Offline Off
Also, the items have to stack. I can make the rest of it.
IMG:http://i.imgur.com/5zhwOTP.png
07.07.12 08:22:22 pm
Up
loldlold123
User
Offline Off
user Infinite Rain has written:
user Avo has written:
Check out my http://unrealsoftware.de/files_show.php?file=10938 . It has got little bug, but whatever. I give you permission to edit and even a upload, but add me in credits.
Haha, really funny.

@user loldlold123: Listen, I cn do to you an easy example with infinite menus. Function for each item and item exparation, if you want.


ok it would be nice for me,but also needed remove item function...(cuz im gonna make trade system with that so i need to remove items)
07.07.12 08:45:08 pm
Up
Infinite Rain
Reviewer
Offline Off
OK I will make it now
WAIT.

Edit:

Code:
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
--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]].name 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)
     table.insert(Player[id].inventory, itemid)
end

function RemoveItem(id, itemid)
     for n, w in pairs(Player[id].inventory) do
          if w == itemid then
               table.remove(Player[id].inventory, n)
               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


In config:
Items:
name = name of the item
func = function of the item

Functions:
ItemAdd(id, itemid) -- adds an item into player's inventory
RemoveItem(id, itemid) -- Removes the item from player's inventory

ItemSlots -- The number of the slots in inventory (deffault 5 - 30 items can be held

If you want to make stacks, ask Alistaire, as he asked to.
edited 2×, last 07.07.12 09:20:31 pm
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
07.07.12 09:25:50 pm
Up
loldlold123
User
Offline Off
how to call that,like if player has got asd item then function? i can check player has got item or not but i have to add counter for each item and i dont wanna do that...so what im gonna do?
08.07.12 10:51:58 am
Up
Infinite Rain
Reviewer
Offline Off
What?

If player got got item and he clicked on this item in inventory then specified function will be called.
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
08.07.12 11:27:00 am
Up
Alistaire
User
Offline Off
He wants the items have a counter in the table so that he can do stuff like;

Code:
1
2
3
4
if player[id][inventory][item][ammount] >= 5 then
     player[id][inventory][item][ammount] = player[id][inventory][item][ammount] - 5
     player[id][inventory][gold] = player[id][inventory][gold] + 100
end


And the like. Not that the table looks like this, but to give an idea.
IMG:http://i.imgur.com/5zhwOTP.png
08.07.12 01:54:00 pm
Up
Infinite Rain
Reviewer
Offline Off
Oh you mean, ammount of the same items?

Code:
1
2
3
4
5
6
7
8
9
function Items(id, itemid)
     local count = 0
     for n, w in pairs(Player[id].inventory) do
          if w == itemid then
               count = count + 1
          end
     end
     return count
end
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
08.07.12 01:56:36 pm
Up
Alistaire
User
Offline Off
I mean that the inventory table needs another table to store the current ammount of the items, and that the ammount should be showed next to the item name in the inventory menu.
IMG:http://i.imgur.com/5zhwOTP.png
08.07.12 02:00:17 pm
Up
Infinite Rain
Reviewer
Offline Off
user Alistaire has written:
I mean that the inventory table needs another table to store the current ammount of the items, and that the ammount should be showed next to the item name in the inventory menu.

OH you mean stacks?
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
08.07.12 02:03:54 pm
Up
Alistaire
User
Offline Off
user Infinite Rain has written:
user Alistaire has written:
I mean that the inventory table needs another table to store the current ammount of the items, and that the ammount should be showed next to the item name in the inventory menu.

OH you mean stacks?


Yes. Check my first post on the thread.
edited 1×, last 08.07.12 02:04:44 pm
IMG:http://i.imgur.com/5zhwOTP.png
08.07.12 02:04:03 pm
Up
Avo
User
Offline Off
user Infinite Rain has written:
OH you mean stacks?

He already said it, David.
08.07.12 02:11:09 pm
Up
Infinite Rain
Reviewer
Offline Off
Code:
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

user Avo has written:
user Infinite Rain has written:
OH you mean stacks?

He already said it, David.


Well, thank you captain obvious.
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
08.07.12 06:25:29 pm
Up
loldlold123
User
Offline Off
wait a minute,there is no save&load
edited 1×, last 08.07.12 06:38:17 pm
08.07.12 07:18:45 pm
Up
Lubo
User
Offline Off
To make ''save system'' is hard.
But anyway good luck.
08.07.12 07:21:56 pm
Up
Alistaire
User
Offline Off
Save system is the easy part.
IMG:http://i.imgur.com/5zhwOTP.png
08.07.12 08:40:12 pm
Up
loldlold123
User
Offline Off
inventory isnt working for me,anyone tried?
08.07.12 09:54:07 pm
Up
Shawni
User
Offline Off
user Lubo has written:
To make ''save system'' is hard.
But anyway good luck.


Its may hard to you.
We die once, do i have to hide to be visible ?
To the start Previous 1 2 Next To the start