Dankoo
Active Member
- Joined
- Sep 4, 2010
- Messages
- 1,007
- Reaction score
- 27
I've got this script:
It's kinda old (2009), don't know if it works on 0.4...
LUA:
function getLoot(monstername)
local loocik = {}
local loot = db.getResult("SELECT * FROM `monsters_loot` WHERE `monster_name`='" .. monstername .. "';")
if loot:getID() ~= -1 then
while(true) do
table.insert(loocik, {loot:getDataInt("item_id"), loot:getDataInt("item_count"), loot:getDataInt("drop_percent"), loot:getDataInt("in_container")})
if not(loot:next())then
break
end
end
loot:free()
else
print("No loot in database for: "..monstername.."!")
end
return loocik
end
function addLoot(x)
pos = x["pos"]
for i=0,255 do
pos.stackpos = 255-i
gpos = getThingfromPos(pos)
if isCorpse(gpos.uid) == 1 then
corp = 255-i
end
end
pos.stackpos = corp
corpse = getThingfromPos(pos)
local container = 0
for i=1,#x.loot do
if x.loot[i][3] >= math.random(1,100) then
if x.loot[i][4] == 0 or container == nil then
local la = doAddContainerItem(corpse.uid, x.loot[i][1], math.random(1, x.loot[i][2]))
if isContainer(la) then
container = la
end
elseif x.loot[i][4] == 1 and container ~= nil then
doAddContainerItem(container, x.loot[i][1], math.random(1, x.loot[i][2]))
end
end
end
end
function onKill(cid, target)
if isMonster(target) then
local pos = getCreaturePosition(target)
local monsterloot = getLoot(getCreatureName(target))
x = {
["pos"] = pos,
["loot"] = monsterloot
}
addEvent(addLoot, 1, x)
end
return TRUE
end
It's kinda old (2009), don't know if it works on 0.4...
[22:35:18.386] [Error - CreatureScript Interface]
[22:35:18.386] In a timer event called from:
[22:35:18.386] data/creaturescripts/scripts/lootsystem.lua onKill
[22:35:18.386] Description:
[22:35:18.386] (luaGetThing) Thing not found