• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Monster:onDropLoot error player nil value

vexler222

Active Member
Joined
Apr 22, 2012
Messages
711
Solutions
15
Reaction score
46
Hi, I have this error in console, it appears every few minutes. When the error print in console, I wasn't killing any monsters and I didn't get any loot.

egMZrqr.png


monster.lua
Code:
local STORAGEVALUE_LOOT = 8914
function Monster:onDropLoot(corpse)

    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()

        -- Boost Loot
        local percentLoot = 0
        if player:getStorageValue(STORAGEVALUE_LOOT_TEMPO) > os.time() then
            local potion = lootPotion[player:getStorageValue(STORAGEVALUE_LOOT_ID)]
            if potion then
                percentLoot = (potion.exp / 100)
            end
        end

        -- Boost Creature
        local percent = 0
        if (mType:getName():lower() == boostCreature[1].name) then
            percent = (boostCreature[1].loot / 100)
        end

        for i = 1, #monsterLoot do
            monsterLoot[i].chance = monsterLoot[i].chance + (monsterLoot[i].chance * percent) + (monsterLoot[i].chance * percentLoot)
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print(string.format('[Warning] DropLoot: Could not add loot item to corpse. [Monster: %s]', item, mType:getName()))
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                    player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 11)
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, text)
                end
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                sendChannelMessage(11, TALKTYPE_CHANNEL_O, text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    end
end
 
Solution
if player:getStorageValue(STORAGEVALUE_LOOT_TEMPO) > os.time() then
you have to add player here
if player and player:getStorage...

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,632
Solutions
126
Reaction score
2,024
if player:getStorageValue(STORAGEVALUE_LOOT_TEMPO) > os.time() then
you have to add player here
if player and player:getStorage...
 
Solution
Top