• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Help script onMove storage

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,209
Solutions
2
Reaction score
154
The script is to prevent a player from moving the item quickly, but the storage is going to third parties (other players that should not receive storage).

LUA:
local maxItemsPerSecond = 1
local stor = 1009191
local exhaust = 3
local startMove = 0
local itemsMove = 0

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)       
       
    local containerIdFromZ = fromPosition.y - 64
    local testeszzz = self:getContainerById(containerIdFromZ)   
   
    local tile = toPosition:getTile()
    if testeszzz then       
            if tile then
                if (tile:getTopCreature()) then
                        local p = Player(tile:getTopCreature():getId())
                        if (p) then
                                if (startMove == 0) then
                                        startMove = os.time()
                                elseif (startMove == os.time()) then
                                        itemsMove = itemsMove + 1
                                elseif(os.time() > startMove) then
                                        startMove = 0
                                        itemsMove = 0
                                end                                   
                               
                                if (itemsMove > maxItemsPerSecond) then
                                    self:setStorageValue(stor, os.time() + exhaust)           
                                end
                               
                                if (self:getStorageValue(stor) > os.time()) then                                       
                                        return false
                                end   
                        end
                end
        end
    end
 
Back
Top