waqmaz
Member
- Joined
- Jun 17, 2015
- Messages
- 203
- Reaction score
- 11
Hello. I've been coding since a few days in lua. I've wrote simple functions:
What I want to get is to remove all variables from itemsID array where [1] and their quantity from quantity array where [1], using doPlayerRemoveItem(cid, itemid, count[, subtype]) function from TFS 0.3.6.
So player should have removed 1 * item 2471 and 2 * item 2130.
Something like this:
Can someone help me? Maybe I should do it another way? Thanks.
Code:
local itemsID = {
[1] = { 2471, 2130},
-- [2] = { 5456, 777, 1148},
}
local quantity = {
[1] = { 1, 2},
-- [2] = { 100, 50, 2},
}
local function getItem(nr)
for i = 1, #itemsID[nr] do
return itemsID[nr][i]
end
end
local function getQuantity(nr)
for i = 1, #quantity[nr] do
return quantity[nr][i]
end
end
local function removeThat(get_items, get_quantity, cid)
if (getPlayerItemCount(cid, get_items) >= get_quantity) then
doPlayerRemoveItem(cid, get_items, get_quantity)
end
return true
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == 4767 then
removeThat(getItem(1), getQuantity(1), cid)
end
return true
end
What I want to get is to remove all variables from itemsID array where [1] and their quantity from quantity array where [1], using doPlayerRemoveItem(cid, itemid, count[, subtype]) function from TFS 0.3.6.
So player should have removed 1 * item 2471 and 2 * item 2130.
Something like this:
Code:
doPlayerRemoveItem(cid, {2471, 2130}, {1,2})
Last edited: