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

Solved !pz command - please help! :)

tivep91

New Member
Joined
Jul 1, 2012
Messages
39
Reaction score
2
Hello all!

Is there a script that checks if player is PZ?

! pz

12:33 You have to wait another 43 seconds.
 
Need Source edits.. i have finished the edits
here you are
in luascript.cpp
Code:
int32_t LuaInterface::luaGetInFightTicks(lua_State* L)
{
    ScriptEnviroment* env = getEnv();
    Creature* creature = env->getCreatureByUID(popNumber(L));
    Condition* condition = creature->getCondition(CONDITION_INFIGHT, (ConditionId_t)CONDITION_INFIGHT);

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

    }else{

        errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushnumber(L, false);

    }

    return 1;
}

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

    doPlayerSendTextMessage(cid,27, "You Have To Wait "..getInFightTicks(cid).." Second For Pz.")
    return true
end

don't ask where to put or how.
 
Last edited:
When i compiling:

CMakeFiles/tfs.dir/src/luascript.cpp.o: In function `LuaScriptInterface::luaGetInFightTicks(lua_State*)':
luascript.cpp:(.text+0x1ba86): undefined reference to `ScriptEnvironment::getCreatureByUID(unsigned int)'
collect2: error: ld returned 1 exit status
make[2]: *** [tfs] Error 1
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
make: *** [all] Error 2


@edit

I must edit your source code to this:

PHP:
int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
{
    ScriptEnvironment* env = getScriptEnv();
    Creature* creature = env->getCreatureByUID(popNumber(L));
    Condition* condition = creature->getCondition(CONDITION_INFIGHT, (ConditionId_t)CONDITION_INFIGHT);

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

    }else{

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

    }

    return 1;
}
 
Try This One
Code:
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;
}
 
/home/ots/tfs/src/luascript.cpp: In static member function 'static int32_t LuaScriptInterface::luaGetInFightTicks(lua_State*)':
/home/ots/tfs/src/luascript.cpp:3034:49: error: 'cid' was not declared in this scope
 
Code:
int32_t LuaScriptInterface::luaGetInFightTicks(lua_State* L)
{
        uint32_t cid = popNumber(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;
}
 
Segmentation fault - server is crashing.

I must edit code to this:
PHP:
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,27, "You Have To Wait "..getInFightTicks(cid).." Second For Pz.")
    return true
end

(hasCondition a nil value etc...)

i am waiting for help.

- - - Edited - - -

Solution: https://github.com/otland/forgottenserver/issues/197
 
Last edited by a moderator:
I know that you have solved this already but others may look for this as well.

Doesn't require any source edit (for TFS 1.0 users)
Code:
" .. (math.floor(Player(cid):getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT):getEndTime() / 1000) - os.time()) .. "

- - - Edited - - -

Added link to the source code fix in his last post
 
Back
Top