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

First item desc script

Ist

New Member
Joined
Sep 13, 2010
Messages
181
Reaction score
2
Hey,
can somebody help me with first item description script?
I mean that while you will loot for example magic plate armor and it is first on the server it will have an unique description saying "This is the first on the server" but only this one, no another.

I saw it few times but I have hell no idea how to start doing such a thing so maybe somebody can help me.
 
Try this:
LUA:
config =
{
	-- [itemid] = storage
	[2472] = 10001
}

-- from [url]http://otland.net/f82/autoloot-91385/[/url]
function onLoot(target, position)

	local function scanContainer(cid, uid)
		for k = (getContainerSize(uid) - 1), 0, -1 do
			local tmp = getContainerItem(uid, k)
			if isContainer(tmp.uid) then
				scanContainer(cid, tmp.uid)
			end
			if (config[tmp.itemid] and getStorage(config[tmp.itemid]) == -1) then
				doItemSetAttribute(tmp.uid, "description", "This is the first on the server.")
				doSetStorage(config[tmp.itemid], 1)
			end
		end
	end

	local items = {}
	for i = getTileInfo(pos).items, 1, -1 do
		pos.stackpos = i
		items[i] = getThingFromPos(pos)
	end
	
	if (#items == 0) then
		return
	end
	
	local corpse = -1
	for _, item in pairs(items) do
		if not isCreature(item.uid) then
			local name = getItemName(item.uid):lower()
			if name:find(target:lower()) then
				corpse = item.uid
				break
			end
		end
	end

	if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
		scanContainer(cid, corpse)
	end
	return true
end

function onKill(cid, target)
	if (isMonster(target)) then
		addEvent(onLoot, 150, cid, getCreatureName(target), getCreaturePosition(target))
	end
	
	return true
end
 
Back
Top