• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[LUA] getContainerSlotsFree/getAllContainerFree

Critico

Sexy
Joined
Mar 25, 2010
Messages
370
Reaction score
176
About: function to check how many free slots the bag has

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
 
Back
Top