• 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 0.X Arena quest temporary

kennyubuntu

Member
Joined
May 20, 2016
Messages
150
Reaction score
13
I have this arena quest script (mod): hastebin (https://hastebin.com/itazofihak.lua)

And on line 369 i'm trying to make this quest temporary...
But it is not working, it should printing wait 5 min, but it is showing this:

Code:
03:05 It is empty, you must wait -27073805 minutes to do it again.

What do i doing wrong?
 
Solution
Your issue is the storage value you are grabbing.
Lua:
math.ceil(((getPlayerStorageValue(cid, storage)) - timeNow)/days) -- current
math.ceil(((getPlayerStorageValue(cid, Reward.Stor)) - timeNow)/days) -- correct

-----------------------------------

Here's a useful function for you.
Lua:
local function SecondsToClock(seconds)
    if seconds < 0 then
        return "0 seconds"
    end
  
    local days = math.floor(seconds / 86400)
    seconds = seconds - days * 86400
    local hours = math.floor(seconds / 3600 )
    seconds = seconds - hours * 3600
    local minutes = math.floor(seconds / 60)
    seconds = seconds - minutes * 60
  
    return string.format("%d days, %d hours, %d minutes, %d seconds", days, hours, minutes, seconds)...
Your issue is the storage value you are grabbing.
Lua:
math.ceil(((getPlayerStorageValue(cid, storage)) - timeNow)/days) -- current
math.ceil(((getPlayerStorageValue(cid, Reward.Stor)) - timeNow)/days) -- correct

-----------------------------------

Here's a useful function for you.
Lua:
local function SecondsToClock(seconds)
    if seconds < 0 then
        return "0 seconds"
    end
  
    local days = math.floor(seconds / 86400)
    seconds = seconds - days * 86400
    local hours = math.floor(seconds / 3600 )
    seconds = seconds - hours * 3600
    local minutes = math.floor(seconds / 60)
    seconds = seconds - minutes * 60
  
    return string.format("%d days, %d hours, %d minutes, %d seconds", days, hours, minutes, seconds)
end

Then you can replace this entire block of code
Lua:
elseif getPlayerStorageValue(cid, Reward.Stor) < 0 then
 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
elseif getPlayerStorageValue(cid, Reward.Stor)-timeNow > days then
 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, storage)) - timeNow)/days) ..' days to do it again.')
elseif getPlayerStorageValue(cid, Reward.Stor)-timeNow > hours then
 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, storage)) - timeNow)/hours) ..' hours to do it again.')
else
 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, storage)) - timeNow)/mins) ..' minutes to do it again.')
end
with this
Lua:
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. SecondsToClock(getPlayerStorageValue(cid, Reward.Stor) - timeNow) ..' to do it again.')
Which would print..
Code:
It is empty, you must wait 0 days, 0 hours, 4 minutes, 53 seconds to do it again.
 
Solution
Your issue is the storage value you are grabbing.
Lua:
math.ceil(((getPlayerStorageValue(cid, storage)) - timeNow)/days) -- current
math.ceil(((getPlayerStorageValue(cid, Reward.Stor)) - timeNow)/days) -- correct

-----------------------------------

Here's a useful function for you.
Lua:
local function SecondsToClock(seconds)
    if seconds < 0 then
        return "0 seconds"
    end
 
    local days = math.floor(seconds / 86400)
    seconds = seconds - days * 86400
    local hours = math.floor(seconds / 3600 )
    seconds = seconds - hours * 3600
    local minutes = math.floor(seconds / 60)
    seconds = seconds - minutes * 60
 
    return string.format("%d days, %d hours, %d minutes, %d seconds", days, hours, minutes, seconds)
end

Then you can replace this entire block of code
Lua:
elseif getPlayerStorageValue(cid, Reward.Stor) < 0 then
 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
elseif getPlayerStorageValue(cid, Reward.Stor)-timeNow > days then
 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, storage)) - timeNow)/days) ..' days to do it again.')
elseif getPlayerStorageValue(cid, Reward.Stor)-timeNow > hours then
 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, storage)) - timeNow)/hours) ..' hours to do it again.')
else
 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, storage)) - timeNow)/mins) ..' minutes to do it again.')
end
with this
Lua:
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. SecondsToClock(getPlayerStorageValue(cid, Reward.Stor) - timeNow) ..' to do it again.')
Which would print..
Code:
It is empty, you must wait 0 days, 0 hours, 4 minutes, 53 seconds to do it again.

Oh fuck, i'm sorry for my lack of attention...
Thank you so much!
 
Back
Top