local config, tps, others = {
level = 1, -- level to use
seconds = 5, -- how long it lasts
createInPZ = false, -- true/false
oneTeleport = true, -- true/false
destination = 'Cronus City' -- town name or other position.
}, {}, {430} -- {430} = items that you can add to block TP from creating (e.g. {430, 2160})
local function remove(pos, guid)
if config.oneTeleport then
for i = 1, #tps do
if tps[i] == guid then
table.remove(tps, i)
break
end
end
end
local item = getTileItemById(pos, 1387).uid
return item > 0 and doRemoveItem(item) and doSendMagicEffect(pos, 34)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local thing = getTopCreature(toPosition)
if getPlayerStorageValue(cid,63336) < os.time() then
if getPlayerLevel(cid) >= config.level then
local guid = getPlayerGUID(cid)
if not config.oneTeleport or not isInArray(tps, guid) then
toPosition.stackpos = 0
if not isPlayer(thing.uid) and not isMonster(thing.uid) and not isNpc(thing.uid) and not isCreature(thing.uid) and not isInArray({0, 65535}, toPosition.x) and not isInArray(others, itemEx.itemid) and (config.createInPZ or not getTileInfo(toPosition).protection) and not hasItemProperty(getTileThingByPos(toPosition).uid, CONST_PROP_MOVABLE) and not hasItemProperty(getTileThingByPos(toPosition).uid, CONST_PROP_BLOCKSOLID) and queryTileAddThing(cid, toPosition) == RETURNVALUE_NOERROR and getTileItemByType(toPosition, ITEM_TYPE_TELEPORT).uid == 0 then
if not hasCondition(cid, CONDITION_INFIGHT) then
doCreateTeleport(1387, type(config.destination) == 'table' and config.destination or getTownTemplePosition(getTownId(config.destination)), toPosition)
setPlayerStorageValue(cid,63336,os.time()+1800)
if config.oneTeleport then
table.insert(tps, guid)
end
addEvent(remove, config.seconds * 1000, toPosition, guid)
doCreatureSay(cid, "Teleport created!", TALKTYPE_MONSTER, nil, nil, toPosition)
doSendMagicEffect(toPosition, 34)
else
doCreatureSay(cid, "You cannot create a teleport while in battle.", TALKTYPE_MONSTER)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doCreatureSay(cid, "You cannot create a teleport here.", TALKTYPE_MONSTER)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doCreatureSay(cid, "You already have an active teleport.", TALKTYPE_MONSTER)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doCreatureSay(cid, "You must be at least level (" .. config.level .. ") to use this.", TALKTYPE_MONSTER)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doCreatureSay(cid, "You need wait 30 minutes to use this item again!", TALKTYPE_MONSTER)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
return true
end
LUA:local config, tps, others = { level = 1, -- level to use seconds = 5, -- how long it lasts createInPZ = false, -- true/false oneTeleport = true, -- true/false destination = 'Cronus City' -- town name or other position. }, {}, {430} -- {430} = items that you can add to block TP from creating (e.g. {430, 2160}) local function remove(pos, guid) if config.oneTeleport then for i = 1, #tps do if tps[i] == guid then table.remove(tps, i) break end end end local item = getTileItemById(pos, 1387).uid return item > 0 and doRemoveItem(item) and doSendMagicEffect(pos, 34) end function onUse(cid, item, fromPosition, itemEx, toPosition) local thing = getTopCreature(toPosition) if getPlayerStorageValue(cid,63336) < os.time() then if getPlayerLevel(cid) >= config.level then local guid = getPlayerGUID(cid) if not config.oneTeleport or not isInArray(tps, guid) then toPosition.stackpos = 0 if not isPlayer(thing.uid) and not isMonster(thing.uid) and not isNpc(thing.uid) and not isCreature(thing.uid) and not isInArray({0, 65535}, toPosition.x) and not isInArray(others, itemEx.itemid) and (config.createInPZ or not getTileInfo(toPosition).protection) and not hasItemProperty(getTileThingByPos(toPosition).uid, CONST_PROP_MOVABLE) and not hasItemProperty(getTileThingByPos(toPosition).uid, CONST_PROP_BLOCKSOLID) and queryTileAddThing(cid, toPosition) == RETURNVALUE_NOERROR and getTileItemByType(toPosition, ITEM_TYPE_TELEPORT).uid == 0 then if not hasCondition(cid, CONDITION_INFIGHT) then doCreateTeleport(1387, type(config.destination) == 'table' and config.destination or getTownTemplePosition(getTownId(config.destination)), toPosition) setPlayerStorageValue(cid,63336,os.time()+1800) if config.oneTeleport then table.insert(tps, guid) end addEvent(remove, config.seconds * 1000, toPosition, guid) doCreatureSay(cid, "Teleport created!", TALKTYPE_MONSTER, nil, nil, toPosition) doSendMagicEffect(toPosition, 34) else doCreatureSay(cid, "You cannot create a teleport while in battle.", TALKTYPE_MONSTER) doSendMagicEffect(toPosition, CONST_ME_POFF) end else doCreatureSay(cid, "You cannot create a teleport here.", TALKTYPE_MONSTER) doSendMagicEffect(toPosition, CONST_ME_POFF) end else doCreatureSay(cid, "You already have an active teleport.", TALKTYPE_MONSTER) doSendMagicEffect(toPosition, CONST_ME_POFF) end else doCreatureSay(cid, "You must be at least level (" .. config.level .. ") to use this.", TALKTYPE_MONSTER) doSendMagicEffect(toPosition, CONST_ME_POFF) end else doCreatureSay(cid, "You need wait 30 minutes to use this item again!", TALKTYPE_MONSTER) doSendMagicEffect(toPosition, CONST_ME_POFF) end return true end
Test it and comment!
local config, tps, others = {
level = 1, -- level to use
seconds = 5, -- how long it lasts
createInPZ = false, -- true/false
oneTeleport = true, -- true/false
destination = 'Cronus City' -- town name or other position.
}, {}, {430} -- {430} = items that you can add to block TP from creating (e.g. {430, 2160})
local function remove(pos, guid)
if config.oneTeleport then
for i = 1, #tps do
if tps[i] == guid then
table.remove(tps, i)
break
end
end
end
local item = getTileItemById(pos, 1387).uid
return item > 0 and doRemoveItem(item) and doSendMagicEffect(pos, 34)
end
local storage, timetouseitem = 1234, 30
function onUse(cid, item, fromPosition, itemEx, toPosition)
local thing = getTopCreature(toPosition)
if exhaustion.get(cid, storage) then
return doPlayerSendCancel(cid, 'You must wait '..timetouseitem..' seconds before you use it again') and false
end
if getPlayerLevel(cid) >= config.level then
local guid = getPlayerGUID(cid)
if not config.oneTeleport or not isInArray(tps, guid) then
toPosition.stackpos = 0
if not isPlayer(thing.uid) and not isMonster(thing.uid) and not isNpc(thing.uid) and not isCreature(thing.uid) and not isInArray({0, 65535}, toPosition.x) and not isInArray(others, itemEx.itemid) and (config.createInPZ or not getTileInfo(toPosition).protection) and not hasItemProperty(getTileThingByPos(toPosition).uid, CONST_PROP_MOVABLE) and not hasItemProperty(getTileThingByPos(toPosition).uid, CONST_PROP_BLOCKSOLID) and queryTileAddThing(cid, toPosition) == RETURNVALUE_NOERROR and getTileItemByType(toPosition, ITEM_TYPE_TELEPORT).uid == 0 then
if not hasCondition(cid, CONDITION_INFIGHT) then
doCreateTeleport(1387, type(config.destination) == 'table' and config.destination or getTownTemplePosition(getTownId(config.destination)), toPosition)
if config.oneTeleport then
table.insert(tps, guid)
end
addEvent(remove, config.seconds * 1000, toPosition, guid)
doCreatureSay(cid, "Teleport created!", TALKTYPE_MONSTER, nil, nil, toPosition)
doSendMagicEffect(toPosition, 34)
exhaustion.set(cid, storage, timetouseitem)
else
doCreatureSay(cid, "You cannot create a teleport while in battle.", TALKTYPE_MONSTER)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doCreatureSay(cid, "You cannot create a teleport here.", TALKTYPE_MONSTER)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doCreatureSay(cid, "You already have an active teleport.", TALKTYPE_MONSTER)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doCreatureSay(cid, "You must be at least level (" .. config.level .. ") to use this.", TALKTYPE_MONSTER)
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
return true
end