• 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 (LuaInterface::luaGetPlayerFlagValue) Player not found

katumblo

Member
Joined
Oct 20, 2010
Messages
60
Reaction score
7
This error is appearing with a bit spells on my server, could someone show me the solution so I can fix it myself later whenever it happens? I'm going to post two of these scripts that are giving me an error for me to use as an example and if you can give that help I would appreciate it <3

Lua:
[Error - Spell Interface]
data/spells/scripts/personagem/hashirama/6.lua:onCastSpell
Description:
(LuaInterface::luaGetPlayerFlagValue) Player not found

Lua:
[Error - Spell Interface]
data/spells/scripts/personagem/hashirama/7.lua:onCastSpell
Description:
(LuaInterface::luaGetPlayerFlagValue) Player not found

Lua:
[Error - Spell Interface]
data/spells/scripts/personagem/hashirama/8.lua:onCastSpell
Description:
(LuaInterface::luaGetPlayerFlagValue) Player not found

Lua:
[Error - Spell Interface]
data/spells/scripts/personagem/hashirama/9.lua:onCastSpell
Description:
(LuaInterface::luaGetPlayerFlagValue) Player not found

6.lua
Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_HITCOLOR, COLOR_BROWN)
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 0)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -6.0, -1400, -6.0, -1600)


arr1 = {
    {3}
}

local area1 = createCombatArea(arr1)
setCombatArea(combat1, area1)


local function onCastSpell1(parameters)
    return isPlayer(parameters.cid) and doCombat(parameters.cid, combat1, parameters.var)
end

function onCastSpell(cid, var)
    local waittime = 1 -- Tempo de exhaustion
    local storage = 8214

    if exhaustion.check(cid, storage) then
        doPlayerSendChannelMessage(cid, "Aguarde ".. exhaustion.get(cid, storage) .. " segundos para usar o jutsu novamente.")
        return false
    end
    local parameters = { cid = cid, var = var}
    local target = getCreatureTarget(cid)  -- efeito no alvo
    local pos = getCreaturePosition(target)
    local poz = getCreaturePosition(cid) -- effeito no caster
    addEvent(doSendMagicEffect, 25, {x = pos.x, y = pos.y+1, z = pos.z}, 384)
    addEvent(doSendMagicEffect, 500, {x = pos.x+1, y = pos.y+1, z = pos.z}, 38)
    addEvent(onCastSpell1, 500, parameters)
    exhaustion.set(cid, storage, waittime)
    return true
end

7.lua
Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_HITCOLOR, COLOR_BROWN)
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 28)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -9.0, -1600, -9.0, -1800)

arr1 = {
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}

local area1 = createCombatArea(arr1)
setCombatArea(combat1, area1)

function onCastSpell(cid, var)
local positionME = {x=getPlayerPosition(cid).x, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z}
doSendMagicEffect(positionME, 28)
local waittime = 2
local storage = 8202

if exhaustion.check(cid, storage) then
return false
end
local p = getCreaturePosition(cid)
local x = {
[0] = {x=p.x+1, y=p.y-1, z=p.z},
[1] = {x=p.x+5, y=p.y+1, z=p.z},
[2] = {x=p.x+1, y=p.y+5, z=p.z},
[3] = {x=p.x-1, y=p.y+1, z=p.z}
}
local y = {
[0] = 229,
[1] = 226,
[2] = 228,
[3] = 227
}
pos = x[getCreatureLookDirection(cid)]
eff = y[getCreatureLookDirection(cid)]
doSendMagicEffect(pos, eff)
exhaustion.set(cid, storage, waittime)
doCombat(cid, combat1, var)
end
 
Solution
Try it. In this case you wanna check if the creature is a monster so you don't run the rest of the code (specially getPlayerFlagValue())
Lua:
exhaustion =
{
    check = function(cid, storage)
        if isMonster(cid) then
            return false
        end

        if (getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        return getPlayerStorageValue(cid, storage) >= os.time()
    end,

    get = function(cid, storage)
        if isMonster(cid) then
            return false
        end

        if (getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        local exhaust = getPlayerStorageValue(cid, storage)
        if (exhaust > 0) then...
The error is probably in your exhaustion functions. I suppose you're using this spell in a monster and when your exhaustion functions check if the player has a no exhaustion flag the error pops. So consider adding right on the top of your exhaustion functions a checking if the creature is a monster:
Lua:
if isMonster(cid) then
    return -- you can return true, false or null, it depends on the function.
end

An error can occur on 6.lua as well, in the onCastSpell1(). In lua, even if the first statement in a bool is false, the code will run the next statements. So the isPlayer() is useless on this code because even if the player doesn't exists the code will run doCombat() and a warning will pop. A solution would be:
Lua:
local function onCastSpell1
    if isCreature(parameters.cid) then -- I prefer (almost) always to use isCreature() because maybe you wanna use this spell for monster.
        doCombat(parameters.cid, combat1, parameters.var)
    end
end

I think your can get a few more tips by a code refactoring:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_HITCOLOR, COLOR_BROWN)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 0)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -6.0, -1400, -6.0, -1600)

