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

Lua If you are on ITEMID tile you cant push

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
993
Solutions
5
Reaction score
55
tfs 1.2 so i need script if player is on specific tile you cant push him if hes on that tile (it would be good if you could go trough him too if its possible)
 
Solution
tfs 1.2 so i need script if player is on specific tile you cant push him if hes on that tile (it would be good if you could go trough him too if its possible)
Hi,
This code will block Player be pushed when above the tile ID 106 and 405.

In data/events/scripts/player.lua look for Player:onMoveCreature function and above the last return true in the function scope put:
Lua:
local blockedIds = {106, 405} --106 = grass id, 405 = wooden floor id
if table.contains(blockedIds, fromPosition:getTile():getId()) then
    return false
end
Lua:
function Player:onMoveCreature(creature, fromPosition, toPosition)
    local blockedIds = {106, 405} --106 = grass id, 405 = wooden floor id
    if table.contains(blockedIds...
tfs 1.2 so i need script if player is on specific tile you cant push him if hes on that tile (it would be good if you could go trough him too if its possible)
Hi,
This code will block Player be pushed when above the tile ID 106 and 405.

In data/events/scripts/player.lua look for Player:onMoveCreature function and above the last return true in the function scope put:
Lua:
local blockedIds = {106, 405} --106 = grass id, 405 = wooden floor id
if table.contains(blockedIds, fromPosition:getTile():getId()) then
    return false
end
Lua:
function Player:onMoveCreature(creature, fromPosition, toPosition)
    local blockedIds = {106, 405} --106 = grass id, 405 = wooden floor id
    if table.contains(blockedIds, fromPosition:getTile():getId()) then
        return false
    end
    return true
end
Now go to data/events/events.xml and look for <event class="Player" method="onMoveCreature" enabled="1"/> and be sure that enabled value is 1.
 
Solution
Hi,
This code will block Player be pushed when above the tile ID 106 and 405.

In data/events/scripts/player.lua look for Player:onMoveCreature function and above the last return true in the function scope put:
Lua:
local blockedIds = {106, 405} --106 = grass id, 405 = wooden floor id
if table.contains(blockedIds, fromPosition:getTile():getId()) then
    return false
end
Lua:
function Player:onMoveCreature(creature, fromPosition, toPosition)
    local blockedIds = {106, 405} --106 = grass id, 405 = wooden floor id
    if table.contains(blockedIds, fromPosition:getTile():getId()) then
        return false
    end
    return true
end
Now go to data/events/events.xml and look for <event class="Player" method="onMoveCreature" enabled="1"/> and be sure that enabled value is 1.
Will test it
 
Back
Top