• 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!

Lua [movement][help] telepor every 24 hours

Crixpx

New Member
Joined
Jan 11, 2015
Messages
70
Reaction score
3
hola!! I would like to know if anyone can edit this script for me :D
Is a war zone script But what I want is that it can only be used every 24 hours My idea is to make an area where you can only enter every 24 hours for vip players :D this is my base script

I'm using OTX 3 for 10.90 ot server

Code:
local destinations = {
    [3140] = {teleportPosition = Position(32996, 31922, 10), storage = 955, value = 1},
    [3141] = {teleportPosition = Position(33011, 31943, 11), storage = 956, value = 2},
    [3142] = {teleportPosition = Position(32989, 31909, 12), storage = 957, value = 3},
}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local destination = destinations[item.uid]
    if not destination then
        return true
    end

    if player:getStorageValue(destination.storage) ~= destination.value then
        player:teleportTo(fromPosition)
        return true
    end

    player:teleportTo(destination.teleportPosition)
    destination.teleportPosition:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

I hope someone can help me u.u thanks
 
Solution
Code:
local destinations = {
    [3140] = {teleportPosition = Position(32996, 31922, 10), storage = 955, value = 1},
    [3141] = {teleportPosition = Position(33011, 31943, 11), storage = 956, value = 2},
    [3142] = {teleportPosition = Position(32989, 31909, 12), storage = 957, value = 3},
}

local key = 80050

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local destination = destinations[item.uid]
    if not destination then
        return true
    end

        --// If player still has exhaustion, push them back
    if player:getExhaustion(key) > 0 then
        player:teleportTo(fromPosition, true)...
I'd use a timed storage value.
in 0.3.7, I'd do it like this.

Code:
local exhaust_timer = 24 * 60 * 60 -- h*m*s
local storage = 11111

local _t = os.time()
if _t > getPlayerStorageValue(cid, storage) then
    setPlayerStorageValue(cid, storage, _t + exhaust_timer)
else
    return false
end
-- rest of script

Basically, os.time() grabs a large ass number, which is your computers current time.
Let's pretend it's "113060100"

Now we have the exhaust timer of 24*60*60 which is 86400.

so we just use a storage value, and add/check these values against each other.

Player current storage value = -1.

Code:
if 113060100 > -1 then
    setPlayerStorageValue(cid, storage, 113060100 + 86400) (which is 113146500)
else
    return false
end
So when it checks again, it will check the new player value, against the current time.
When the current time is Greater then "time + 24h", it will allow the player to pass again, and update his storage to "time+24h" again.

:D
 
Code:
local destinations = {
    [3140] = {teleportPosition = Position(32996, 31922, 10), storage = 955, value = 1},
    [3141] = {teleportPosition = Position(33011, 31943, 11), storage = 956, value = 2},
    [3142] = {teleportPosition = Position(32989, 31909, 12), storage = 957, value = 3},
}

local key = 80050

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local destination = destinations[item.uid]
    if not destination then
        return true
    end

        --// If player still has exhaustion, push them back
    if player:getExhaustion(key) > 0 then
        player:teleportTo(fromPosition, true)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'You cannot enter this zone yet.')
        return true
    end

    if player:getStorageValue(destination.storage) ~= destination.value then
        player:teleportTo(fromPosition)
        return true
    end

    player:teleportTo(destination.teleportPosition)
    destination.teleportPosition:sendMagicEffect(CONST_ME_TELEPORT)
    player:setExhaustion(key, (24*60*60))
    return true
end

put this in your lib
https://otland.net/threads/player-setexhaustion-player-getexhaustion-tfs-1-0.224233/
 
Solution
Back
Top