Lucas Durais
New Member
- Joined
- Jan 13, 2017
- Messages
- 40
- Reaction score
- 1
Hello guys
My problem is: I'm using a full carpet that transforms into a small carpet and starts an event.
In 10 seconds, it will transform to the original full carpet. But if you step in one tile, it will transform the item I used to the original id before the event.
That way, if another player uses the full carpet after the first player and before the event starts, he will not be able to step on the tile before the event transforms the small carpet to the full carpet.
I need to stop the event from happening as soon as the player steps on the tile.
My stepIn script is like this:
And the onUse script like this:
My problem is: I'm using a full carpet that transforms into a small carpet and starts an event.
In 10 seconds, it will transform to the original full carpet. But if you step in one tile, it will transform the item I used to the original id before the event.
That way, if another player uses the full carpet after the first player and before the event starts, he will not be able to step on the tile before the event transforms the small carpet to the full carpet.
I need to stop the event from happening as soon as the player steps on the tile.
My stepIn script is like this:
Code:
local carpetPosition = Position(32953, 31466, 6)
function onStepIn(player, item, position, fromPosition)
if not player then
return true
end
if item.itemid == 9625 then
if Tile(carpetPosition):getItemById(9622) then
return true
end
elseif Tile(carpetPosition):getItemById(9623) and Tile({ x=32953, y=31465, z=6}):getItemById(9625) then
player:teleportTo(Position(32953, 31465, 7))
Tile({ x=32953, y=31465, z=6}):getItemById(9625):transform(9624)
Tile({ x=32953, y=31466, z=6}):getItemById(9623):transform(9622)
end
return true
end
And the onUse script like this:
Code:
local carpetPosition = Position(32953, 31466, 6)
local trapPosition = Position(32953, 31465, 6)
local function transformCarpet()
local teleportcarpet = Tile(carpetPosition):getItemById(9623)
if not teleportcarpet then
return
end
teleportcarpet:transform(9622)
teleportcarpet:setUniqueId(61001)
end
local function transformTrap()
local teleporttrap = Tile(trapPosition):getItemById(9625)
teleporttrap:transform(9624)
teleporttrap:setUniqueId(61000)
end
local function chargingText(cid, text, position)
local player = Player(cid)
player:say(text, TALKTYPE_MONSTER_SAY, false, player, position)
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.uid == 61000 then
if item.itemid == 9624 then
local trapClosed = Tile({ x=32953, y=31465, z=6}):getItemById(9624)
if trapClosed then
trapClosed:transform(9625)
addEvent(chargingText, (1) * 1, player.uid, 'Screeeeeeech', toPosition)
end
end
elseif item.uid == 61001 then
if item.itemid == 9622 then
local carpetFull = Tile({ x=32953, y=31466, z=6}):getItemById(9622)
if carpetFull then
carpetFull:transform(9623)
addEvent(transformTrap, 1 * 10 * 999)
addEvent(transformCarpet, 1 * 10 * 1000)
end
end
end
return true
end