Advertisement
MillhioreBT

DreamOfGold.lua

Dec 28th, 2020 (edited)
1,008
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.38 KB | None | 0 0
  1. --[[
  2.  
  3.     Credits: Sarah Wesker
  4.     Version: 1.1
  5.     Compat: TFS 1.3
  6.     Create: December 2020
  7.  
  8. ]]--
  9.  
  10. local config = {
  11.     miscellaneous = {
  12.         name = "Dream Of Gold", -- event name
  13.         talkaction = "!dream", -- Talkaction words
  14.         -->> These two functions are compatible with newer versions of TFS Eyes o.o <<-
  15.         canPushPlayers = false, -- Allow players within the event to push each other?
  16.     },
  17.     start = {
  18.         time = "20:02:10", -- time to start event each day
  19.         waiting = '60s', -- wait player to enter event, examples: 10s -> 10 seconds | 2m -> 2 minutes
  20.         ending = '2m' -- 5 minutes finish event
  21.     },
  22.     area = {
  23.         fromPos = Position(3093, 1880, 7), -- Upper left corner
  24.         toPos = Position(3125, 1906, 7), -- Lower right corner
  25.         waitZone = Position(3078, 1904, 7) -- Waiting room
  26.     },
  27.     players = {
  28.         min = 2, -- min required
  29.         max = 10, -- max players in the evento
  30.         storage = 7777, -- storage, to remove players from the event in case they get trapped! (it should never happen)
  31.         speed = 250 -- speed at which players must move in the event
  32.     },
  33.     state = {
  34.         type = 'stoped', -- no edit!
  35.         debug = false -- not use in production
  36.     },
  37.     gold = { -- Properties in the event
  38.         id = 2148, -- gold coin ID
  39.         aid = 7777, -- cambia este valor si ya tienes en uso este Action ID
  40.         chestId = 5675, -- chestId
  41.         chestAid = 7778, -- cambia este valor si ya tienes en uso este Action ID
  42.         chestChance = 2, -- chance for create chest on area
  43.         chestValues = {500,800} -- chance of gain 500 to 800 gold when use the chest
  44.     },
  45.     rewardBag = 1992, -- Reward bag id
  46.     rewards = { -- In this table, you can add the rewards, as are the example:
  47.         { itemId = 2160, count = 100, chance = 100 },
  48.         { itemId = 7591, count = 100, chance = 70 },
  49.         { itemId = 7590, count = 100, chance = 70 }
  50.     },
  51.     cache = { -- This table should not be modified for anything
  52.         eventIds = {},
  53.         players = {},
  54.         tiles = {},
  55.         tileCount = 0
  56.     }
  57. }
  58.  
  59. --Check if your Server is compatible
  60. if not EventCallback or not Container.getItems then
  61.     print("------------------------DREAM EVENT------------------------\nWARNING: YOUR SERVER IS NOT COMPATIBLE WITH THIS EVENT\nREQUIREMENTS: TFS 1.3\nhttps://github.com/otland/forgottenserver/pull/2867\nhttps://github.com/otland/forgottenserver/pull/3160\n-------------------------------------------------------------")
  62.     config = nil
  63. else
  64.  
  65.     _DGE = {}
  66.  
  67.     function _DGE.isWalkable(x, y, z)
  68.         local tile = Tile(x, y, z)
  69.         if not tile or tile:hasFlag(TILESTATE_FLOORCHANGE) then
  70.             return false
  71.         end
  72.  
  73.         local ground = tile:getGround()
  74.         if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
  75.             return false
  76.         end
  77.  
  78.         local items = tile:getItems()
  79.         for i = 1, tile:getItemCount() do
  80.             local item = items[i]
  81.             local itemType = item:getType()
  82.             if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
  83.                 return false
  84.             end
  85.         end
  86.         return tile
  87.     end
  88.  
  89.     local function loadTiles()
  90.         config.cache.tiles = {}
  91.         config.cache.tileCount = 0
  92.         for x = config.area.fromPos.x, config.area.toPos.x do
  93.             for y = config.area.fromPos.y, config.area.toPos.y do
  94.                 local tile = _DGE.isWalkable(x, y, config.area.fromPos.z)
  95.                 if tile then
  96.                     local ground = tile:getGround()
  97.                     ground:setAttribute(ITEM_ATTRIBUTE_ACTIONID, config.gold.aid)
  98.                     config.cache.tileCount = config.cache.tileCount +1
  99.                     ground:setCustomAttribute('tileIndex', config.cache.tileCount)
  100.                     table.insert(config.cache.tiles, tile)
  101.                 end
  102.             end
  103.         end
  104.     end
  105.  
  106.     local function formatTime(seconds)
  107.         if seconds <= 0 then return '0s' end
  108.         local days = math.floor(seconds / 86400)
  109.         seconds = (seconds % 86400)
  110.         local hours = math.floor(seconds / 3600)
  111.         seconds = (seconds % 3600)
  112.         local minutes = math.floor(seconds / 60)
  113.         seconds = (seconds % 60)
  114.         local result = ''
  115.         if days >= 1 then result = string.format("%s%u days", result, days) end
  116.         if hours >= 1 then result = string.format("%s%s%u hours", result, (days > 0 and ' ' or ''), hours) end
  117.         if minutes >= 1 then result = string.format("%s%s%u minutes", result, (hours > 0 and ' ' or ''), minutes) end
  118.         if seconds >= 1 then result = string.format("%s%s%u seconds", result, (minutes > 0 and ' ' or ''), seconds) end
  119.         return result
  120.     end
  121.  
  122.     local function getTime(str)
  123.         local seconds = str:match('(%d+)s') or 0
  124.         local minutes = str:match('(%d+)m') or 0
  125.         local hours = str:match('(%d+)h') or 0
  126.         return seconds, minutes, hours
  127.     end
  128.  
  129.     function _DGE.debug(message)
  130.         print(string.format("[%s - Debug] %s", config.miscellaneous.name, message))
  131.     end
  132.  
  133.     function _DGE.eventSay(message)
  134.         Game.broadcastMessage(string.format("%s says:\n%s", config.miscellaneous.name, message), MESSAGE_EVENT_ADVANCE)
  135.     end
  136.  
  137.     function _DGE.sayToPlayers(message)
  138.         for _, p in pairs(config.cache.players) do
  139.             local player = Player(p.id)
  140.             if player then
  141.                 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s says:\n%s", config.miscellaneous.name, message))
  142.             end
  143.         end
  144.     end
  145.  
  146.     function _DGE.removeCachePlayer(player)
  147.         local playerId = player:getId()
  148.         for index, p in pairs(config.cache.players) do
  149.             if p.id == playerId then
  150.                 table.remove(config.cache.players, index)
  151.                 return true
  152.             end
  153.         end
  154.         return false
  155.     end
  156.  
  157.     function _DGE.finish()
  158.         if #config.cache.players > 1 then
  159.             table.sort(config.cache.players, function (p1, p2) return p1.score > p2.score end)
  160.         else
  161.             _DGE.close()
  162.             return
  163.         end
  164.         local winner = Player(config.cache.players[1].id)
  165.         if winner then
  166.             winner:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Congratulations, you are the winner!")
  167.             _DGE.eventSay(string.format("The player %s is the winner!", winner:getName()))
  168.             _DGE.sendRewards(winner)
  169.         end
  170.         _DGE.close()
  171.     end
  172.  
  173.     function _DGE.sendRewards(winner)
  174.         local bag = Game.createItem(config.rewardBag, 1)
  175.         if bag then
  176.             for _, reward in pairs(config.rewards) do
  177.                 if reward.chance >= math.random(1, 100) then
  178.                     bag:addItem(reward.itemId, reward.count, INDEX_WHEREEVER, FLAG_NOLIMIT)
  179.                 end
  180.             end
  181.             local inbox = winner:getInbox()
  182.             if inbox then
  183.                 local description, items = "You rewards: ", bag:getItems()
  184.                 for _, item in pairs(items) do
  185.                     description = string.format("%s%d %s%s", description, item:getCount(), item:getName(), (_ == #items and '.' or ', '))
  186.                 end
  187.                 inbox:addItemEx(bag, INDEX_WHEREEVER, FLAG_NOLIMIT)
  188.                 winner:sendTextMessage(MESSAGE_INFO_DESCR, description..'\nCheck your depot inbox.')
  189.             end
  190.         end
  191.     end
  192.  
  193.     function _DGE.resetPlayer(player)
  194.         _DGE.changeSpeedTo(player, true)
  195.         player:setMovementBlocked(false)
  196.         player:setStorageValue(config.players.storage, -1)
  197.         local town = player:getTown()
  198.         if not town then town = Town(1) end
  199.         player:getPosition():sendMagicEffect(CONST_ME_POFF)
  200.         local townPos = town:getTemplePosition()
  201.         player:teleportTo(townPos)
  202.         townPos:sendMagicEffect(CONST_ME_TELEPORT)
  203.     end
  204.  
  205.     function _DGE.changeSpeedTo(player, remove)
  206.         local speed = player:getSpeed()
  207.         if remove then
  208.             local index = _DGE.isPlayerExist(player)
  209.             if index then
  210.                 local base = config.cache.players[index].speed
  211.                 if speed > base then
  212.                     local diff = base - speed
  213.                     player:changeSpeed(diff)
  214.                 elseif speed < base then
  215.                     local diff = speed - base
  216.                     player:changeSpeed(math.abs(diff))
  217.                 end
  218.             end
  219.             return
  220.         end
  221.         if speed > config.players.speed then
  222.             local diff = config.players.speed - speed
  223.             player:changeSpeed(diff)
  224.         elseif speed < config.players.speed then
  225.             local diff = speed - config.players.speed
  226.             player:changeSpeed(math.abs(diff))
  227.         end
  228.     end
  229.  
  230.     function _DGE.checkSpeedPlayers()
  231.         for _, p in pairs(config.cache.players) do
  232.             local player = Player(p.id)
  233.             if player then
  234.                 _DGE.changeSpeedTo(player)
  235.             end
  236.         end
  237.         config.cache.eventIds['speed'] = addEvent(_DGE.checkSpeedPlayers, 1000)
  238.     end
  239.  
  240.     function _DGE.clean(withoutCreatures, exactlyTile)
  241.         local function clean(tile)
  242.             local gold = tile:getItemById(config.gold.id)
  243.             while gold do
  244.                 gold:remove()
  245.                 gold = tile:getItemById(config.gold.id)
  246.             end
  247.             local chest = tile:getItemById(config.gold.chestId)
  248.             while chest do
  249.                 chest:remove()
  250.                 chest = tile:getItemById(config.gold.chestId)
  251.             end
  252.         end
  253.         if exactlyTile then
  254.             clean(config.cache.tiles[exactlyTile])
  255.             return
  256.         end
  257.         for _, tile in pairs(config.cache.tiles) do
  258.             clean(tile)
  259.             if not withoutCreatures then
  260.                 local creatures = tile:getCreatures()
  261.                 for _, creature in pairs(creatures) do
  262.                     if creature:isPlayer() then
  263.                         _DGE.resetPlayer(creature)
  264.                     end
  265.                 end
  266.             end
  267.         end
  268.     end
  269.  
  270.     function _DGE.fill()
  271.         _DGE.clean(true)
  272.         for _, tile in pairs(config.cache.tiles) do
  273.             local tilePos = tile:getPosition()
  274.             if math.random(1, 100) <= config.gold.chestChance then
  275.                 local chest = Game.createItem(config.gold.chestId, 1, tilePos)
  276.                 if chest then
  277.                     chest:setAttribute(ITEM_ATTRIBUTE_ACTIONID, config.gold.chestAid)
  278.                 end
  279.             else
  280.                 for i = 1, 3 do
  281.                     local gold = Game.createItem(config.gold.id, math.random(10, 80), tilePos)
  282.                     if gold then
  283.                         gold:setAttribute(ITEM_ATTRIBUTE_ACTIONID, config.gold.chestAid)
  284.                     end
  285.                 end
  286.             end
  287.         end
  288.     end
  289.  
  290.     function _DGE.refill(refillInterval, count)
  291.         if count == 0 then
  292.             return
  293.         end
  294.         _DGE.showScores()
  295.         _DGE.fill()
  296.         config.cache.eventIds['refill'] = addEvent(_DGE.refill, refillInterval, refillInterval, count -1)
  297.     end
  298.  
  299.     function _DGE.showScores()
  300.         if #config.cache.players > 1 then
  301.             table.sort(config.cache.players, function (p1, p2) return p1.score > p2.score end)
  302.         else
  303.             _DGE.close()
  304.             return
  305.         end
  306.         local count = 0
  307.         local description = "~ Scores ~\n\n"
  308.         local playerCount = #config.cache.players
  309.         for _, p in pairs(config.cache.players) do
  310.             count = count +1
  311.             local player = Player(p.id)
  312.             if player then
  313.                 description = string.format("%s%d) %s - %d coins%s", description, _, player:getName(), p.score, (_ == playerCount and '' or '\n'))
  314.             end
  315.             if count >= 5 then
  316.                 break
  317.             end
  318.         end
  319.         _DGE.sayToPlayers(description)
  320.     end
  321.  
  322.     function _DGE.checkWaiting()
  323.         if #config.cache.players >= config.players.min then
  324.             _DGE.eventPreparing()
  325.             return
  326.         end
  327.         config.state.type = "stoped"
  328.         _DGE.eventSay("The event has been closed due to lack of participants.")
  329.         _DGE.close()
  330.     end
  331.  
  332.     function _DGE.kickPlayers()
  333.         for _, p in pairs(config.cache.players) do
  334.             local player = Player(p.id)
  335.             if player then
  336.                 _DGE.resetPlayer(player)
  337.             end
  338.         end
  339.         config.cache.players = {}
  340.     end
  341.  
  342.     function _DGE.kickPlayer(player)
  343.         local index = _DGE.isPlayerExist(player)
  344.         if not index then
  345.             return false
  346.         end
  347.         _DGE.resetPlayer(player)
  348.         table.remove(config.cache.players, index)
  349.         return true
  350.     end
  351.  
  352.     function _DGE.isPlayerExist(player)
  353.         local playerId = player:getId()
  354.         for _, p in pairs(config.cache.players) do
  355.             if playerId == p.id then
  356.                 return _
  357.             end
  358.         end
  359.         return false
  360.     end
  361.  
  362.     function _DGE.joinPlayer(player)
  363.         table.insert(config.cache.players, { id = player:getId(), score = 0, speed = player:getSpeed() })
  364.         player:setStorageValue(config.players.storage, 1)
  365.         player:getPosition():sendMagicEffect(CONST_ME_POFF)
  366.         player:teleportTo(config.area.waitZone)
  367.         config.area.waitZone:sendMagicEffect(CONST_ME_TELEPORT)
  368.         if #config.cache.players >= config.players.max then
  369.             local waitingEventId = config.cache.eventIds['waiting']
  370.             if waitingEventId then
  371.                 stopEvent(waitingEventId)
  372.                 config.cache.eventIds['waiting'] = nil
  373.             end
  374.             _DGE.stopAdvertising()
  375.             _DGE.eventPreparing()
  376.         end
  377.         return true
  378.     end
  379.  
  380.     function _DGE.eventPreparing()
  381.         _DGE.fill()
  382.         local alreadyTile = {}
  383.         for _, p in pairs(config.cache.players) do
  384.             local player = Player(p.id)
  385.             if player then
  386.                 local rNumber = math.random(1, config.cache.tileCount)
  387.                 if not table.contains(alreadyTile, rNumber) then
  388.                     table.insert(alreadyTile, rNumber)
  389.                     _DGE.clean(nil, rNumber)
  390.                     player:setMovementBlocked(true)
  391.                     _DGE.changeSpeedTo(player)
  392.                     player:teleportTo(config.cache.tiles[rNumber]:getPosition())
  393.                 end
  394.             end
  395.         end
  396.         _DGE.eventSay("We are ready to start, get ready...")
  397.         config.state.type = "preparing"
  398.         config.cache.eventIds['counterStart'] = addEvent(_DGE.counterStart, 1000, 5)
  399.     end
  400.  
  401.     function _DGE.sendNumber(player, number, color)
  402.         player:sendTextMessage(MESSAGE_EXPERIENCE_OTHERS, text, player:getPosition(), number, color, 0, TEXTCOLOR_NONE)
  403.     end
  404.  
  405.     function _DGE.addScore(player, count)
  406.         local index = _DGE.isPlayerExist(player)
  407.         if index then
  408.             config.cache.players[index].score = config.cache.players[index].score +count
  409.             return true
  410.         end
  411.         return false
  412.     end
  413.  
  414.     function _DGE.counterStart(seconds)
  415.         local started = seconds == 0
  416.         for _, p in pairs(config.cache.players) do
  417.             local player = Player(p.id)
  418.             if player then
  419.                 if started then
  420.                     player:setMovementBlocked(false)
  421.                     player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Gogogogog!")
  422.                 else
  423.                     _DGE.sendNumber(player, seconds, TEXTCOLOR_RED)
  424.                 end
  425.             end
  426.         end
  427.         if not started then
  428.             config.cache.eventIds['counterStart'] = addEvent(_DGE.counterStart, 1000, seconds -1)
  429.         else
  430.             _DGE.checkSpeedPlayers()
  431.             config.state.type = "started"
  432.             local s, m ,h = getTime(config.start.ending)
  433.             local tseconds = s+(m*60)+(h*60*60)
  434.             config.cache.eventIds['ending'] = addEvent(_DGE.finish, tseconds * 1000)
  435.             local refillInterval = math.ceil(tseconds/3) * 1000
  436.             config.cache.eventIds['refill'] = addEvent(_DGE.refill, refillInterval, refillInterval, 2)
  437.         end
  438.     end
  439.  
  440.     function _DGE.stopAdvertising()
  441.         local s, m ,h = getTime(config.start.waiting)
  442.         local tseconds = s+(m*60)+(h*60*60)
  443.         local advertisings = math.floor(tseconds / 60)
  444.         if advertisings > 0 then
  445.             for i = 1, advertisings do
  446.                 stopEvent(config.cache.eventIds['advertisings'..i])
  447.             end
  448.         end
  449.     end
  450.  
  451.     function _DGE.init()
  452.         if config.cache.tileCount == 0 then
  453.             loadTiles()
  454.             if config.state.debug then
  455.                 _DGE.debug(string.format("loaded %d tiles.", config.cache.tileCount))
  456.             end
  457.         end
  458.         _DGE.clean()
  459.         local s, m ,h = getTime(config.start.waiting)
  460.         local tseconds = s+(m*60)+(h*60*60)
  461.         _DGE.eventSay(string.format("The event will start in %s, use the command %s to enter.", formatTime(tseconds), config.miscellaneous.talkaction))
  462.         config.cache.eventIds['waiting'] = addEvent(_DGE.checkWaiting, tseconds * 1000)
  463.         config.state.type = "open"
  464.         local advertisings = math.floor(tseconds / 60)
  465.         if advertisings > 0 then
  466.             for i = 1, advertisings do
  467.                 config.cache.eventIds['advertisings'..i] = addEvent(function (tseconds, talk)
  468.                     _DGE.eventSay(string.format("The event will start in %s, use the command %s to enter.", formatTime(tseconds), talk))
  469.                 end, (30 * 1000)*i, tseconds-30, config.miscellaneous.talkaction)
  470.             end
  471.         end
  472.         return true
  473.     end
  474.  
  475.     function _DGE.close()
  476.         for _, eventId in pairs(config.cache.eventIds) do
  477.             stopEvent(eventId)
  478.         end
  479.         config.cache.eventIds = {}
  480.         _DGE.kickPlayers()
  481.         config.state.type = "close"
  482.     end
  483.  
  484.     local global = GlobalEvent("DreamOfGold")
  485.     global.onTime = _DGE.init
  486.     global:time(config.start.time)
  487.     global:register()
  488.  
  489.     local talk = TalkAction(config.miscellaneous.talkaction)
  490.     function talk.onSay(player, words, param)
  491.         if player:getGroup():getAccess() then
  492.             if param == "open" then
  493.                 if table.contains({'open', 'started', 'preparing'}, config.state.type) then
  494.                     player:sendCancelMessage("The event is now open.")
  495.                 else
  496.                     _DGE.init()
  497.                 end
  498.                 return false
  499.             elseif param == "close" then
  500.                 if table.contains({'closing', 'stoped'}, config.state.type) then
  501.                     player:sendCancelMessage("The event is already closed.")
  502.                 else
  503.                     _DGE.close()
  504.                 end
  505.                 return false
  506.             end
  507.         end
  508.         if table.contains({'back', 'exit'}, param:lower()) then
  509.             if table.contains({'started', 'preparing'}, config.state.type) then
  510.                 player:sendCancelMessage("Sorry, the event has already started.")
  511.                 return false
  512.             end
  513.             if not _DGE.kickPlayer(player) then
  514.                 player:sendCancelMessage("Sorry, but you are not at the event.")
  515.             else
  516.                 player:sendCancelMessage("You have left the event.")
  517.             end
  518.             return false
  519.         end
  520.         if _DGE.isPlayerExist(player) then
  521.             player:sendCancelMessage("Sorry, you're already inside the event.")
  522.             return false
  523.         end
  524.         if config.state.type == "open" then
  525.             if not _DGE.joinPlayer(player) then
  526.                 player:sendCancelMessage("Sorry, there are no more spaces.")
  527.             end
  528.         elseif table.contains({'closing', 'stoped'}, config.state.type) then
  529.             player:sendCancelMessage("Sorry, but the event is closed.")
  530.         else
  531.             player:sendCancelMessage("Sorry, but the event is running.")
  532.         end
  533.         return false
  534.     end
  535.  
  536.     talk:separator(" ")
  537.     talk:register()
  538.  
  539.     local cEvent = CreatureEvent("DreamOfGold")
  540.     function cEvent.onLogin(player)
  541.         if player:getStorageValue(config.players.storage) == 1 then
  542.             _DGE.resetPlayer(player)
  543.         end
  544.         return true
  545.     end
  546.     cEvent:register()
  547.  
  548.     local cEvent = CreatureEvent("DreamOfGoldLogout")
  549.     function cEvent.onLogout(player)
  550.         if player:getStorageValue(config.players.storage) == 1 then
  551.             player:sendCancelMessage("You cannot logout, because you are at the event.")
  552.             return false
  553.         end
  554.         return true
  555.     end
  556.     cEvent:register()
  557.  
  558.     local move = MoveEvent("DreamOfGold")
  559.     function move.onStepIn(creature, ground, position, fromPosition)
  560.         local player = creature:getPlayer()
  561.         if not player then
  562.             return true
  563.         end
  564.         local tile = config.cache.tiles[ground:getCustomAttribute('tileIndex')]
  565.         if not tile then
  566.             return true
  567.         end
  568.         local playerId = player:getId()
  569.         local items = tile:getItems()
  570.         for _, item in pairs(items) do
  571.             if item:getId() == config.gold.id then
  572.                 local count = player:getSpeed() > config.players.speed and item:getCount()/2 or item:getCount()
  573.                 if _DGE.addScore(player, count) then
  574.                     _DGE.sendNumber(player, count, TEXTCOLOR_YELLOW)
  575.                     item:remove()
  576.                 end
  577.                 break
  578.             end
  579.         end
  580.         return true
  581.     end
  582.     move:aid(config.gold.aid)
  583.     move:register()
  584.  
  585.     local action = Action()
  586.     function action.onUse(player, item, fromPos, target, toPos, isHotkey)
  587.         if item:getId() == config.gold.chestId then
  588.             local count = math.random(config.gold.chestValues[1], config.gold.chestValues[2])
  589.             count = player:getSpeed() > config.players.speed and count/2 or count
  590.             if _DGE.addScore(player, count) then
  591.                 _DGE.sendNumber(player, count, TEXTCOLOR_YELLOW)
  592.                 item:remove()
  593.             end
  594.         end
  595.         return true
  596.     end
  597.     action:aid(config.gold.chestAid)
  598.     action:register()
  599.  
  600.     local ec = EventCallback
  601.     function ec.onMoveCreature(player, creature, fromPosition, toPosition)
  602.         if not player:getGroup():getAccess() then
  603.             if not config.miscellaneous.canPushPlayers then
  604.                 if player:getStorageValue(config.players.storage) == 1 then
  605.                     player:sendCancelMessage("It is not allowed to move players in the event.")
  606.                     return false
  607.                 end
  608.             end
  609.         end
  610.         return true
  611.     end
  612.     ec:register(-1)
  613.  
  614.     local ec = EventCallback
  615.     function ec.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
  616.         if not player:getGroup():getAccess() then
  617.             if toPosition.x ~= CONTAINER_POSITION or fromPosition.x ~= CONTAINER_POSITION then
  618.                 if player:getStorageValue(config.players.storage) == 1 then
  619.                     player:sendCancelMessage("It is not allowed to move items in the event.")
  620.                     return false
  621.                 end
  622.             end
  623.         end
  624.         return true
  625.     end
  626.     ec:register(-1)
  627. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement