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

Get Killer

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
How to get the killer?
Look the script:
Code:
function onDeath(cid, corpse, deathList)
    local drop, nDrop = doCreatureSetDropLoot(cid, true), doCreatureSetDropLoot(cid, false)
    local killer = ?????????
    if getPlayerLevel(cid) <= 50 then
        if isMonster(killer) == true then
            nDrop
        else
            drop
        end
    else
        local item_amuletOfLoss, slot = 2173, getPlayerSlotItem(cid, CONST_SLOT_NECKLACE)
        if slot == item_amuletOfLoss.itemid then
            doPlayerRemoveItem(cid, slot, 1)
            nDrop
        else
            drop
        end
    end
    return true
end
 
You mean just get if the killer is a player?

You should include server version tho.
 
Last edited by a moderator:
F.e
Code:
-- this will check the entire list
for _, list in pairs (deathList) do
   if isMonster(list) then
      nDrop
   end
end

Code:
-- this will check only the last hit
   if isMonster(deathList[1]) then
      nDrop
   end
 
Code:
function onDeath(cid, corpse, deathList)
    local drop, nDrop = doCreatureSetDropLoot(cid, true), doCreatureSetDropLoot(cid, false)
    if getPlayerLevel(cid) <= 50 then
        for _, list in pairs (deathList) do
            if isMonster(list) then
                nDrop
            end
        end
    else
        local item_amuletOfLoss, slot = 2173, getPlayerSlotItem(cid, CONST_SLOT_NECKLACE)
        if slot == item_amuletOfLoss.itemid then
            doPlayerRemoveItem(cid, slot.itemid, 1)
            nDrop
        else
            drop
        end
    end
    return true
end
 
Basic rules of most languages, the thing on the right is always assigned to the thing on the left.

Also you can't assign something a value and then place in a script, you need to do something with it, drop and nDrop are just variables, they aren't functions.

The solution is staring at you right in your face.
 
Code:
function onDeath(cid, corpse, deathList)
    local drop, nDrop = doCreatureSetDropLoot(cid, true), doCreatureSetDropLoot(cid, false)
    if getPlayerLevel(cid) <= 50 then
        for _, list in pairs (deathList) do
            if isMonster(list) then
                nDrop
            end
        end
    else
        local item_amuletOfLoss, slot = 2173, getPlayerSlotItem(cid, CONST_SLOT_NECKLACE)
        if slot == item_amuletOfLoss.itemid then
            doPlayerRemoveItem(cid, slot.itemid, 1)
            nDrop
        else
            drop
        end
    end
    return true
end
If you really that to look like this:
Code:
function onDeath(cid, corpse, deathList)
    local drop, nDrop = function() doCreatureSetDropLoot(cid, true) end, function() doCreatureSetDropLoot(cid, false) end
    if getPlayerLevel(cid) <= 50 then
        for _, list in pairs (deathList) do
            if isMonster(list) then
                nDrop()
            end
        end
    else
        local item_amuletOfLoss, slot = 2173, getPlayerSlotItem(cid, CONST_SLOT_NECKLACE)
        if slot == item_amuletOfLoss.itemid then
            doPlayerRemoveItem(cid, slot.itemid, 1)
            nDrop()
        else
            drop()
        end
    end
    return true
end

But that is shitty just change the functions to doCreatureSetDropLoot(cid, true/false), false where you have nDrop and true where you have drop.
 
Back
Top