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

Fly System TFS 1.2 question

bizao030188

Member
Joined
Jun 4, 2012
Messages
50
Solutions
2
Reaction score
7
I am trying to make my own fly system for TFS 1.2 and I am not sure about how to create a new tile in destPos while moving (onStepOut movement)

With onSay I can create a tile upstairs:
Code:
function onSay(player, words, param)
    if player:getStorageValue(storageFly) ~= 1 then return false end
    local position = player:getPosition()
    position.z = position.z - 1  
    local destTile = Tile(position)
    if not destTile then
        Game.createTile(position)
        Game.createItem(8426, 1, position)
        player:teleportTo(position)
    end  
    return true
end

but then I can't create a tile when player tries to walk using onStepOut since the method is not called when player wants to walk to void:
Code:
function onStepOut(creature, item, position, fromPosition)
    local destTile = Tile(position)
    if not destTile then
        Game.createTile(position)
        Game.createItem(8426, 1, position)
        creature:teleportTo(position, false)
    end  
    return true
end

I appreciate any kind of help.
 

Thanks man, what he does is create the following creature event:
C++:
bool CreatureEvent::executeOnMove(Player* player, const Position& fromPosition, const Position& toPosition)
{
    //onMove(player, frompos, topos)
    if (!scriptInterface->reserveScriptEnv()) {
        std::cout << "[Error - CreatureEvent::executeOnMove] Call stack overflow" << std::endl;
        return false;
    }

    ScriptEnvironment* env = scriptInterface->getScriptEnv();
    env->setScriptId(scriptId, scriptInterface);

    lua_State* L = scriptInterface->getLuaState();
    scriptInterface->pushFunction(scriptId);

    LuaScriptInterface::pushUserdata(L, player);
    LuaScriptInterface::setMetatable(L, -1, "Player");
    LuaScriptInterface::pushPosition(L, fromPosition);
    LuaScriptInterface::pushPosition(L, toPosition);

    return scriptInterface->callFunction(3);
}

which I did not understand very well, but it works!

Actually, as the onStepOut is not executed while walking to void he created the onMove that is always executed when a player moves.
 
Back
Top