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

Lua when dying receive storage

darkmu

Well-Known Member
Joined
Aug 26, 2007
Messages
274
Solutions
1
Reaction score
50
Location
Paraná,Brazil
I'm trying to make a system that when dying by a monster, the person will get a storage in which they will use it in the future to recover the level using an item.


Lua:
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
   local player = Player(creature)
  
   if not player then
     return false
   end
  

  
    player:setStorageValue(15715,1)       

    end
    return false
end
 
Solution
E
sorry, change this:

if not killer:isPlayer() then

to this:

if killer:isPlayer() then
Lua:
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if not creature:isPlayer() then
        return false
    end

    if not killer:isPlayer() then
        return false
    end

    creature:setStorageValue(15715, 1)
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(15715) == 1 then
        player:addLevel(1)
        player:setStorageValue(15715, 0)
    end
    return true
end
 
Lua:
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if not creature:isPlayer() then
        return false
    end

    if not killer:isPlayer() then
        return false
    end

    creature:setStorageValue(15715, 1)
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(15715) == 1 then
        player:addLevel(1)
        player:setStorageValue(15715, 0)
    end
    return true
end
its ok to return false? I mean would it trigger or not something else?
 
its ok to return false? I mean would it trigger or not something else?
in fact absolutely nothing happens, whatever it returns: D
it would be enough to return nothing:
Lua:
return
end

Now that I think about it, this function in the sources must be of type Void and not Boolean
 
Lua:
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if not creature:isPlayer() then
        return false
    end

    if not killer:isPlayer() then
        return false
    end

    creature:setStorageValue(15715, 1)
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(15715) == 1 then
        player:addLevel(1)
        player:setStorageValue(15715, 0)
    end
    return true
end
Strange that I am dying and soon after I am unable to use the item, I think I did everything right. I registered the event at login and left it with the tag in the xml, even debugging it to see if I was calling the file correctly. :(
 
Back
Top