utime/lua/autorun/sh_utime.lua

49 lines
1.1 KiB
Lua
Raw Permalink Normal View History

2012-12-18 16:12:43 -05:00
-- Written by Team Ulysses, http://ulyssesmod.net/
AddCSLuaFile( "autorun/sh_utime.lua" )
AddCSLuaFile( "autorun/cl_utime.lua" )
module( "Utime", package.seeall )
2025-01-16 13:04:08 -05:00
--[[
2012-12-18 16:12:43 -05:00
local meta = FindMetaTable( "Player" )
if not meta then return end
function meta:GetUTime()
2015-04-02 13:23:12 -04:00
return self:GetNWFloat( "TotalUTime" )
2012-12-18 16:12:43 -05:00
end
function meta:SetUTime( num )
2015-04-07 17:36:54 -04:00
self:SetNWFloat( "TotalUTime", num )
2012-12-18 16:12:43 -05:00
end
function meta:GetUTimeStart()
2015-04-02 13:23:12 -04:00
return self:GetNWFloat( "UTimeStart" )
2012-12-18 16:12:43 -05:00
end
function meta:SetUTimeStart( num )
2015-04-07 17:36:54 -04:00
self:SetNWFloat( "UTimeStart", num )
2012-12-18 16:12:43 -05:00
end
function meta:GetUTimeSessionTime()
return CurTime() - self:GetUTimeStart()
end
function meta:GetUTimeTotalTime()
return self:GetUTime() + CurTime() - self:GetUTimeStart()
end
2025-01-16 13:04:08 -05:00
]]--
2012-12-18 16:12:43 -05:00
function timeToStr( time )
local tmp = time
local s = tmp % 60
tmp = math.floor( tmp / 60 )
local m = tmp % 60
tmp = math.floor( tmp / 60 )
local h = tmp % 24
tmp = math.floor( tmp / 24 )
local d = tmp % 7
2013-01-27 20:33:19 -05:00
local w = math.floor( tmp / 7 )
2012-12-18 16:12:43 -05:00
return string.format( "%02iw %id %02ih %02im %02is", w, d, h, m, s )
end