local area = createCombatArea({ 3 })
setCombatArea(combat, area)

local waittime = 1 -- Tempo de exhaustion
local storage = 8214

function onCastSpell(cid, var)
    if exhaustion.check(cid, storage) then
        doPlayerSendCancel(cid, "Aguarde " .. exhaustion.get(cid, storage) .. " segundos para usar o jutsu novamente.")
        return false
    end

    local targetPosition = getCreaturePosition(getCreatureTarget(cid))

    addEvent(doSendMagicEffect, 25, {
        x = targetPosition.x,
        y = targetPosition.y + 1,
        z = targetPosition.z
    }, 384)

    addEvent(doSendMagicEffect, 500, {
        x = targetPosition.x + 1,
        y = targetPosition.y + 1,
        z = targetPosition.z
    }, 38)

    addEvent(function()
        if isCreature(cid) then
            doCombat(cid, combat, var)
        end
    end, 500)

    exhaustion.set(cid, storage, waittime)
    return true
end
 
Last edited:
The error is probably in your exhaustion functions. I suppose you're using this spell in a monster and when your exhaustion functions check if the player has a no exhaustion flag the error pops. So consider adding right on the top of your exhaustion functions a checking if the creature is a monster:
Lua:
if isMonster(cid) then
    return -- you can return true, false or null, it depends on the function.
end

An error can occur on 6.lua as well, in the onCastSpell1(). In lua, even if the first statement in a bool is false, the code will run the next statements. So the isPlayer() is useless on this code because even if the player doesn't exists the code will run doCombat() and a warning will pop. A solution would be:
Lua:
local function onCastSpell1
    if isCreature(cid) then -- I prefer (almost) always to use isCreature() because maybe you wanna use this spell for monster.
        doCombat(cid, combat)
    end
end

I think your can get a few more tips by a code refactoring:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_HITCOLOR, COLOR_BROWN)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 0)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -6.0, -1400, -6.0, -1600)

local area = createCombatArea({ 3 })
setCombatArea(combat, area)

local waittime = 1 -- Tempo de exhaustion
local storage = 8214

function onCastSpell(cid, var)
    if exhaustion.check(cid, storage) then
        doPlayerSendCancel(cid, "Aguarde " .. exhaustion.get(cid, storage) .. " segundos para usar o jutsu novamente.")
        return false
    end

    local targetPosition = getCreaturePosition(getCreatureTarget(cid))

    addEvent(doSendMagicEffect, 25, {
        x = targetPosition.x,
        y = targetPosition.y + 1,
        z = targetPosition.z
    }, 384)

    addEvent(doSendMagicEffect, 500, {
        x = targetPosition.x + 1,
        y = targetPosition.y + 1,
        z = targetPosition.z
    }, 38)

    addEvent(function()
        if isCreature(cid) then
            doCombat(cid, combat)
        end
    end, 500)

    exhaustion.set(cid, storage, waittime)
    return true
end

So, about the first code, where I should put it?
At second code, it doesn't works :( (the problem is the same)

And, about the third, I didn't do it, that's why it's a mess, my codes are organized but I program in python/php/c++, I'm starting in otserver so I have several questions (Just so it doesn't look ugly for me, I'm sending it as my codes are indented) xd
 

Attachments

  • imagem_2022-09-14_004243419.png
    imagem_2022-09-14_004243419.png
    224.8 KB · Views: 2 · VirusTotal
So, about the first code, where I should put it?
In your exhaustion functions, it's probably in data/libs/

At second code, it doesn't works :( (the problem is the same)
Yeah, I know, the solution to your problem is the first code I sent, in the exhaustion functions. The second code fixes another error that could eventually occur.
 
In your exhaustion functions, it's probably in data/libs/


Yeah, I know, the solution to your problem is the first code I sent, in the exhaustion functions. The second code fixes another error that could eventually occur.

I found, it's in data/libs/034-exaustion, now it's like this:


Lua:
exhaustion =
{
    check = function (cid, storage)
        if isCreature(cid) then
            if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
                return false
            end
        end


        return getPlayerStorageValue(cid, storage) >= os.time()
    end,

    get = function (cid, storage)
        if isCreature(cid) then
            if(getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
                return false
            end

            local exhaust = getPlayerStorageValue(cid, storage)
            if(exhaust > 0) then
                local left = exhaust - os.time()
                if(left >= 0) then
                    return left
                end
            end

            return false

        end
    end,

    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time() + time)
    end,

    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return true
        end

        return false
    end
}

