• 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]Container with a certain item

Joe Rod

Discord: joerod1
Joined
Mar 16, 2011
Messages
499
Solutions
2
Reaction score
172
GitHub
joerod1
Hi guys, i need a script for a backpack that accept only an item (or an array), something like this:

LUA:
if item.itemid == 2160 then
         itemcanbeinsidebackpack
        else 
        itemcannotbeinsidebackpack
end
i don't know if can be done :c, it would be nice if somebody can help me, thanks in advance

Regards :)
 
Last edited:
no need to add lua scripting checks into this, containers are slow enough already

container.cpp
Code:
ReturnValue Container::__queryMaxCount(int32_t index, const Thing* thing, uint32_t count,
	uint32_t& maxQueryCount, uint32_t flags) const
{
	const Item* item = thing->getItem();
	if(!item)
	{
		maxQueryCount = 0;
		return RET_NOTPOSSIBLE;
	}

	if(((flags & FLAG_NOLIMIT) == FLAG_NOLIMIT))
	{
		maxQueryCount = std::max((uint32_t)1, count);
		return RET_NOERROR;
	}

[B][COLOR="red"]	if(getID() == 1987 && item->getID() == 2160)
		return RET_NOTPOSSIBLE;[/COLOR][/B]
now you can't add crystal coins into bags, but you can still add them into a backpack that's inside that bag
 
Hey Cyko, i tried with this:
[cpp] if(getID() == 1987 && item->getID() != 2220 || getID() == 1987 && item->getID() != 2222 || getID() == 1987 && item->getID() != 2651 || getID() == 1987 && item->getID() != 2653)
return RET_NOTPOSSIBLE;[/cpp]

I need that only the the getID items can be inside the backpack, now i can't add anything into the containerid 1987, how can i solve this? xD

edit: fixed xD
 
Last edited:
Back
Top