bpm91
Intermediate OT User
- Joined
- May 23, 2019
- Messages
- 882
- Solutions
- 7
- Reaction score
- 123
- Location
- Brazil
- YouTube
- caruniawikibr
hello I'm trying to make the teleport be created, and that after 4 minutes after pulling the first lever they all return to the initial starting point and the teleport disappears but when I pull they don't create the teleport and don't go back to normal
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local leverOn = 1945 -- id da alavanca on (qnd o player da o 1 use)
local leverOf = 1946 -- id da alavanca off
local config = {
[1] = {x = 33320, y = 32682, z = 14}, -- [actionid] = posição da alavanca
[2] = {x = 33349, y = 32680, z = 14}, -- posição da alavanca
[3] = {x = 33358, y = 32701, z = 14}, -- posição da alavanca
[4] = {x = 33338, y = 32702, z = 14}, -- posição da alavanca
[5] = {x = 33305, y = 32734, z = 14}, -- posição da alavanca
[6] = {x = 33357, y = 32749, z = 14}, -- posição da alavanca
[7] = {x = 33368, y = 32763, z = 14}, -- posição da alavanca
[8] = {x = 33382, y = 32786, z = 14}, -- posição da alavanca
}
local time = 4 -- 4 minutos
local teleportId = 1387 -- id do tp
local tpPos = {x = 33399, y = 32802, z = 14} -- pos do tp
local toTpPos = {x = 33367, y = 32805, z = 14} -- pos que o tp vai levar
if (item:getId() == 1945) then
item:transform(1946)
elseif (item:getId() == 1946) then
item:transform(1945)
end
local lever1 = Tile({x = config[1].x, y = config[1].y, z = config[1].z}):getItemById(leverOn)
local lever2 = Tile({x = config[2].x, y = config[2].y, z = config[2].z}):getItemById(leverOn)
local lever3 = Tile({x = config[3].x, y = config[3].y, z = config[3].z}):getItemById(leverOn)
local lever4 = Tile({x = config[4].x, y = config[4].y, z = config[4].z}):getItemById(leverOn)
local lever5 = Tile({x = config[5].x, y = config[5].y, z = config[5].z}):getItemById(leverOn)
local lever6 = Tile({x = config[6].x, y = config[6].y, z = config[6].z}):getItemById(leverOn)
local lever7 = Tile({x = config[7].x, y = config[7].y, z = config[7].z}):getItemById(leverOn)
local lever8 = Tile({x = config[8].x, y = config[8].y, z = config[8].z}):getItemById(leverOn)
if (lever1 and lever2 and lever3 and lever4 and lever5 and lever6 and lever7 and lever8) then
local item2 = Game.createItem(teleportId, 1,cpPos)
if item2:isTeleport() then
item2:setDestination(toTpPos)
end
return true
end
addEvent(function ()
if (not lever1 or not lever2 or not lever3 or not lever4 or not lever5 or not lever6 or not lever7 or not lever8) then
lever1:transform(leverOf)
lever2:transform(leverOf)
lever3:transform(leverOf)
lever4:transform(leverOf)
lever5:transform(leverOf)
lever6:transform(leverOf)
lever7:transform(leverOf)
lever8:transform(leverOf)
end
end, time * 1000 * 60 * 60 )
return true
end