!!!TESTED ON TFS 0.3.5pl1!!!
So, i know that there is already some sort of this script, but anyway i found it some kind of buggy and i didn't really understand the example the authors gave
That is the reason i made my own, really easy to configue, here it comes:
First of all add this code at the end of your data/lib functions.lua
And here comes my script >>Extra explanation: Make a lua file, name it to whatever you want, put it in your data/actions/scripts, copy/paste my code, add this line into your data/actions actions.xml
So, i know that there is already some sort of this script, but anyway i found it some kind of buggy and i didn't really understand the example the authors gave
That is the reason i made my own, really easy to configue, here it comes:
First of all add this code at the end of your data/lib functions.lua
Code:
function timeString(timeDiff)
local dateFormat = {
{"day", timeDiff / 60 / 60 / 24},
{"hour", timeDiff / 60 / 60 % 24},
{"minute", timeDiff / 60 % 60},
{"second", timeDiff % 60}
}
local out = {}
for k, t in ipairs(dateFormat) do
local v = math.floor(t[2])
if(v > 0) then
table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
end
end
return table.concat(out)
end
And here comes my script >>Extra explanation: Make a lua file, name it to whatever you want, put it in your data/actions/scripts, copy/paste my code, add this line into your data/actions actions.xml
Code:
<action uniqueid="xxxx" event="script" value="NameOf YourLuaFile.lua"/>
Code:
-- Script made by Menfes
-- Credits to Darad for helping me with the simple idea about os.time() xD
-- 100% credits to the one who made timeDiff >>Colandus<<(its little buggy when it comes to seconds
-- ex.onUse (tibian time) ->00:32 Please come back in minutes and 30 seconds.
-- (Bug, its 0 minutes, but it still show "minutes")
function onUse(cid, item, fromPosition, itemEx, toPosition)
local waitTime = 5*60 -- in minutes, if u want seconds, remove *60
local itemName = "a magic ball" -- don't forget the prefix "a" or "an"
local itemId = 7632 -- the item ID :)
local storage = 123456 -- playerstorage number
--! Nabs don't configure !--
local queststatus = getPlayerStorageValue(cid,storage)
if queststatus + (waitTime) <= os.time() then
setPlayerStorageValue(cid,storage,os.time())
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found ".. itemName ..".")
doPlayerAddItem(cid,itemId,1)
elseif getPlayerStorageValue(cid, storage)-os.time()+(waitTime) <= 60 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"It is empty, come back in ".. getPlayerStorageValue(cid, storage)-os.time()+(waitTime) .." seconds.")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"It is empty, come back in ".. timeString(getPlayerStorageValue(cid, storage)-os.time()+(waitTime)) ..".")
end
return true
end
Last edited: