• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

RevScripts throw items delay

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
198
Reaction score
14
Hello, good night, someone will have a method to delay the following items by throwing them on the floor.

  • 2148 (Gold Coin)
  • 2152 (Platinum Coin)
  • 2160 (Crystal Coin)
  • 3976 (Worms)

In a nutshell, for
put a delay on the anti push

i used otbr tfs 1.3
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
Try this?

It tracks the last tile that the 'delayed items' were placed on.
If someone tries to place another delayed item onto the same tile again, they are delayed.

If someone places it on tile 1, then tile 2, then tile 1 again, there is no delay, as these are different tiles each time.

Lua:
local delayedItems = {2148, 2152, 2160, 3976}
local delay = 1000 -- milliseconds
local creatures = {}

local delayMovingItemsToSameTile = EventCallback

delayMovingItemsToSameTile.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if not table.contains(delayedItems, item:getId()) then
        return true
    end
    if toPosition.x == CONTAINER_POSITION then
        return true
    end
    local cid = self:getId()
    local mtime = os.mtime()
    if creatures[cid] and creatures[cid].position == toPosition and creatures[cid].delayTime > mtime then
        return false
    end
    creatures[cid] = {position = toPosition, delayTime = mtime + delay}
    return true
end

delayMovingItemsToSameTile:register()
 

Fabi Marzan

Member
Joined
Aug 31, 2020
Messages
61
Solutions
1
Reaction score
11
Try this?

It tracks the last tile that the 'delayed items' were placed on.
If someone tries to place another delayed item onto the same tile again, they are delayed.

If someone places it on tile 1, then tile 2, then tile 1 again, there is no delay, as these are different tiles each time.

Lua:
local delayedItems = {2148, 2152, 2160, 3976}
local delay = 1000 -- milliseconds
local creatures = {}

local delayMovingItemsToSameTile = EventCallback

delayMovingItemsToSameTile.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if not table.contains(delayedItems, item:getId()) then
        return true
    end
    if toPosition.x == CONTAINER_POSITION then
        return true
    end
    local cid = self:getId()
    local mtime = os.mtime()
    if creatures[cid] and creatures[cid].position == toPosition and creatures[cid].delayTime > mtime then
        return false
    end
    creatures[cid] = {position = toPosition, delayTime = mtime + delay}
    return true
end

delayMovingItemsToSameTile:register()
That system is very useful, but is there another one that doesn't allow you to drop certain items under you? That you can't pull under your feet or the other player's... to eliminate the anti push completely.
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
That system is very useful, but is there another one that doesn't allow you to drop certain items under you? That you can't pull under your feet or the other player's... to eliminate the anti push completely.

Alright.
If the tile has a player on it, it won't allow the item to be moved under them.

Lua:
local disableMovingItemsUnderAPlayer = EventCallback

disableMovingItemsUnderAPlayer.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if toPosition.x ~= CONTAINER_POSITION then
        return true
    end
    local tile = Tile(toPosition)
    if not tile then
        return false
    end
    local creatures = tile:getCreatures()
    for i = 1, #creatures do
        local player = Player(creatures[i])
        if player:isPlayer() then
            return false
        end
    end
    return true
end

disableMovingItemsUnderAPlayer:register()
 

Fabi Marzan

Member
Joined
Aug 31, 2020
Messages
61
Solutions
1
Reaction score
11
Alright.
If the tile has a player on it, it won't allow the item to be moved under them.

Lua:
local disableMovingItemsUnderAPlayer = EventCallback

disableMovingItemsUnderAPlayer.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if toPosition.x ~= CONTAINER_POSITION then
        return true
    end
    local tile = Tile(toPosition)
    if not tile then
        return false
    end
    local creatures = tile:getCreatures()
    for i = 1, #creatures do
        local player = Player(creatures[i])
        if player:isPlayer() then
            return false
        end
    end
    return true
end

disableMovingItemsUnderAPlayer:register()
It didn't work for me, it still lets me drop objects under me... am I doing something wrong? create a new file and put it inside /scripts/eventcallbacks/player.
 

Roddet

life.rbegin()
Joined
May 1, 2013
Messages
643
Solutions
61
Reaction score
380
Location
MX
Replace toPosition.x to fromPosition.x or if you want delay to work even by moving items from ground and not just from container then just replace ~= with ==
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
It didn't work for me, it still lets me drop objects under me... am I doing something wrong? create a new file and put it inside /scripts/eventcallbacks/player.
made a mistake
Lua:
if toPosition.x ~= CONTAINER_POSITION then
change to ==
 
OP
OP
A

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
198
Reaction score
14
Try this?

It tracks the last tile that the 'delayed items' were placed on.
If someone tries to place another delayed item onto the same tile again, they are delayed.

If someone places it on tile 1, then tile 2, then tile 1 again, there is no delay, as these are different tiles each time.

Lua:
local delayedItems = {2148, 2152, 2160, 3976}
local delay = 1000 -- milliseconds
local creatures = {}

local delayMovingItemsToSameTile = EventCallback

delayMovingItemsToSameTile.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if not table.contains(delayedItems, item:getId()) then
        return true
    end
    if toPosition.x == CONTAINER_POSITION then
        return true
    end
    local cid = self:getId()
    local mtime = os.mtime()
    if creatures[cid] and creatures[cid].position == toPosition and creatures[cid].delayTime > mtime then
        return false
    end
    creatures[cid] = {position = toPosition, delayTime = mtime + delay}
    return true
end

delayMovingItemsToSameTile:register()
I have this error
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/antipush.lua
/home/forgottenserver/data/scripts/antipush.lua:21: attempt to index local 'delayMovingItemsToSameTile' (a nil value)
stack traceback:
        [C]: in function '__newindex'
        /home/forgottenserver/data/scripts/antipush.lua:21: in main chunk
> antipush.lua [error]
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
I have this error
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/antipush.lua
/home/forgottenserver/data/scripts/antipush.lua:21: attempt to index local 'delayMovingItemsToSameTile' (a nil value)
stack traceback:
        [C]: in function '__newindex'
        /home/forgottenserver/data/scripts/antipush.lua:21: in main chunk
> antipush.lua [error]
You must have copied it wrong.

I just tested it and have no problems
 
OP
OP
A

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
198
Reaction score
14
You must have copied it wrong.

I just tested it and have no problems
error
1647216050532.png

script.lua
Lua:
local delayedItems = {2148, 2152, 2160, 3976}
local delay = 1000 -- milliseconds
local creatures = {}

local delayMovingItemsToSameTile = EventCallback

delayMovingItemsToSameTile.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if not table.contains(delayedItems, item:getId()) then
        return true
    end
    if toPosition.x == CONTAINER_POSITION then
        return true
    end
    local cid = self:getId()
    local mtime = os.mtime()
    if creatures[cid] and creatures[cid].position == toPosition and creatures[cid].delayTime > mtime then
        return false
    end
    creatures[cid] = {position = toPosition, delayTime = mtime + delay}
    return true
end

delayMovingItemsToSameTile:register()
1647216074726.png
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
Dunno what to do for you here.

It works on regular tfs, but not your otbr version.

My only solution for you is to go find a working onMoveItem script.. and transplant my script into it?
 
Top