• 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 Editing loot when it's dropped

Rexxar

of Unimatrix Zero-One
Joined
Jun 4, 2009
Messages
1,014
Solutions
3
Reaction score
130
Location
Narnia
Simple question!

Is it possible to alter loot that is dropped by a monster, when (or right after) the monster dies and loot is placed in its corpse?

Example:
Monster XXX drops "Shovel".
I want the script to, when a monster dies, check if its loot contains "Shovel".
If so, check if player name is "Adam", and if monster name is "Scarab".
If the above thing is true, replace "Shovel" with "Pick Axe".
(Or remove "Shovel" from the monster corpse, and instead place "Pick Axe" in there)


Is this possible in LUA or would it require C++ stuff?

Any help is appreciated, and rewarded with Reputation. :)

//Rex
 
I think it should be something like this.

LUA:
function onDeath(cid, corpse, deathList)
local loot = {1000,1001}
	if isCreature(cid) then
		for i=1, #loot do
			doCreatureSetDropLoot(cid,loot[i])
		end
	end
	return true
end
 
mm...
hey unk, if you print the loot it will be "2" so why doCreatureSetDropLoot(cid, 2) D;?
anyways i cant script it because i dont understand the request xd
 
creaturescripts.xml
Code:
	<event type="death" name="EditLoot" event="script" value="script.lua"/>
script.lua
Code:
function onDeath(cid, corpse, deathList)
	for i = 1, #deathList do
		if isPlayer(deathList[i]) and getCreatureName(deathList[i]) == 'Adam' then
			local i = 0
			while i < getContainerSize(corpse.uid) do
				local k = getContainerItem(corpse.uid, i)
				if k.itemid == 2554 then
					doTransformItem(k.uid, 2553)
					break
				end
				i = i + 1
			end
			break
		end
	end
	return true
end
monster script:
Code:
	<script>
		<event name="EditLoot"/>
	</script>
 
Last edited:
Oh so onDeath works on monsters too? That's awesome!

Thanks guys, really appreciate it! :)


Edit: Lol damnit, can't seem to rep you Cyko :<
I'll try again once I've "spread a little reputation around"
 
Last edited:
Back
Top