• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Its option to add to all monsters custom lot

Mauzim

Member
Joined
Jan 3, 2011
Messages
568
Reaction score
9
its option to add custom lot example. 1cc witch 3000 lot rate to all monsters w/o edit all monsters..
 
Try this:
PHP:
function onKill(cid, target, lastHit)
    if not(isPlayer(target)) then
        addEvent(addLoot, 150, cid, getCreatureName(target), getCreaturePosition(target))
    end
    return true
end

function addLoot(cid, target, pos)
    local items = {}
    for i = getTileInfo(pos).items, 1, -1 do
        pos.stackpos = i
        table.insert(items, getThingFromPos(pos))
    end
 
    if (#items == 0) then
        return true
    end
 
    local corpse = -1
    for _, item in ipairs(items) do
		if isContainer(item.uid) then
			corpse = item.uid
		end
    end
 
    if (corpse ~= -1) and isContainer(corpse) then
		if math.random(100000) <= 3000 then
			doAddContainerItem(corpse, 2160)
		end
    end
end
 
Last edited:
PHP:
[18:0:50.730] [Error - CreatureScript Interface]
[18:0:50.730] data/creaturescripts/scripts/event.lua:onKill
[18:0:50.731] Description:
[18:0:50.731] (luaAddEvent) Callback parameter should be a function.
 
not to rain on your parade or anything, but it's probably better if you localize the addLoot function...
LUA:
local function addLoot(cid, target, pos)
    local items = {}
    for i = getTileInfo(pos).items, 1, -1 do
        pos.stackpos = i
        table.insert(items, getThingFromPos(pos))
    end
 
    if (#items == 0) then
        return false
    end
 
    local corpse = -1
    for _, item in ipairs(items) do
        if isContainer(item.uid) then
            corpse = item.uid
        end
    end
 
    if (corpse ~= -1) and isContainer(corpse) then
        if math.random(100000) <= 3000 then
            doAddContainerItem(corpse, 2160)
        end
    end
	
	return true
end

function onKill(cid, target, lastHit)
    if not(isPlayer(target)) then
        addEvent(addLoot, 150, cid, getCreatureName(target), getCreaturePosition(target))
    end
    return true
end
 
Back
Top