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

Add item to monster loot

VirrageS

←•†ĿuĀ && ©¤¤•→
Joined
May 30, 2010
Messages
984
Reaction score
63
Location
Poland
Hello :D

Like in title I want to add item to monster loot e.x sword (2376).
Item is adding when monster die and text "xxxx" is apearing.

I searched for any function but I didn't find <_<.



Thanks and rep for help
 
Maybe GlobalDrop ? But it no adds to corpse but to your backpack.

Lua:
function onKill(cid, target, lastHit)

local items = {{8300}} -- id of sword
local exmonster = {"Rat"} -- name of monster


local teste = 0
if isMonster(target) then
for i=1,#exmonster do
if getCreatureName(target) == exmonster[i] then
teste = 1
end
end

if teste == 0 then
for i=1,#items do
rand = math.random(1,100000)
if (items[i][2]) >= rand then
doPlayerAddItem(cid,items[i][1])
doPlayerSendTextMessage(cid, 25,"The legendary sword has been dropped ".. getItemNameById(items[i][1])..".")
end
end
end
end
return true
end
 
Hello :D

Like in title I want to add item to monster loot e.x sword (2376).
Item is adding when monster die and text "xxxx" is apearing.

I searched for any function but I didn't find <_<.



Thanks and rep for help
that request is not so clear :s why just not add the loot item to monster's loots in xml? and which TFS?
 
Beacuse I want to add some attributes which can changing to item.
And when I will have scrpit which is adding item then is easy to add to item random attributes and also I want text show on dead monster when drop this item.
That so why I need to have script :)


TFS: 0.4 trunk 3884
 
in that case..
Lua:
function onDeath(cid, corpse, deathList)
	local item = doCreateItemEx(2376)
	doItemSetAttribute(item, 'defense', 5)
	doAddContainerItemEx(corpse.uid, item)
	doSendAnimatedText(getThingPos(cid), 'TEXT', math.random(255))
	return true
end
XML:
<event type="death" name="item" event="script" value="item.lua"/>

at monster xml file
XML:
    <script>
        <event name="item"/>
    </script>
 
Back
Top