and my 6.lua:
Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_HITCOLOR, COLOR_BROWN)
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 0)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -6.0, -1400, -6.0, -1600)


arr1 = {
    {3}
}

local area1 = createCombatArea(arr1)
setCombatArea(combat1, area1)


local function onCastSpell1(parameters)
    if isCreature() then
        return isPlayer(parameters.cid) and doCombat(parameters.cid, combat1, parameters.var)
    end
end

function onCastSpell(cid, var)
    local waittime = 1 -- Tempo de exhaustion
    local storage = 8214

    if exhaustion.check(cid, storage) then
        doPlayerSendChannelMessage(cid, "Aguarde ".. exhaustion.get(cid, storage) .. " segundos para usar o jutsu novamente.")
        return false
    end
    local parameters = { cid = cid, var = var}
    local target = getCreatureTarget(cid)  -- efeito no alvo
    local pos = getCreaturePosition(target)
    local poz = getCreaturePosition(cid) -- effeito no caster
    addEvent(doSendMagicEffect, 25, {x = pos.x, y = pos.y+1, z = pos.z}, 384)
    addEvent(doSendMagicEffect, 500, {x = pos.x+1, y = pos.y+1, z = pos.z}, 38)
    addEvent(onCastSpell1, 500, parameters)
    exhaustion.set(cid, storage, waittime)
    return true
end

but the error still appears

Lua:
[Error - Spell Interface]
data/spells/scripts/personagem/hashirama/6.lua:onCastSpell
Description:
(LuaInterface::luaGetPlayerFlagValue) Player not found

[Error - Spell Interface]
data/spells/scripts/personagem/hashirama/9.lua:onCastSpell
Description:
(LuaInterface::luaGetPlayerFlagValue) Player not found

[Error - Spell Interface]
data/spells/scripts/personagem/hashirama/6.lua:onCastSpell
Description:
(LuaInterface::luaGetPlayerFlagValue) Player not found

[Error - Spell Interface]
data/spells/scripts/personagem/hashirama/8.lua:onCastSpell
Description:
(LuaInterface::luaGetPlayerFlagValue) Player not found

[Error - Spell Interface]
data/spells/scripts/personagem/hashirama/7.lua:onCastSpell
Description:
(LuaInterface::luaGetPlayerFlagValue) Player not found

*I used "isCreature()" because like you said, I have a vocation with it and a monster with it too
 
Try it. In this case you wanna check if the creature is a monster so you don't run the rest of the code (specially getPlayerFlagValue())
Lua:
exhaustion =
{
    check = function(cid, storage)
        if isMonster(cid) then
            return false
        end

        if (getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        return getPlayerStorageValue(cid, storage) >= os.time()
    end,

    get = function(cid, storage)
        if isMonster(cid) then
            return false
        end

        if (getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        local exhaust = getPlayerStorageValue(cid, storage)
        if (exhaust > 0) then
            local left = exhaust - os.time()
            if (left >= 0) then
                return left
            end
        end

        return false

    end,

    set = function(cid, storage, time)
        if isMonster(cid) then
            return
        end

        setPlayerStorageValue(cid, storage, os.time() + time)
    end,

    make = function(cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if (not exhaust) then
            exhaustion.set(cid, storage, time)
            return true
        end

        return false
    end
}

if isCreature() then
You forgot to pass parameters.cid as parameter.
isPlayer(parameters.cid) and
You can remove this.
 
Solution
Try it. In this case you wanna check if the creature is a monster so you don't run the rest of the code (specially getPlayerFlagValue())
Lua:
exhaustion =
{
    check = function(cid, storage)
        if isMonster(cid) then
            return false
        end

        if (getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        return getPlayerStorageValue(cid, storage) >= os.time()
    end,

    get = function(cid, storage)
        if isMonster(cid) then
            return false
        end

        if (getPlayerFlagValue(cid, PLAYERFLAG_HASNOEXHAUSTION)) then
            return false
        end

        local exhaust = getPlayerStorageValue(cid, storage)
        if (exhaust > 0) then
            local left = exhaust - os.time()
            if (left >= 0) then
                return left
            end
        end

        return false

    end,

    set = function(cid, storage, time)
        if isMonster(cid) then
            return
        end

        setPlayerStorageValue(cid, storage, os.time() + time)
    end,

    make = function(cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if (not exhaust) then
            exhaustion.set(cid, storage, time)
            return true
        end

        return false
    end
}


You forgot to pass parameters.cid as parameter.

You can remove this.
Niiiiiice !! Its works perfectly! 0 errors.
Thank u very muuuuuch bro <3
 
Back
Top