• 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 STORAGE TELEPORT AFTER TIME

Dohko

Active Member
Joined
Mar 7, 2017
Messages
100
Reaction score
29
Hello, good evening friends, I apologize for my bad English, my problem is in my movement script,
I have tfs 1.2 on my server, and I would like to adapt my code to when the player's storage change he would be teleported to the temple, script In question ->

Lua:
function onUse(cid, item, frompos, item2, topos)

        local player = Player(cid)

    if player:getStorageValue(58344) >= os.time() then

        player:say('Voce ja tem acesso.', TALKTYPE_MONSTER_SAY)

        return true

    end

   

        player:setStorageValue(58344, os.time() + 600)

I need the player go to the temple after the storage time is up.
 
Lua:
local config = {
    storage = 58344,
    cooldown = 60,
  }

function onUse(cid, item, frompos, item2, topos)
    local player = Player(cid)
    if player:getStorageValue(config.storage) >= os.time() then
     doPlayerSendTextMessage(player, TALKTYPE_ORANGE_1, "Voce ja tem acesso.")
    addEvent(Templo, config.cooldown * 100, player:getId())
    end
    player:setStorageValue(config.storage, os.time() + config.cooldown)
return true
end

function Templo(cid)
    local player = Player(cid)
    if not player then
        return
    end
  player:teleportTo(getPlayerMasterPos(cid))
end
 
Lua:
local config = {
    storage = 58344,
    cooldown = 60,
  }

function onUse(cid, item, frompos, item2, topos)
    local player = Player(cid)
    if player:getStorageValue(config.storage) >= os.time() then
     doPlayerSendTextMessage(player, TALKTYPE_ORANGE_1, "Voce ja tem acesso.")
    addEvent(Templo, config.cooldown * 100, player:getId())
    end
    player:setStorageValue(config.storage, os.time() + config.cooldown)
return true
end

function Templo(cid)
    local player = Player(cid)
    if not player then
        return
    end
  player:teleportTo(getPlayerMasterPos(cid))
end

Hey bro, thanks for help me,
Can you explain to me exactly what you did? Because I've changed my code a bit and it's not like it was before
and can you use function ontime to callback the getstorage ? i think it's more safe.
 
Last edited:
i think is works
Lua:
local config = {
    storage = 58344,
    cooldown = 60,
  }

function onThink(cid, interval)
    local player = Player(cid)
    if player:getStorageValue(config.storage) >= os.time() then
        addEvent(Templo, config.cooldown * 100, player:getId())
        player:sendTextMessage(TALKTYPE_ORANGE_1, "Voce ja tem acesso.")

    end

 return true
end

function Templo(cid)
    local player = Player(cid)
    if not player then
        return
    end
  player:teleportTo(getPlayerMasterPos(cid))

end
login.lua
Lua:
player:registerEvent("Godp")
 
Last edited:
i think is works
Lua:
local config = {
    storage = 58344,
    cooldown = 60,
  }

function onThink(cid, interval)
    local player = Player(cid)
    if player:getStorageValue(config.storage) >= os.time() then
        addEvent(Templo, config.cooldown * 100, player:getId())
        doPlayerSendTextMessage(player, TALKTYPE_ORANGE_1, "Voce ja tem acesso.")

    end

 return true
end

function Templo(cid)
    local player = Player(cid)
    if not player then
        return
    end
  player:teleportTo(getPlayerMasterPos(cid))

end
login.lua
Lua:
player:registerEvent("Godp")

hey man, thanks for help me, i change my code and adptate by your tips,
my new code

Lua:
local config = {
toKnow = 123456,
storage = 789456,
cooldown = 6,
pos = {x = 159, y = 49, z = 7}, -- para onde o jogador será teleportado caso o tempo tenha acabado.
}

function onThink(cid, interval)
    if getPlayerStorageValue (cid, config.toKnow) == 1 then
     
    local player = Player(cid)
    print(1)
    if getPlayerStorageValue (cid, config.storage) < os.time () then
    print(2)
    addEvent(Templo, config.cooldown * 100, player:getId())
    print(3) 
    setPlayerStorageValue (cid, config.toKnow, 0)
    doPlayerSendTextMessage (cid, 19, "Seu tempo de hunt chegou ao fim!")
    end
    end

 return true
end

function Templo(cid)
    local player = Player(cid)
    if not player then
        return
    end
    player:teleportTo(getPlayerMasterPos(cid))

end

function onKill(cid, target, lastHit)
    if getPlayerStorageValue (cid, config.toKnow) == 1 then
        if getPlayerStorageValue (cid, config.storage) < os.time () then
            doTeleportThing (cid, config.pos)
            setPlayerStorageValue (cid, config.toKnow, 0)
            doPlayerSendTextMessage (cid, 19, "Seu tempo de hunt chegou ao fim!")
        end
    end
return true
end
but i only go to temple if i kill a monster after the times end
 
but i only go to temple if i kill a monster after the times end
Change
Code:
player:teleportTo(getPlayerMasterPos(cid))
to
Code:
player:teleportTo(config.pos)
change too
Code:
doPlayerSendTextMessage(player, TALKTYPE_ORANGE_1, "Voce ja tem acesso.")
to
Code:
 player:sendTextMessage(TALKTYPE_ORANGE_1, "Voce ja tem acesso.")
 
Last edited:
Nothing happened :(
I enter in the script area, wait for the times end, and doesn't work,
i only teleport when i call the function onKill, please,
Please make an onThink function work with the same onKill commands, which is working perfectly.
thanks for help bro's <3
 
Nothing happened :(
I enter in the script area, wait for the times end, and doesn't work,
i only teleport when i call the function onKill, please,
Please make an onThink function work with the same onKill commands, which is working perfectly.
thanks for help bro's <3
which way the player get storage?
 
Back
Top