• 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 Errors with creaturescript

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
hello, help me with this error in console please

CONSOLE.png

Code:
on <...pts/creaturescripts/quests/liquid_black/jaul_storage.lua:6>

Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/quests/liquid_black/obujos_storage.lua:callback
...s/creaturescripts/quests/liquid_black/obujos_storage.lua:9: attempt to index local 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...s/creaturescripts/quests/liquid_black/obujos_storage.lua:9: in function <...s/creaturescripts/quests/liquid_black/obujos_storage.lua:6>

Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/creaturescripts/quests/liquid_black/tanjis_storage.lua:callback
...s/creaturescripts/quests/liquid_black/tanjis_storage.lua:9: attempt to index local 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...s/creaturescripts/quests/liquid_black/tanjis_storage.lua:9: in function <...s/creaturescripts/quests/liquid_black/tanjis_storage.lua:6>




jaul_storage:
Lua:
local config = {    timeStorage = 50070,
    timeDelay   = 05 * 60 * 60 -- 24h
}

local cEvent = CreatureEvent("killJaul")
function cEvent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    for cid, _ in pairs(creature:getDamageMap()) do
        local player = Player(cid)
        if player:isPlayer() then
            player:setStorageValue(config.timeStorage, config.timeDelay + os.time())
        end
    end
  
  
    return true
end

cEvent:register()

tanjis_storage:
Lua:
local config = {    timeStorage = 50071,
    timeDelay   = 05 * 60 * 60 -- 24h
}

local cEvent = CreatureEvent("killTanjis")
function cEvent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    for cid, _ in pairs(creature:getDamageMap()) do
        local player = Player(cid)
        if player:isPlayer() then
            player:setStorageValue(config.timeStorage, config.timeDelay + os.time())
        end
    end
  
  
    return true
end

cEvent:register()

obujos_storage:
Lua:
local config = {    timeStorage = 50072,
    timeDelay   = 05 * 60 * 60 -- 24h
}

local cEvent = CreatureEvent("killObujos")
function cEvent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    for cid, _ in pairs(creature:getDamageMap()) do
        local player = Player(cid)
        if player:isPlayer() then
            player:setStorageValue(config.timeStorage, config.timeDelay + os.time())
        end
    end
  
  
    return true
end

cEvent:register()
 
Solution
change:
Lua:
local player = Player(cid)
        if player:isPlayer() then
X
Lua:
local player = Player(cid)
        if player then

Why do you want to check if a player is a player? xd
change:
Lua:
local player = Player(cid)
        if player:isPlayer() then
X
Lua:
local player = Player(cid)
        if player then

Why do you want to check if a player is a player? xd
 
Solution
change:
Lua:
local player = Player(cid)
        if player:isPlayer() then
X
Lua:
local player = Player(cid)
        if player then

Why do you want to check if a player is a player? xd
Was my fault.

Figured damage map could get creatures and players, so did a redundant check to see if the creature data I used to create a player actually made a player or not. xD
(also to ensure the players who attacked the creature were still online.. 🤷‍♂️ )

Why does it error there, tho?
 
Back
Top