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

attempt to call global 'getCreatureCondition' (a nil value)

Joined
Apr 11, 2015
Messages
105
Reaction score
6
0.4

Hello,

I am currently experiencing an issue where it seems that my server does not recognize the GetCreatureCondition function in any script. I am using this version of the server: Fir3element/3777.

I suspect the problem might be related to the sources, and I can provide any files you think might be necessary to diagnose the issue. The relevant files and details can be accessed through the link I provided above.

While searching for a solution, I found a post on Otland that discusses a similar issue: Attempt to call global 'getCreatureCondition' a nil value. However, the solution provided there seems to have been very specific to that particular user's situation.

I am looking for a way to make the getCreatureCondition function recognized by my server scripts. Any guidance or suggestions on how to address this issue would be greatly appreciated.

Thank you for your help.
 
did you search in
data/lib/100-compat.lua.
for possible functions related to that? it says you should use

hasCondition = getCreatureCondition

so you are using Get not get there is your error the letter should not be capital but only of the following words
 
Last edited:
Argue Seth Meyers GIF by Late Night with Seth Meyers

First of all... what is the exact error. And can you provide one on the scripts that uses it..


 
Seems that getCreatureCondition is the correct lua method...

So what is the error(if any), and provide any script that doesn't work...
did you not read what i said? He is using wrong name he put his GetCreatureCondition < function it should be getCreatureCondition the letter makes all the difference the engine can not differentiate between and will not find the GetCreatureCondition because it is not attached to global compat variable only getCreatureCondition is
 
did you not read what i said? He is using wrong name he put his GetCreatureCondition < function it should be getCreatureCondition the letter makes all the difference the engine can not differentiate between and will not find the GetCreatureCondition because it is not attached to global compat variable only getCreatureCondition is
No... because it wasn't in your original post. You edited it afterwards. And I assume he means the existing scripts aren't working, which all begin with a lowercase 'g'. That is also why I asked him to provide a script that doesn't work... just to make sure he hasn't edited them or made any typo mistakes...

And I know how Lua works ... I don't need any explanations from you at all.
 
@highsanta
Thank you for replying.
I used both capital letter and normal, and got the same problem

@Fjorda
Hey, thank you for replying too.
The error is the title of this thread.
And the script, the error occur in every script that has getcreaturecondition, so any simple script like this
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not getCreatureCondition(cid, CONDITION_INFIGHT) then
        if doPlayerAddItem(cid, 2674, 1) then
    else
    end
    return true
end
will return this error: attempt to call global 'getCreatureCondition' (a nil value)

I tried add getCreatureCondition = hasCreatureCondition, but still got the same errors, should I replace hasCondition = getCreatureCondition for this in 100-compat.lua?
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getCreatureCondition(cid, CONDITION_INFIGHT) then

doPlayerSendCancel(cid, "Sorry not possible")
else

doPlayerAddItem(cid,2674, 1)

end

end


consider adding exhaust to giving player the item aswell i guess otherwise it will only be bound to onUse cooldown which is dictated by config.lua
 
@highsanta
Thank you for replying.
I used both capital letter and normal, and got the same problem

@Fjorda
Hey, thank you for replying too.
The error is the title of this thread.
And the script, the error occur in every script that has getcreaturecondition, so any simple script like this
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if not getCreatureCondition(cid, CONDITION_INFIGHT) then
        if doPlayerAddItem(cid, 2674, 1) then
    else
    end
    return true
end
will return this error: attempt to call global 'getCreatureCondition' (a nil value)

I tried add getCreatureCondition = hasCreatureCondition, but still got the same errors, should I replace hasCondition = getCreatureCondition for this in 100-compat.lua?
Have you tried recompiling? Or are there any startup errors at all? Could possibly have overwritten the method in Lua or set it to nil by accident...

I've briefly looked at the methods in the sources and they seem to be registered, I'm not actually sure what the issue is to be honest.
 
Have you tried recompiling? Or are there any startup errors at all? Could possibly have overwritten the method in Lua or set it to nil by accident...

I've briefly looked at the methods in the sources and they seem to be registered, I'm not actually sure what the issue is to be honest.
Its nil because player has no condition set to him so it returns nil you cant not have the condition you just wont have a condition there is no if not condition_infight it returns nil not false because its condition and not boolean i think
 
Its nil because player has no condition set to him so it returns nil you cant not have the condition you just wont have a condition there is no if not condition_infight it returns nil not false because its condition and not boolean i think
What have you been smoking? Do you understand the error?

C++:
int32_t LuaInterface::luaGetCreatureCondition(lua_State* L)
{
    //getCreatureCondition(cid, condition[, subId = 0])
    uint32_t subId = 0, condition = 0;
    if(lua_gettop(L) > 2)
        subId = popNumber(L);

    condition = popNumber(L);
    ScriptEnviroment* env = getEnv();
    if(Creature* creature = env->getCreatureByUID(popNumber(L)))
        lua_pushboolean(L, creature->hasCondition((ConditionType_t)condition, subId));
    else
    {
        errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushboolean(L, false);
    }

    return 1;
}
 

Similar threads

Back
Top