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

onMoveCreature event [TFS 1.2]

OperatorMopa

Member
Joined
Feb 10, 2014
Messages
127
Reaction score
6
Hello guys, i need to track tile id every step i make, so onstepin/onstepout is useless, becouse i would have to add every tile to the script.
I've found onMoveCreature event, but it seems like it doesn't work, or i don't know how it works. I've enabled it in events.xml and added a simple sendTextMessage to execute every time it's used, but there is no result.

Any ideas to solve it?
 
Maybe you can implement this
I've tried it , and it doesn't work for me or i have incorrectly added the creaturescript

Code:
<event type="move" name="CreatureMove" script="test.lua" />
test.lua
Code:
function onMove(creature, newPos, oldPos)
    creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "TEST")
end

Nothing happens :/

I've also tried to clog some cpp functions and:
1. bool CreatureEvent::executeOnMove in creatureevent.cpp doesn't execute

2. And now the weird part :D
When i add clog at the top of Game::internalMoveCreature in game.cpp it work's fine, but when i add it into "for" loop in the same function (added in gugahoa onMove creature event commit) it doesn't show.
It looks like Game::internalMoveCreature ignore this loop - why ?
 
data\lib\compat\compat.lua line 896
Code:
function doRelocate(fromPos, toPos)
    if fromPos == toPos then
        return false
    end

    local fromTile = Tile(fromPos)
    if fromTile == nil then
        return false
    end

    if Tile(toPos) == nil then
        return false
    end

    for i = fromTile:getThingCount() - 1, 0, -1 do
        local thing = fromTile:getThing(i)
        if thing ~= nil then
            if thing:isItem() then
                if ItemType(thing:getId()):isMovable() then
                    thing:moveTo(toPos)
                end
            elseif thing:isCreature() then
                thing:teleportTo(toPos)
            end
        end
    end
    return true
end
 
data\lib\compat\compat.lua line 896
Code:
function doRelocate(fromPos, toPos)
    if fromPos == toPos then
        return false
    end

    local fromTile = Tile(fromPos)
    if fromTile == nil then
        return false
    end

    if Tile(toPos) == nil then
        return false
    end

    for i = fromTile:getThingCount() - 1, 0, -1 do
        local thing = fromTile:getThing(i)
        if thing ~= nil then
            if thing:isItem() then
                if ItemType(thing:getId()):isMovable() then
                    thing:moveTo(toPos)
                end
            elseif thing:isCreature() then
                thing:teleportTo(toPos)
            end
        end
    end
    return true
end
I don't need function to move my character, i need event to track every step





EDIT.
I've done it using https://github.com/otland/forgottenserver/pull/839/commits
 
Last edited:
Back
Top