• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Delay to this script... How i add?:$

Xeikh

詠春 ☯
Joined
Oct 23, 2009
Messages
724
Reaction score
17
Hello, im using this script to make a teleport... but i would like to add a delay of 30 minutes.

Can please someone tell me what to add?:$
 
Last edited:
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!
 
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!

Why not use 'if not exhaustion.get(cid, storage) then xx else doPlayerSendCancel(cid, 'You are exhausted')' :p.
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
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
 
both ways will perform the same action, the difference is that one is configured more than another xP! remeber he want 30 minutes of delay :p
 
Ok im going to test it. Thanks guys! :D

Edit:

The delay dont works u_______u

Edit 2:

Sorry Bogart, your script dont works:$

Thanks Acubens, yours did work xD
 
Back
Top