Critico
Sexy
- Joined
- Mar 25, 2010
- Messages
- 370
- Reaction score
- 176
About: function to check how many free slots the bag has
exemple:
return slots free in your all backpack's
return slots free in your primary backpack
Lua:
function getContainerSlotsFree(container) -- by vodka
return getContainerCap(container)-getContainerSize(container)
end
function getAllContainerFree(container) -- by vodka
local containers,soma = {},0
for i = 0, getContainerSize(container)-1 do
local item = getContainerItem(container, i)
if isContainer(item.uid) then
table.insert(containers, item.uid)
end
end
for _, check in pairs(containers) do
soma = soma + getContainerSlotsFree(check)
end
return (soma + getContainerSlotsFree(container))
end
exemple:
Lua:
function onSay(cid, words, param)
local item = getAllContainerFree(getPlayerSlotItem(cid, 3).uid)
return doPlayerSendTextMessage(cid,18,'You have '..item..' slots free in your backpack')
end
return slots free in your all backpack's
Lua:
function onSay(cid, words, param)
local item = getContainerSlotsFree(getPlayerSlotItem(cid, 3).uid)
return doPlayerSendTextMessage(cid,18,'You have '..item..' slots free in your primary backpack')
end
return slots free in your primary backpack