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

Function on Look Item

Vrotz

Member
Joined
Apr 7, 2011
Messages
1,071
Reaction score
7
Location
Brazil
Hello,
I've a script to scan the items of player when they logged in game. These items lasts thirty days.

Like that:
PHP:
doItemSetAttribute(item.uid, "duration", os.time() + 30 * 24 * 60 * 60)

How I do to when I look at the item I know the time remaining to finished the 30 days?

Ex:
PHP:
This item will expire on 27d and 50 minutes
 
this is the lua weird way:
Lua:
local dur = getItemAttribute(item.uid, "duration")
local days = round((dur - os.time())/24/60/60)
local minutes = round((dur-os.time())/60)
print( days.." and "..minutes)
i'll check the sources to see if i can do it there
 
Last edited:
Lua:
local dur = getItemAttribute(item.uid, "duration")
local rTime = dur - os.time()
local days = math.floor(((rTime/60)/60)/24)
rTime = rTime - (days * 60 * 60 * 24)
local hours = math.floor((rTime/60)/60)
rTime = rTime - (hours * 60 * 60)
local minutes = math.floor(rTime/60)
rTime = rTime - (minutes * 60)
local seconds = rTime
local txt = "This item will expire on ".. days .."d, ".. hours .."h, ".. minutes .."m and ".. seconds .."s."

You can add that to onLook script and then send txt to player...
 
Back
Top