• 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 Help me in this function

viniciusturko

New Member
Joined
Jun 23, 2009
Messages
94
Reaction score
2
Location
Brasil
Hello, I have a function that returns the item ids into a container. But I want that the function returns the slots where u can't find an item as 1 or nil.
For example, I have a container with a rope and a shovel, if I use my function, It will return just the id of the both tools, and not something like this : nil, nil, nil, rope, nil, nil shovel.

Can someone help me to make this function works?
Here is the function I'm using :

Code:
function getIdsInContainer(containeruid)
    local t = {}
    for i = 0, (getContainerSize(containeruid)-1) do
        local item = getContainerItem(containeruid, i)
        table.insert(t, item.itemid)
    end
return t
end

Rep ++
 
Lua:
function getIdsInContainer(containeruid)
	local t = {}
	for i = (getContainerSize(uid) - 1), 0, -1 do
		local item = getContainerItem(containeruid, i)
		if item.itemid < 1 then
			table.insert(t, i)
		end
	end
	return t
end

That will return the slot ids


@Down

Edited, shoul be working
 
Last edited:
Lua:
function getContainerFreeSlots(uid)
	return getContainerCap(uid) - getContainerSize(uid)
end
obviously returns a number, don't see why would you need a table with nil values
 
Back
Top