# RevScriptskilluaCaveOwners/no back temple

#### Gaber Zen

##### Active Member
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

This should work, but you should consider adding a position check in case the player already left the spawn to temple, died, or whatever, so he doesn't get teleported unless he is in the spawn.
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)
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
function(cid, pos)
if not isPlayer(cid) then
return true
end
doTeleportThing(cid, pos)
end,
6 * 60 * 60 * 1000,
cid,
getTownTemplePosition(getPlayerTown(cid))
)
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
function(cid, pos)
if not isPlayer(cid) then
return true
end
doTeleportThing(cid, pos)
end,
6 * 60 * 60 * 1000,
cid,
getTownTemplePosition(getPlayerTown(cid))
)
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``````
To add the position check, replace both `addEvents`
Lua:
``addEvent(function(cid, pos) if not isPlayer(cid) then return true end doTeleportThing(cid, pos) end, 6 * 60 * 60 * 1000, cid, getTownTemplePosition(getPlayerTown(cid)))``
with
Lua:
``````if isInRange(getPlayerPosition(cid), {x = 1000, y = 1000, z = 7}, {x = 2000, y = 2000, z = 7}) then
function(cid, pos)
if not isPlayer(cid) then
return true
end
doTeleportThing(cid, pos)
end,
6 * 60 * 60 * 1000,
cid,
getTownTemplePosition(getPlayerTown(cid))
)
end``````
Don't forget to change the spawn position range instead of `{x = 1000, y = 1000, z = 7}, {x = 2000, y = 2000, z = 7}`

Last edited:
You make the subject a seat
I don't know how to change the separate codes

Last edited:
You don't have to change anything. Copy and paste.
The rest are just explanation of what you should do to make it better.

This should work, but you should consider adding a position check in case the player already left the spawn to temple, died, or whatever, so he doesn't get teleported unless he is in the spawn.
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)
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
function(cid, pos)
if not isPlayer(cid) then
return true
end
doTeleportThing(cid, pos)
end,
6 * 60 * 60 * 1000,
cid,
getTownTemplePosition(getPlayerTown(cid))
)
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
function(cid, pos)
if not isPlayer(cid) then
return true
end
doTeleportThing(cid, pos)
end,
6 * 60 * 60 * 1000,
cid,
getTownTemplePosition(getPlayerTown(cid))
)
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``````
To add the position check, replace both `addEvents`
Lua:
``addEvent(function(cid, pos) if not isPlayer(cid) then return true end doTeleportThing(cid, pos) end, 6 * 60 * 60 * 1000, cid, getTownTemplePosition(getPlayerTown(cid)))``
with
Lua:
``````if isInRange(getPlayerPosition(cid), {x = 1000, y = 1000, z = 7}, {x = 2000, y = 2000, z = 7}) then
function(cid, pos)
if not isPlayer(cid) then
return true
end
doTeleportThing(cid, pos)
end,
6 * 60 * 60 * 1000,
cid,
getTownTemplePosition(getPlayerTown(cid))
)
end``````
Don't forget to change the spawn position range instead of `{x = 1000, y = 1000, z = 7}, {x = 2000, y = 2000, z = 7}`
2
This should work, but you should consider adding a position check in case the player already left the spawn to temple, died, or whatever, so he doesn't get teleported unless he is in the spawn.
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)
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
function(cid, pos)
if not isPlayer(cid) then
return true
end
doTeleportThing(cid, pos)
end,
6 * 60 * 60 * 1000,
cid,
getTownTemplePosition(getPlayerTown(cid))
)
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
function(cid, pos)
if not isPlayer(cid) then
return true
end
doTeleportThing(cid, pos)
end,
6 * 60 * 60 * 1000,
cid,
getTownTemplePosition(getPlayerTown(cid))
)
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``````
To add the position check, replace both `addEvents`
Lua:
``addEvent(function(cid, pos) if not isPlayer(cid) then return true end doTeleportThing(cid, pos) end, 6 * 60 * 60 * 1000, cid, getTownTemplePosition(getPlayerTown(cid)))``
with
Lua:
``````if isInRange(getPlayerPosition(cid), {x = 1000, y = 1000, z = 7}, {x = 2000, y = 2000, z = 7}) then
function(cid, pos)
if not isPlayer(cid) then
return true
end
doTeleportThing(cid, pos)
end,
6 * 60 * 60 * 1000,
cid,
getTownTemplePosition(getPlayerTown(cid))
)
end``````
Don't forget to change the spawn position range instead of `{x = 1000, y = 1000, z = 7}, {x = 2000, y = 2000, z = 7}`
first Code i add in actions
second code where i can add?

player cant enter in cave, just 1 player use the scrolls OMG!!!

#### Attachments

player cant enter in cave, just 1 player use the scrolls OMG!!!
stop man go learn english and come

troll, and not only troll but disrespectful on DMs, and asking for specific chosen OTLand members to help you.
Feel free to mention them here like you used to do with your banned OTLand account, "Joker Man", I am not going to help anymore.

That's the only line I added to your existing script. If there are different issues, then they existed before my edit.
Lua:
``addEvent(function(cid, pos) if not isPlayer(cid) then return true end doTeleportThing(cid, pos) end, 6 * 60 * 60 * 1000, cid, getTownTemplePosition(getPlayerTown(cid)))``

I am not going to help anymore.
Why don't you tell him where he can put this script .

i use code by you look when i click in scrolls First 1 < no used
my Code is working but player no kick temple, 2 photo
You didn't help me

#### Attachments

Last edited:
Some one can help me, need player kick temple after 6 hours from use scrolls
Tfs 1.2

Some one can help me?

Some one fix the problem?

who help me?
Today

still im need help

help?

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 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 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)
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
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, restTempo(getPlayerStorageValue(cid, stg)))
end
end``````
test it tell me here

erro, in action

#### 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

function hasCave(cid)
for _, storage in ipairs(storages) do
local sto = getGlobalStorageValue(storage)
if 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 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)
doCreatureSay(cid, "Você acabou de alugar a caverna " .. cave .. " por 6 horas. Aproveite!", TALKTYPE_ORANGE_1)
return true
else
return 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 seconds = remainingTime % 60
local minutes = math.floor(remainingTime / 60) % 60
local hours = math.floor(remainingTime / 3600)
return doPlayerSendCancel(cid, string.format("Você já usou este item e precisa esperar %02d:%02d:%02d para usar novamente.", hours, minutes, seconds))
end
end``````
Post automatically merged:

updated the code better to inform everyone that the player just rented a cave etc

#### Attachments

Last edited:

RevScripts Potion EXP [8.6]
Replies
0
Views
273
Replies
8
Views
410
Replies
19
Views
941
Replies
2
Views
264
Replies
13
Views
328
Replies
5
Views
491
Replies
5
Views
382
Replies
11
Views
733
Replies
1
Views
116
Replies
2
Views
183