• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Get items from container and doCombat on cid.

kermaxpl

Pora na Nonsens Scripter
Joined
Aug 21, 2012
Messages
121
Reaction score
7
Location
Poland
Hi, I have a question. How can i get all items from container(corpse/backpack), and add them to table?

-- Edit

How can I use doCombat to hurt cid?
 
Last edited:
LUA:
function getAllItemsFromContainer(container)
	local containers = {}
	local items = {}
 
	local sitem = container
	if sitem.uid > 0 then
		if isContainer(sitem.uid) then
			table.insert(containers, sitem.uid)
		elseif not(id) or id == sitem.itemid then
			table.insert(items, sitem)
		end
	end
 
	while #containers > 0 do
		for k = (getContainerSize(containers[1]) - 1), 0, -1 do
			local tmp = getContainerItem(containers[1], k)
			if isContainer(tmp.uid) then
				table.insert(containers, tmp.uid)
			elseif not(id) or id == tmp.itemid then
				table.insert(items, tmp)
			end
		end
		table.remove(containers, 1)
	end
 
	return items
end
 
but i can use it for onKill/onPrepareDeath?? I want to use it to script with can set random attributes to items. I want to make more optymized version than Cykotitan's.
 
Back
Top