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

TFS 1.X+ [MOVEMENTS] New Players can't access

Hyagosrs

Member
Joined
Mar 10, 2018
Messages
94
Solutions
1
Reaction score
11
when a new player try to step in it says:
Screenshot_1.png

this is script check if they have the storage and says how much time left to access a boss.

Lua:
function onStepIn(cid, item, position, fromPosition)
     if getPlayerStorageValue(cid, 8092) ~= 1 then
         doPlayerSendCancel(cid, "You need to wait " ..getPlayerStorageValue(cid, 8089) - os.time() .." seconds to access this boss again.")
         doTeleportThing(cid, fromPosition)
     end
     return true
end

the player doesn't have this storage, but he can't access this tile.
 
Solution
try this one
Lua:
local STORAGE = 8092
function onStepIn(cid, item, position, fromPosition)
local cur = math.max(getCreatureStorage(cid,STORAGE) - os.time(), 0)
if cur > 1 then
local days = math.floor(cur / (60 * 60 * 24))
cur = cur - days * 60 * 60 * 24
local hours = math.floor(cur / (60 * 60))
cur = cur - hours * 60 * 60
local minutes = math.floor(cur / 60)
  doPlayerSendCancel(cid, string.format("You need to wait %d days, %d hours and %d minutes left to access this boss again.", days, hours, minutes))
doTeleportThing(cid, fromPosition)
end
return false
end

or this one

Lua:
       function onStepIn(cid, item, position, fromPosition)
        local time = getPlayerStorageValue(cid, 8089) - os.time()
         local hours, minutes...
change if getPlayerStorageValue(cid, 8092) ~= 1 then to if getPlayerStorageValue(cid, 8092) == 1 then
 
Lua:
function onStepIn(cid, item, position, fromPosition)
     if getPlayerStorageValue(cid, 8092) > 1 then
         doPlayerSendCancel(cid, "You need to wait " ..getPlayerStorageValue(cid, 8089) - os.time() .." seconds to access this boss again.")
         doTeleportThing(cid, fromPosition)
    else
        return true
     end
     return true
end
 
Last edited:
Lua:
function onStepIn(cid, item, position, fromPosition)
     if getPlayerStorageValue(cid, 8092) > 1 then
         doPlayerSendCancel(cid, "You need to wait " ..getPlayerStorageValue(cid, 8089) - os.time() .." seconds to access this boss again.")
         doTeleportThing(cid, fromPosition)
    else
        return true
     end
     return true
end

Edit: The storage use os.time() ?

it seems it works perfectly, do you know how to change second to minutos in this message?
 
Maybe...

Lua:
doPlayerSendCancel(cid, "You need to wait " ..(getPlayerStorageValue(cid, 8089) - os.time())/60 .." minutes to access this boss again.")


If the code stop working when the player get the storage change
Code:
if getPlayerStorageValue(cid, 8092) > 1 then
To:
Code:
if getPlayerStorageValue(cid, 8092) > os.time() then
 
try this one
Lua:
local STORAGE = 8092
function onStepIn(cid, item, position, fromPosition)
local cur = math.max(getCreatureStorage(cid,STORAGE) - os.time(), 0)
if cur > 1 then
local days = math.floor(cur / (60 * 60 * 24))
cur = cur - days * 60 * 60 * 24
local hours = math.floor(cur / (60 * 60))
cur = cur - hours * 60 * 60
local minutes = math.floor(cur / 60)
  doPlayerSendCancel(cid, string.format("You need to wait %d days, %d hours and %d minutes left to access this boss again.", days, hours, minutes))
doTeleportThing(cid, fromPosition)
end
return false
end

or this one

Lua:
       function onStepIn(cid, item, position, fromPosition)
        local time = getPlayerStorageValue(cid, 8089) - os.time()
         local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
         if time >= 3600 then
             text = hours.." "..(hours > 1 and "hours" or "hour")..", "..minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
         elseif time >= 60 then
             text = minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
         else
             text = seconds.." "..(seconds > 1 and "seconds" or "second")
         end
         if getPlayerStorageValue(cid, 8092) > 1 then
         doPlayerSendCancel(cid, "You need to wait "..text.." seconds to access this boss again.")
         doTeleportThing(cid, fromPosition)
     end
     return true
end
 
Solution
try this one
Lua:
local STORAGE = 8092
function onStepIn(cid, item, position, fromPosition)
local cur = math.max(getCreatureStorage(cid,STORAGE) - os.time(), 0)
if cur > 1 then
local days = math.floor(cur / (60 * 60 * 24))
cur = cur - days * 60 * 60 * 24
local hours = math.floor(cur / (60 * 60))
cur = cur - hours * 60 * 60
local minutes = math.floor(cur / 60)
  doPlayerSendCancel(cid, string.format("You need to wait %d days, %d hours and %d minutes left to access this boss again.", days, hours, minutes))
doTeleportThing(cid, fromPosition)
end
return false
end

or this one

Lua:
       function onStepIn(cid, item, position, fromPosition)
        local time = getPlayerStorageValue(cid, 8089) - os.time()
         local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
         if time >= 3600 then
             text = hours.." "..(hours > 1 and "hours" or "hour")..", "..minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
         elseif time >= 60 then
             text = minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
         else
             text = seconds.." "..(seconds > 1 and "seconds" or "second")
         end
         if getPlayerStorageValue(cid, 8092) > 1 then
         doPlayerSendCancel(cid, "You need to wait "..text.." seconds to access this boss again.")
         doTeleportThing(cid, fromPosition)
     end
     return true
end

it didn't work, players access everytime.
 
2 scripts don't work ?
try this
Lua:
local STORAGE = 8089
function onStepIn(cid, item, position, fromPosition)
local cur = math.max(getCreatureStorage(cid,STORAGE) - os.time(), 0)
if getPlayerStorageValue(cid, 8092) > 1 then
local days = math.floor(cur / (60 * 60 * 24))
cur = cur - days * 60 * 60 * 24
local hours = math.floor(cur / (60 * 60))
cur = cur - hours * 60 * 60
local minutes = math.floor(cur / 60)
  doPlayerSendCancel(cid, string.format("You need to wait %d days, %d hours and %d minutes left to access this boss again.", days, hours, minutes))
doTeleportThing(cid, fromPosition)
end
return false
end
 
Maybe...

Lua:
doPlayerSendCancel(cid, "You need to wait " ..(getPlayerStorageValue(cid, 8089) - os.time())/60 .." minutes to access this boss again.")


If the code stop working when the player get the storage change
Code:
if getPlayerStorageValue(cid, 8092) > 1 then
To:
Code:
if getPlayerStorageValue(cid, 8092) > os.time() then

good it worked, is it possible to have a limit for this?
Screenshot_2.png
 
Back
Top