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

!pz tfs 0.4 Tibia 8.6 problem

jareczekjsp

Member
Joined
Jan 30, 2023
Messages
185
Reaction score
9
GitHub
Jarek123
Hello Guys I use Script

Lua:
function onSay(cid, words, param, channel)
if not getCreatureCondition(cid, CONDITION_INFIGHT) then -- before is hasCondition.
return doPlayerSendCancel(cid, "You Don't Have Pz") and doSendMagicEffect(getThingPos(cid), 2)
end

doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You Have To Wait " .. (math.floor(getInFightTicks(cid) / 1000) - os.time()) .. " Second For Pz.")
    return true
end

and I have problem because when I dont have whiteskull Command !pz ,working is write "You Don't Have Pz"

but when I have white skull nothing is write I can spamming !pz command ,how I can fix it guys?
Post automatically merged:

When I have whiteskull Is error in console like that

Lua:
[3:10:06] [Error - TalkAction Interface]
[3:10:06] data/talkactions/scripts/pz.lua:onSay
[3:10:06] Description:
[3:10:06] data/talkactions/scripts/pz.lua:6: attempt to call global 'getInFightTicks' (a nil value)
[3:10:06] stack traceback:
[3:10:06]       data/talkactions/scripts/pz.lua:6: in function <data/talkactions/scripts/pz.lua:1>
 
Last edited:
Hello Guys I use Script

Lua:
function onSay(cid, words, param, channel)
if not getCreatureCondition(cid, CONDITION_INFIGHT) then -- before is hasCondition.
return doPlayerSendCancel(cid, "You Don't Have Pz") and doSendMagicEffect(getThingPos(cid), 2)
end

doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You Have To Wait " .. (math.floor(getInFightTicks(cid) / 1000) - os.time()) .. " Second For Pz.")
    return true
end

and I have problem because when I dont have whiteskull Command !pz ,working is write "You Don't Have Pz"

but when I have white skull nothing is write I can spamming !pz command ,how I can fix it guys?
Post automatically merged:

When I have whiteskull Is error in console like that

Lua:
[3:10:06] [Error - TalkAction Interface]
[3:10:06] data/talkactions/scripts/pz.lua:onSay
[3:10:06] Description:
[3:10:06] data/talkactions/scripts/pz.lua:6: attempt to call global 'getInFightTicks' (a nil value)
[3:10:06] stack traceback:
[3:10:06]       data/talkactions/scripts/pz.lua:6: in function <data/talkactions/scripts/pz.lua:1>
check this solution

 
Last edited:
is the same

Lua:
[3:40:31] [Error - TalkAction Interface]
[3:40:31] data/talkactions/scripts/pz.lua:onSay
[3:40:31] Description:
[3:40:31] data/talkactions/scripts/pz.lua:6: attempt to call global 'getInFightTicks' (a nil value)
[3:40:31] stack traceback:
[3:40:31]       data/talkactions/scripts/pz.lua:6: in function <data/talkactions/scripts/pz.lua:1>
 
When I compile I have error

Lua:
/home/ots/src/luascript.cpp:9333:9: error: ‘LuaScriptInterface’ has not been dec                                                                                        lared
 9333 | int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
      |         ^~~~~~~~~~~~~~~~~~
