Lbtg
Intermediate OT User
- Joined
- Nov 22, 2008
- Messages
- 2,324
- Reaction score
- 136
Hello, we making this carpet system and little bit failing, could someone look up at this and can help solve it
carpetTPplayer.lua
carpetLIB.lua
carpetCreate.lua
trying to add videos, but can't..
The problem is the carpet is glitching with player. Its not flying together nicely...
carpetTPplayer.lua
Lua:
function onThink(cid, interval, lastExecution)
for i = 0, CARPET_QUEST.carpet.sqms - 1 do
local _teleported = false
local position = CARPET_QUEST.carpet.startPosition
local pos = Position(position.x + i, position.y, position.z)
local tile = Tile(pos)
if tile then
local ground = tile:getItemById(CARPET_QUEST.carpet.ItemID)
if ground then
local topCreature = tile:getTopCreature()
if topCreature and topCreature:isPlayer() then
if not _teleported then
if ground:getAttribute(ITEM_ATTRIBUTE_ACTIONID) == CARPET_QUEST.carpet.ActionID then
if i == CARPET_QUEST.carpet.sqms - 1 then
local position = Position(topCreature:getPosition().x + 2, topCreature:getPosition().y, topCreature:getPosition().z)
_teleported = true
addEvent(function()
topCreature:teleportTo(position)
topCreature:getPosition():sendMagicEffect(15)
end, 650)
else
local position = Position(topCreature:getPosition().x + 1, topCreature:getPosition().y, topCreature:getPosition().z)
_teleported = true
addEvent(function()
topCreature:teleportTo(position)
end, 650)
end
end
end
end
end
end
end
for i = 0, CARPET_QUEST.carpet.sqms - 1 do
local _teleported = false
local position = Position(CARPET_QUEST.carpet.startPosition.x + CARPET_QUEST.carpet.sqms, CARPET_QUEST.carpet.startPosition.y, CARPET_QUEST.carpet.startPosition.z)
local pos = Position(position.x - i, position.y, position.z)
local tile = Tile(pos)
if tile then
local ground = tile:getItemById(CARPET_QUEST.carpet.ItemID)
if ground then
local topCreature = tile:getTopCreature()
if topCreature and topCreature:isPlayer() then
if not _teleported then
if ground:getAttribute(ITEM_ATTRIBUTE_ACTIONID) == CARPET_QUEST.carpet.ActionID + 1 then
if i == CARPET_QUEST.carpet.sqms - 1 then
local position = Position(topCreature:getPosition().x - 2, topCreature:getPosition().y, topCreature:getPosition().z)
_teleported = true
addEvent(function()
topCreature:teleportTo(position)
topCreature:getPosition():sendMagicEffect(15)
end, 650)
else
local position = Position(topCreature:getPosition().x - 1, topCreature:getPosition().y, topCreature:getPosition().z)
_teleported = true
addEvent(function()
topCreature:teleportTo(position)
end, 650)
end
end
end
end
end
end
end
return true
end
carpetLIB.lua
Lua:
CARPET_QUEST = {
carpet = { startPosition = Position(33177, 31548, 15),
sqms = 23,
delay = 800,
ItemID = 13661,
ActionID = 8575,
}
}
CARPET_QUEST_FIRST_RUN = true
CARPET_QUEST_BEGIN = true
CARPET_QUEST_START = true
CARPET_QUEST_CURRENT_POSITION = nil
CARPET_QUEST_TELEPORT = nil
CARPET_QUEST_DELAY = 0
carpetCreate.lua
Lua:
function onThink(cid, interval, lastExecution)
if CARPET_QUEST_BEGIN and CARPET_QUEST_START then
if not CARPET_QUEST_TELEPORT then
CARPET_QUEST_TELEPORT = Game.createItem(CARPET_QUEST.carpet.ItemID, 1, CARPET_QUEST.carpet.startPosition)
CARPET_QUEST_TELEPORT:setAttribute(ITEM_ATTRIBUTE_ACTIONID, CARPET_QUEST.carpet.ActionID)
end
CARPET_QUEST_START = false
for i = 1, CARPET_QUEST.carpet.sqms do
local pos = Position(CARPET_QUEST.carpet.startPosition.x + i, CARPET_QUEST.carpet.startPosition.y, CARPET_QUEST.carpet.startPosition.z)
if i == 1 then
CARPET_QUEST_DELAY = 0
else
CARPET_QUEST_DELAY = CARPET_QUEST_DELAY + CARPET_QUEST.carpet.delay
end
addEvent(function()
CARPET_QUEST_TELEPORT:remove()
CARPET_QUEST_TELEPORT = Game.createItem(CARPET_QUEST.carpet.ItemID, 1, pos)
CARPET_QUEST_TELEPORT:setAttribute(ITEM_ATTRIBUTE_ACTIONID, CARPET_QUEST.carpet.ActionID)
if i == CARPET_QUEST.carpet.sqms then
CARPET_QUEST_BEGIN = false
CARPET_QUEST_START = true
currentPosition = pos
CARPET_QUEST_TELEPORT:setAttribute(ITEM_ATTRIBUTE_ACTIONID, CARPET_QUEST.carpet.ActionID + 1)
end
end, CARPET_QUEST_DELAY)
end
end
if not CARPET_QUEST_BEGIN and CARPET_QUEST_START then
CARPET_QUEST_START = false
for i = 1, CARPET_QUEST.carpet.sqms do
local pos = Position(currentPosition.x - i, currentPosition.y, currentPosition.z)
if i == 1 then
CARPET_QUEST_DELAY = 0
else
CARPET_QUEST_DELAY = CARPET_QUEST_DELAY + CARPET_QUEST.carpet.delay
end
addEvent(function()
CARPET_QUEST_TELEPORT:remove()
CARPET_QUEST_TELEPORT = Game.createItem(CARPET_QUEST.carpet.ItemID, 1, pos)
CARPET_QUEST_TELEPORT:setAttribute(ITEM_ATTRIBUTE_ACTIONID, CARPET_QUEST.carpet.ActionID + 1)
if i == CARPET_QUEST.carpet.sqms then
CARPET_QUEST_BEGIN = true
CARPET_QUEST_START = true
_isFirstRun = false
CARPET_QUEST_TELEPORT:setAttribute(ITEM_ATTRIBUTE_ACTIONID, CARPET_QUEST.carpet.ActionID)
end
end, CARPET_QUEST_DELAY)
end
end
return true
end
Post automatically merged:
trying to add videos, but can't..
The problem is the carpet is glitching with player. Its not flying together nicely...
Last edited: