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

RevScripts killuaCaveOwners/no back temple

Gaber Zen

Well-Known Member
Joined
Apr 22, 2023
Messages
222
Reaction score
51
Location
Egypt
Hello, how are everyone, I am facing a problem that I do not know how to solve. When the person runs out of time from using the card, he does not leave the room after the specified period of 6 hours
function restTempo(storage)-- By Zefz
local segundos, minutos, horas = 0,0,0
local tot = storage - os.time()
horas = math.floor(tot/3600)
tot = tot - horas * 3600
minutos = math.floor(tot/60)
tot = tot - minutos * 60
segundos = tot
return string.format("Você jل usou este item e precisa esperar %.2d:%.2d:%.2d para usar novamente.", horas, minutos, segundos)
end


local storages = {

722340,
722341,
722342,
722343,
722344,
722345,
722346,
722347,
722348,
722349,
722363,
722364,
722365,
722366,
722367,
722368,
722369,
722370,
722371,
722372

}

local stg = 722340

local function hasCave(cid)
local storages = {722340,722341,722342,722343,722344,722345,722346,722347,722348,722349,722363,722364,722365,722366,722367,722368,722369,722370,722371,722372}

for a,b in pairs(storages) do
sto = getGlobalTableStorage(b)
if sto.guid and sto.guid == getCreatureName(cid) then
if tonumber(sto.time) > os.time() then
return a
end
end
end
return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

if hasCave(cid) then
return doPlayerSendCancel(cid,"Você jل é o dono da cave "..hasCave(cid).." e nمo pode alugar outra até o aluguel dela acabar.")
end
if getPlayerStorageValue(cid, stg) < os.time() then
setPlayerStorageValue(cid, stg, os.time() + (24*3600))
local check, cave = false, 0
for i = 1, #storages do
sto = getGlobalTableStorage(storages)
if not sto.time then
setGlobalTableStorage(storages,{guid = getCreatureName(cid), time = os.time() + (6*3600)})
doRemoveItem(item.uid,1)
doSendMagicEffect(getThingPos(cid), 12)
cave = i
check = true
break;
end
if sto.time and tonumber(sto.time) > 0 then
if tonumber(sto.time) < os.time() then
setGlobalTableStorage(storages,{guid = getCreatureName(cid), time = os.time() + (6*3600)})
doRemoveItem(item.uid,1)
doSendMagicEffect(getThingPos(cid), 12)
cave = i
check = true
break;
end
end
end

if check then
doSaveServer()
doPlayerSendTextMessage(cid,25,"Você acabou de alugar a cave "..cave.." por 6 horas. Aproveite!")
else
doPlayerSendCancel(cid,"Todas as caves jل estمo alugadas no momento... Tente novamente mais tarde.")
end
else
doPlayerSendTextMessage(cid,25, restTempo(getPlayerStorageValue(cid, stg)))
end
return true
end

 
Lua:
function restTempo(storage)
    local segundos, minutos, horas = 0, 0, 0
    local tot = storage - os.time()
    horas = math.floor(tot / 3600)
    tot = tot - horas * 3600
    minutos = math.floor(tot / 60)
    tot = tot - minutos * 60
    segundos = tot
    return string.format("Você já usou este item e precisa esperar %.2d:%.2d:%.2d para usar novamente.", horas, minutos, segundos)
end

local storages = {
    722340,
    722341,
    722342,
    722343,
    722344,
    722345,
    722346,
    722347,
    722348,
    722349,
    722363,
    722364,
    722365,
    722366,
    722367,
    722368,
    722369,
    722370,
    722371,
    722372
}

local stg = 722340

function hasCave(cid)
    for _, storage in ipairs(storages) do
        local sto = getGlobalStorageValue(storage)
        if type(sto) == "table" and sto.guid and sto.guid == getCreatureName(cid) then
            if tonumber(sto.time) > os.time() then
                return true
            end
        end
    end
    return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if hasCave(cid) then
       doCreatureSay(cid, "Você já é o dono de uma caverna e não pode alugar outra até o término do aluguel atual.", TALKTYPE_ORANGE_1)

    end

    if getPlayerStorageValue(cid, stg) < os.time() then
        setPlayerStorageValue(cid, stg, os.time() + (24 * 3600))
        local check, cave = false, 0

        for i, storage in ipairs(storages) do
            local sto = getGlobalStorageValue(storage)
            if type(sto) ~= "table" or not sto.time then
                setGlobalStorageValue(storage, { guid = getCreatureName(cid), time = os.time() + (6 * 3600) })
                doRemoveItem(item.uid, 1)
                doSendMagicEffect(getThingPos(cid), 12)
                cave = i
                check = true
                break
            elseif sto.time and tonumber(sto.time) < os.time() then
                setGlobalStorageValue(storage, { guid = getCreatureName(cid), time = os.time() + (6 * 3600) })
                doRemoveItem(item.uid, 1)
                doSendMagicEffect(getThingPos(cid), 12)
                cave = i
                check = true
                break
            end
        end

        if check then
            -- doPlayerSave(cid) -- Linha removida
            doCreatureSay(cid, "Você acabou de alugar a caverna " .. cave .. " por 6 horas. Aproveite!", TALKTYPE_ORANGE_1)
        else
            doPlayerSendCancel(cid, "Todas as cavernas já estão alugadas no momento. Tente novamente mais tarde.")
        end
    else
               local remainingTime = getPlayerStorageValue(cid, stg) - os.time()
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, restTempo(remainingTime))
    end
end

I changed the "Game.broadcastMessage" function for another one, see if it worked

how did you put it in a storage teleport? so show me the complete "cave" teleort script
 
code is working but player no enter in cave no sit name<
i cant enter in cave
so could you share the script for this cave? for me to test or even the script I sent?
Post automatically merged:

Lua:
function restTempo(storage)
    local segundos, minutos, horas = 0, 0, 0
    local tot = storage - os.time()
    horas = math.floor(tot / 3600)
    tot = tot - horas * 3600
    minutos = math.floor(tot / 60)
    tot = tot - minutos * 60
    segundos = tot
    return string.format("Você já usou este item e precisa esperar %.2d:%.2d:%.2d para usar novamente.", horas, minutos, segundos)
end

local storages = {
    722340,
    722341,
    722342,
    722343,
    722344,
    722345,
    722346,
    722347,
    722348,
    722349,
    722363,
    722364,
    722365,
    722366,
    722367,
    722368,
    722369,
    722370,
    722371,
    722372
}

local stg = 722340

function hasCave(cid)
    for _, storage in ipairs(storages) do
        local sto = getGlobalStorageValue(storage)
        if type(sto) == "table" and sto.guid and sto.guid == getCreatureName(cid) then
            if tonumber(sto.time) > os.time() then
                return true
            end
        end
    end
    return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if hasCave(cid) then
        doCreatureSay(cid, "Você já é o dono de uma caverna e não pode alugar outra até o término do aluguel atual.", TALKTYPE_ORANGE_1)
        return true
    end

    if getPlayerStorageValue(cid, stg) < os.time() then
        setPlayerStorageValue(cid, stg, os.time() + (24 * 3600))
        local check, cave = false, 0

        for i, storage in ipairs(storages) do
            local sto = getGlobalStorageValue(storage)
            if type(sto) ~= "table" or not sto.time then
                setGlobalStorageValue(storage, { guid = getCreatureName(cid), time = os.time() + (6 * 3600) })
                doRemoveItem(item.uid, 1)
                doSendMagicEffect(getThingPos(cid), 12)
                cave = i
                check = true
                break
            elseif sto.time and tonumber(sto.time) < os.time() then
                setGlobalStorageValue(storage, { guid = getCreatureName(cid), time = os.time() + (6 * 3600) })
                doRemoveItem(item.uid, 1)
                doSendMagicEffect(getThingPos(cid), 12)
                cave = i
                check = true
                break
            end
        end

        if check then
            doCreatureSay(cid, "Você acabou de alugar a caverna " .. cave .. " por 6 horas. Aproveite!", TALKTYPE_ORANGE_1)
        else
            doPlayerSendCancel(cid, "Todas as cavernas já estão alugadas no momento. Tente novamente mais tarde.")
        end
       
        else
    local remainingTime = getPlayerStorageValue(cid, stg) - os.time()
    local remainingText = restTempo(remainingTime)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, remainingText)
end
end

I can't understand what happened to the teleport, did you put storage in the map editor? do you have the script for the teleport when entering?
 
Last edited:
this is my code action
Lua:
function restTempo(storage)-- By Zefz
  local segundos, minutos, horas = 0,0,0
  local tot = storage - os.time()
  horas = math.floor(tot/3600)
  tot = tot - horas * 3600
  minutos = math.floor(tot/60)
  tot = tot - minutos * 60
  segundos = tot
  return string.format("Você jل usou este item e precisa esperar %.2d:%.2d:%.2d para usar novamente.", horas, minutos, segundos)
end


local storages = {
       
        722340,
        722341,
        722342,
        722343,
        722344,
        722345,
        722346,
        722347,
        722348,
        722349,
        722363,
        722364,
        722365,
        722366,
        722367,
        722368,
        722369,
        722370,
        722371,
        722372

}

local stg = 722340

local function hasCave(cid)
    local storages = {722340,722341,722342,722343,722344,722345,722346,722347,722348,722349,722363,722364,722365,722366,722367,722368,722369,722370,722371,722372}

    for a,b in pairs(storages) do
        sto = getGlobalTableStorage(b)
        if sto.guid and sto.guid == getCreatureName(cid) then
            if tonumber(sto.time) > os.time() then
                return a
            end
        end
    end
    return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if hasCave(cid) then
        return doPlayerSendCancel(cid,"Você jل é o dono da cave "..hasCave(cid).." e nمo pode alugar outra até o aluguel dela acabar.")
    end
if getPlayerStorageValue(cid, stg) < os.time() then
        setPlayerStorageValue(cid, stg, os.time() + (24*3600))
        local check, cave = false, 0
        for i = 1, #storages do
                sto = getGlobalTableStorage(storages[i])
                if not sto.time then
                        setGlobalTableStorage(storages[i],{guid = getCreatureName(cid), time = os.time() + (6*3600)})
                        doRemoveItem(item.uid,1)
                        doSendMagicEffect(getThingPos(cid), 12)
                        cave = i
                        check = true
                        break;
                end
                if sto.time and tonumber(sto.time) > 0 then
                        if tonumber(sto.time) < os.time() then
                            setGlobalTableStorage(storages[i],{guid = getCreatureName(cid), time = os.time() + (6*3600)})
                            doRemoveItem(item.uid,1)
                            doSendMagicEffect(getThingPos(cid), 12)
                            cave = i
                            check = true
                            break;
                        end
                end
        end

        if check then
                doSaveServer()
                doPlayerSendTextMessage(cid,25,"Você acabou de alugar a cave "..cave.." por 6 horas. Aproveite!")
        else
                doPlayerSendCancel(cid,"Todas as caves jل estمo alugadas no momento... Tente novamente mais tarde.")
        end
    else
        doPlayerSendTextMessage(cid,25, restTempo(getPlayerStorageValue(cid, stg)))
    end
        return true
end
talk action
Code:
local nme = "Cave Owners"

local storages = {722340,722341,722342,722343,722344,722345,722346,722347,722348,722349,722363,722364,722365,722366,722367,722368,722369,722370,722371,722372}

function onSay(cid, words, param)
    local msg = ""
    for a,b in pairs(storages) do
        sto = getGlobalTableStorage(b)
        if sto.guid and sto.time then
            local tempo = tonumber(sto.time) - os.time()
            if tempo > 0 then
                msg = msg.."[Cave "..a.."] "..gTm(cid,nme,1)..": "..sto.guid.." "..gTm(cid,nme,2).." ".. timeString((tonumber(sto.time) - os.time()), getCreatureStorage(cid,language) == "end" and true or false) .."\n"
            else
                msg = msg.."[Cave "..a.."] "..gTm(cid,nme,3)..": "..sto.guid.."\n"
            end
        else
            msg = msg.."[Cave "..a.."] "..gTm(cid,nme,4).."\n"
        end
    end
    doShowTextDialog(cid,8981,msg)
    return true
end
 

Attachments

Lua:
function restTempo(storage)
  local segundos, minutos, horas = 0, 0, 0
  local tot = storage - os.time()
  horas = math.floor(tot / 3600)
  tot = tot - horas * 3600
  minutos = math.floor(tot / 60)
  tot = tot - minutos * 60
  segundos = tot
  return string.format("Você já usou este item e precisa esperar %.2d:%.2d:%.2d para usar novamente.", horas, minutos, segundos)
end

local storages = {
  722340,
  722341,
  722342,
  722343,
  722344,
  722345,
  722346,
  722347,
  722348,
  722349,
  722363,
  722364,
  722365,
  722366,
  722367,
  722368,
  722369,
  722370,
  722371,
  722372
}

local stg = 722340

local function hasCave(cid)
  for _, storage in ipairs(storages) do
    local sto = getGlobalStorageValue(storage)
    if type(sto) == "table" and sto.guid and sto.guid == getCreatureName(cid) then
      if tonumber(sto.time) > os.time() then
        return true
      end
    end
  end
  return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
  if hasCave(cid) then
    return doPlayerSendCancel(cid, "Você já é o dono de uma caverna e não pode alugar outra até o término do aluguel atual.")
  end

  if getPlayerStorageValue(cid, stg) < os.time() then
    setPlayerStorageValue(cid, stg, os.time() + (24 * 3600))
    local check, cave = false, 0

    for i, storage in ipairs(storages) do
      local sto = getGlobalStorageValue(storage)
      if type(sto) ~= "table" or not sto.time then
        setGlobalStorageValue(storage, { guid = getCreatureName(cid), time = os.time() + (6 * 3600) })
        doRemoveItem(item.uid, 1)
        doSendMagicEffect(getThingPos(cid), 12)
        cave = i
        check = true
        break
      elseif sto.time and tonumber(sto.time) < os.time() then
        setGlobalStorageValue(storage, { guid = getCreatureName(cid), time = os.time() + (6 * 3600) })
        doRemoveItem(item.uid, 1)
        doSendMagicEffect(getThingPos(cid), 12)
        cave = i
        check = true
        break
      end
    end

    if check then
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você acabou de alugar a caverna " .. cave .. " por 6 horas. Aproveite!")
    else
      doPlayerSendCancel(cid, "Todas as cavernas já estão alugadas no momento. Tente novamente mais tarde.")
    end
  else
    local remainingTime = getPlayerStorageValue(cid, stg) - os.time()
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, restTempo(remainingTime))
  end
end


last test the code there .. if it continues does not work, I will give up doing it, unfortunately ;/
 
script is working but, player not get access for cave
05:47 Você acabou de alugar a caverna 1 por 6 horas. Aproveite!
you can use talk action with /caves, you dont see anything caves no have access
 
Lua:
function restTempo(storage)
  local segundos, minutos, horas = 0, 0, 0
  local tot = storage - os.time()
  horas = math.floor(tot / 3600)
  tot = tot - horas * 3600
  minutos = math.floor(tot / 60)
  tot = tot - minutos * 60
  segundos = tot
  return string.format("Você já usou este item e precisa esperar %.2d:%.2d:%.2d para usar novamente.", horas, minutos, segundos)
end

local storages = {
  722340,
  722341,
  722342,
  722343,
  722344,
  722345,
  722346,
  722347,
  722348,
  722349,
  722363,
  722364,
  722365,
  722366,
  722367,
  722368,
  722369,
  722370,
  722371,
  722372
}

local stg = 722340

local function hasCave(cid)
  for _, storage in ipairs(storages) do
    local sto = getGlobalStorageValue(storage)
    if type(sto) == "table" and sto.guid and sto.guid == getCreatureName(cid) then
      if tonumber(sto.time) > os.time() then
        return true
      end
    end
  end
  return false
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
  if hasCave(cid) then
    return doPlayerSendCancel(cid, "Você já é o dono de uma caverna e não pode alugar outra até o término do aluguel atual.")
  end

  if getPlayerStorageValue(cid, stg) < os.time() then
    setPlayerStorageValue(cid, stg, os.time() + (24 * 3600))
    local check, cave = false, 0

    for i, storage in ipairs(storages) do
      local sto = getGlobalStorageValue(storage)
      if type(sto) ~= "table" or not sto.time then
        setGlobalStorageValue(storage, { guid = getCreatureName(cid), time = os.time() + (6 * 3600) })
        doRemoveItem(item.uid, 1)
        doSendMagicEffect(getThingPos(cid), 12)
        cave = i
        check = true
        break
      elseif sto.time and tonumber(sto.time) < os.time() then
        setGlobalStorageValue(storage, { guid = getCreatureName(cid), time = os.time() + (6 * 3600) })
        doRemoveItem(item.uid, 1)
        doSendMagicEffect(getThingPos(cid), 12)
        cave = i
        check = true
        break
      end
    end

    if check then
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você acabou de alugar a caverna " .. cave .. " por 6 horas. Aproveite!")
      doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    else
      doPlayerSendCancel(cid, "Todas as cavernas já estão alugadas no momento. Tente novamente mais tarde.")
    end
      else
    local remainingTime = getPlayerStorageValue(cid, stg) - os.time()
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, restTempo(remainingTime))
  end
end
I added this function
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
let's see what it gives!
 
I think you need to put teleportation as storage, you have to use the map editor (rme) I don't know, when you use the item and be able to enter the basement (tp) or it may be missing a function "position of the teleport".




PM me!
 
take a look, just for example... put some [xxx] = { -- Action ID, one for each cellar.
gStor = 7330, -- Global storage, one value for each basement.
caveName = "Cave 1", -- Name of the cave.
enterPos = {x=0, y=0, z=7}, -- Position the player will be teleported to when entering the basement.
signPos = {x=0, y=0, z=7} -- Position of the item that was configured in the signID variable on the map.

Swift:
https://tibiaking.com/forums/topic/100090-cave-exclusiva-super-up-by-woox/

I think something like that

but I don't know how it works, I hope someone is a good scripter to be able to help you!!
 
Back
Top