Karain
Jack of all trades
Hello fellow Scripters of OTLand, i was working on a new "proof of concept" code that will search the corpse of a monster for loot and print them out, the code works fine (as far as i have debugged it), it's just that the corpse is always "empty" in the code, even if the monster actually dropped some loot in the game, whether it's in bags or items.
So i came here to in hope to see if anyone encountered this before, i have searched this on OTLand before and it seemed to be working for everyone just fine (although they are not using TFS 1.0)
Here's my piece of code.
when killing any monster (for example orc), i get this feedback:
i have a separate test code to see the size, capacity, empty and item holding of the container infront of me, when i run it on the same corpse it brings me this:
i don't want to create a whole loot system just to make this work XD
EDIT: if there is no way to fix it, there might be a way to do the same script but with onUse?
Thanks in advance.
So i came here to in hope to see if anyone encountered this before, i have searched this on OTLand before and it seemed to be working for everyone just fine (although they are not using TFS 1.0)
Here's my piece of code.
Code:
function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
local player = Player(killer)
local body = Container(corpse)
if isMonster(cid) and isPlayer(killer) then
if body:isContainer() then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT,body:getName())
local itemcount = body:getSize()
player:sendTextMessage(MESSAGE_STATUS_DEFAULT,"size: "..body:getSize().." - capacity: "..body:getCapacity().. " - empty: "..body:getEmptySlots().." - item holding: "..body:getItemHoldingCount())
if itemcount > 0 then
for i=1,itemcount do
local item = body:getItem(i)
local itemname = itemtype:getName()
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "item name: "..itemname)
end
end
end
end
return true
end
when killing any monster (for example orc), i get this feedback:
Code:
22:33 size: 0 - capacity: 10 - empty: 10 - item holding: 0
22:33 Loot of a orc: 3 gold coins, a studded shield
i have a separate test code to see the size, capacity, empty and item holding of the container infront of me, when i run it on the same corpse it brings me this:
Code:
22:33 size: 2 - capacity: 8 - empty: 8 - item holding: 2
i don't want to create a whole loot system just to make this work XD
EDIT: if there is no way to fix it, there might be a way to do the same script but with onUse?
Thanks in advance.