• 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!

Max Items in backpack when ID XXXX, YYYY or ZZZZ(?)

GarQet

Own3d!
Joined
Feb 10, 2009
Messages
1,381
Solutions
14
Reaction score
81
HiHo!
I have no idea how to write such a script: When player puts on the backpack item with id XXXX, YYYY or ZZZZ then script check her backpack in search of those are objects. If amount of this three items would be six, then script cancel throwing another item to backpack about id XXXX, YYYY or ZZZZ. So the maximum number of items in a backpack with id XXXX, YYYY, ZZZZ is 6. If player wants to have more, system rejects his whim. This is understandable? :P
Can someone write me some idea or create this small script for me?
 
My attempt to create a script.
I have found new function by Mock (http://otland.net/f35/creaturescript-onmoveitem-moveitem-frompos-position-cid-96742/). I used it in my script:
LUA:
local ItemID = {2222, 2651, 2653, 2220, 2655}

function onMoveItem(moveItem, frompos, position, cid)
if(isInArray(ItemID, moveItem.itemid)) then
	doPlayerSendCancel(cid, "You cannot drop this item!")
	return false
end
end
This is what I tried of the options available in the TFS:
LUA:
local ItemID = {2222, 2651, 2653, 2220, 2655}

function onRemoveItem(moveItem, tileItem, position, cid)

	if(isInArray(ItemID, moveItem.itemid)) then
		doPlayerSendCancel(cid, "You cannot drop this item!")
		return false
	end
end
LUA:
local ItemID = {2222, 2651, 2653, 2220, 2655}

function onRemoveItem(moveItem, tileItem, position, cid)

	if(isInArray(ItemID, moveItem.itemid)) then
		doPlayerSendCancel(cid, "You cannot drop this item!")
		doRemoveItem(moveItem.uid, 1)
		doCreateItem(moveItem.itemid, 1, position)
		return false
	end
end
No script is not working properly. I have no idea how to do it. Please help.
 
Back
Top