/home/ots/src/luascript.cpp: In function ‘int32_t luaGetInFightTicks(lua_State*                                                                                         ’:
/home/ots/src/luascript.cpp:9335:20: error: ‘getNumber’ was not declared in this                                                                                         scope; did you mean ‘isNumber’?
 9335 |     uint32_t cid = getNumber<uint32_t>(L, 1);
      |                    ^~~~~~~~~
      |                    isNumber
/home/ots/src/luascript.cpp:9335:38: error: expected primary-expression before                                                                                          >’ token
 9335 |     uint32_t cid = getNumber<uint32_t>(L, 1);
      |                                      ^
/home/ots/src/luascript.cpp:9340:13: error: ‘pushNumber’ was not declared in thi                                                                                        s scope; did you mean ‘lua_Number’?
 9340 |             pushNumber(L, condition->getEndTime());
      |             ^~~~~~~~~~
      |             lua_Number
/home/ots/src/luascript.cpp:9342:13: error: ‘pushNil’ was not declared in this s                                                                                        cope
 9342 |             pushNil(L);
      |             ^~~~~~~
/home/ots/src/luascript.cpp:9345:9: error: ‘pushNil’ was not declared in this sc                                                                                        ope
 9345 |         pushNil(L);
      |         ^~~~~~~
make[2]: *** [CMakeFiles/theforgottenserver.dir/build.make:580: CMakeFiles/thefo                                                                                        rgottenserver.dir/src/luascript.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/theforgottenserver.dir/all] E                                                                                        rror 2
make: *** [Makefile:91: all] Error 2
Post automatically merged:

Can you help me bro?
Post automatically merged:

up
Post automatically merged:

anyone know what is problem?
 
Last edited:
yes I add this one to luascript.cpp


Lua:
int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
{
    Creature* creature = g_game.getCreatureByID(cid);
    Condition* condition = creature->getCondition(CONDITION_INFIGHT, (ConditionId_t)CONDITION_INFIGHT);

    if(creature)
    {
        condition->getEndTime();
        pushNumber(L, true);

    }else{

        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushNumber(L, false);

    }

    return 1;
}
Post automatically merged:

and this one I try
Code:
int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
{
    uint32_t cid = getNumber<uint32_t>(L, 1);
    Creature* creature = g_game.getCreatureByID(cid);
    if (creature) {
        Condition* condition = creature->getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT);
        if (condition) {
            pushNumber(L, condition->getEndTime());
        } else {
            pushNil(L);
        }
    } else {
        pushNil(L);
    }
    return 1;
}
 
yes I add this one to luascript.cpp


Lua:
int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
{
    Creature* creature = g_game.getCreatureByID(cid);
    Condition* condition = creature->getCondition(CONDITION_INFIGHT, (ConditionId_t)CONDITION_INFIGHT);

    if(creature)
    {
        condition->getEndTime();
        pushNumber(L, true);

    }else{

        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushNumber(L, false);

    }

    return 1;
}
That's right, but you need to declare a file, like 'luascript.h', or some specific part, for the function to be recognized and the compilation to be successful, do you understand?
 
So i Do something wrong?,and I use tfs 0.4 this man use tfs 1.0
Post automatically merged:

So bro How I can declare in file luascript.h?

I have PAste the same ?
Lua:
int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
{
    Creature* creature = g_game.getCreatureByID(cid);
    Condition* condition = creature->getCondition(CONDITION_INFIGHT, (ConditionId_t)CONDITION_INFIGHT);

    if(creature)
    {
        condition->getEndTime();
        pushNumber(L, true);

    }else{

        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushNumber(L, false);

    }

    return 1;
}
 
Try replacing this in luascript.cpp and compile. If an error appears indicating that something is missing or undeclared, you will need to add it to luascript.h or some other file.

C++:
int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
{
    Creature* creature = g_game.getCreatureByID(cid);

    if (creature)
    {
        Condition* condition = creature->getCondition(CONDITION_INFIGHT, (ConditionId_t)CONDITION_INFIGHT);

        if (condition)
        {
          
            int endTime = condition->getEndTime();

          
            pushNumber(L, true);
        }
        else
        {
          
            reportErrorFunc(getErrorDesc(LUA_ERROR_CONDITION_NOT_FOUND));
            pushNumber(L, false);
        }
    }
    else
    {
      
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushNumber(L, false);
    }

    return 1;
}
 
ok thanks moment please I try compile
Post automatically merged:

So I add this to luascript.cpp and is error so I have put his the same to luascript.h? or deleted it in cpp and add to luascript .h?
Post automatically merged:

When I put this
Lua:
int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
{
    Creature* creature = g_game.getCreatureByID(cid);

    if (creature)
    {
        Condition* condition = creature->getCondition(CONDITION_INFIGHT, (ConditionId_t)CONDITION_INFIGHT);

        if (condition)
        {
          
            int endTime = condition->getEndTime();

          
            pushNumber(L, true);
        }
        else
        {
          
            reportErrorFunc(getErrorDesc(LUA_ERROR_CONDITION_NOT_FOUND));
            pushNumber(L, false);
        }
    }
    else
    {
      
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushNumber(L, false);
    }
to luascript is new errors
Post automatically merged:

Lua:
/home/ots/src/luascript.h:779:9: error: ‘LuaScriptInterface’ has not been declared
  779 | int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
      |         ^~~~~~~~~~~~~~~~~~
/home/ots/src/actions.h:62:30: error: field ‘m_interface’ has incomplete type ‘LuaInterface’
   62 |                 LuaInterface m_interface;
      |                              ^~~~~~~~~~~
/home/ots/src/luascript.h:222:7: note: forward declaration of ‘class LuaInterface’
  222 | class LuaInterface
      |       ^~~~~~~~~~~~
In file included from /home/ots/src/creature.h:23,
                 from /home/ots/src/player.h:23,
                 from /home/ots/src/actions.cpp:23:
/usr/include/boost/any.hpp:33:1: error: expected unqualified-id before ‘namespace’
   33 | namespace boost
      | ^~~~~~~~~
In file included from /home/ots/src/fileloader.h:23,
                 from /home/ots/src/map.h:22,
                 from /home/ots/src/creature.h:28:
/usr/include/zlib.h:37:8: error: expected unqualified-id before string constant
   37 | extern "C" {
      |        ^~~
/home/ots/src/fileloader.h:162:17: error: ‘gzFile’ does not name a type
  162 |                 gzFile m_file;
      |                 ^~~~~~
In file included from /home/ots/src/map.h:25:
/home/ots/src/waypoints.h:48:13: error: cannot define member function ‘LuaInterface::Waypoints::addWaypoint’ within ‘LuaInterface’
   48 | inline void Waypoints::addWaypoint(WaypointPtr waypoint)
      |             ^~~~~~~~~
/home/ots/src/waypoints.h:52:20: error: cannot define member function ‘LuaInterface::Waypoints::getWaypointByName’ within ‘LuaInterface’
   52 | inline WaypointPtr Waypoints::getWaypointByName(const std::string& name) const
      |                    ^~~~~~~~~
In file included from /home/ots/src/item.h:26,
                 from /home/ots/src/tile.h:23,
                 from /home/ots/src/map.h:26:
and more
Post automatically merged:

My scripts is
 
Last edited:
ok thanks moment please I try compile
Post automatically merged:

So I add this to luascript.cpp and is error so I have put his the same to luascript.h? or deleted it in cpp and add to luascript .h?
Post automatically merged:

When I put this
Lua:
int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
{
    Creature* creature = g_game.getCreatureByID(cid);

    if (creature)
    {
        Condition* condition = creature->getCondition(CONDITION_INFIGHT, (ConditionId_t)CONDITION_INFIGHT);

        if (condition)
        {
         
            int endTime = condition->getEndTime();

         
            pushNumber(L, true);
        }
        else
        {
         
            reportErrorFunc(getErrorDesc(LUA_ERROR_CONDITION_NOT_FOUND));
            pushNumber(L, false);
        }
    }
    else
    {
     
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushNumber(L, false);
    }
to luascript is new errors
Post automatically merged:


and more
Post automatically merged:

My scripts is
add in luascript.h this
static int32_t luaGetInFightTicks(lua_State* L);
 
I dont know how I can fix it;/
luascript.cpp
Lua:
//getInFightTicks(cid)
    lua_register(m_luaState, "getInFightTicks", LuaInterface::luaGetInFightTicks);
Lua:
int32_t LuaInterface::luaGetInFightTicks(lua_State* L)
{
    ScriptEnviroment* env = getEnv();
    Player* creature = env->getPlayerByUID((uint32_t)popNumber(L));
    if (creature) {
        Condition* condition = creature->getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT);
        if (condition) {
            lua_pushnumber(L, condition->getEndTime());
        } else {
            lua_pushnil(L);
        }
    } else {
        lua_pushnil(L);
    }
    return 1;
}
luascript.h
Lua:
static int32_t luaGetInFightTicks(lua_State* L);
and replace getCreatureCondition to hasCondition
 
Last edited:
Back
Top