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

TFS 1.X+ block house push

peteralto

Member
Joined
Nov 1, 2020
Messages
93
Solutions
1
Reaction score
19
How could I block players from pushing players into houses (tile)?
 
Solution
E
you can achieve this with a simple if at onMoveCreature event:

Lua:
function Player:onMoveCreature(creature, fromPosition, toPosition)
    local tile = Tile(toPosition)
    if tile and tile:getHouse() then
        self:sendTextMessage(MESSAGE_STATUS_SMALL, "Sorry not possible xD")
        return false
    end
    if EventCallback.onMoveCreature then
        return EventCallback.onMoveCreature(self, creature, fromPosition, toPosition)
    end
    return true
end


in events.xml set enabled="1" for onMoveCreature
you can achieve this with a simple if at onMoveCreature event:

Lua:
function Player:onMoveCreature(creature, fromPosition, toPosition)
    local tile = Tile(toPosition)
    if tile and tile:getHouse() then
        self:sendTextMessage(MESSAGE_STATUS_SMALL, "Sorry not possible xD")
        return false
    end
    if EventCallback.onMoveCreature then
        return EventCallback.onMoveCreature(self, creature, fromPosition, toPosition)
    end
    return true
end


in events.xml set enabled="1" for onMoveCreature
 
Solution
you can achieve this with a simple if at onMoveCreature event:

Lua:
function Player:onMoveCreature(creature, fromPosition, toPosition)
    local tile = Tile(toPosition)
    if tile and tile:getHouse() then
        self:sendTextMessage(MESSAGE_STATUS_SMALL, "Sorry not possible xD")
        return false
    end
    if EventCallback.onMoveCreature then
        return EventCallback.onMoveCreature(self, creature, fromPosition, toPosition)
    end
    return true
end


in events.xml set enabled="1" for onMoveCreature
Cool, thanks!
 
Back
Top