mirror of
https://github.com/CFC-Servers/cfc_time.git
synced 2025-03-04 03:03:20 -05:00
add comments explaining utime compat desired behavior, fix GetUTime function (#44)
This commit is contained in:
parent
def1cd8b4a
commit
067e54b464
@ -8,20 +8,24 @@ CreateConVar( "utime_enable", "1", FCVAR_ARCHIVE )
|
||||
local logger = CFCTime.Logger
|
||||
local plyMeta = FindMetaTable( "Player" )
|
||||
|
||||
-- GetUTime returns the total time the player has played on the server excluding the current session
|
||||
function plyMeta:GetUTime()
|
||||
return self:GetNWFloat( "CFC_Time_TotalTime", 0 )
|
||||
return self:GetNWFloat( "CFC_Time_TotalTime", 0 ) - self:GetUTimeSessionTime()
|
||||
end
|
||||
|
||||
-- GetUTimeStart returns the time the player started their current session
|
||||
function plyMeta:GetUTimeStart()
|
||||
local now = os.time()
|
||||
local sessionSeconds = now - self:GetNWFloat( "CFC_Time_SessionStart", now )
|
||||
return CurTime() - sessionSeconds
|
||||
end
|
||||
|
||||
-- GetUTimeSessionTime returns the time the player has played in their current session
|
||||
function plyMeta:GetUTimeSessionTime()
|
||||
return self:GetNWFloat( "CFC_Time_SessionDuration", 0 )
|
||||
end
|
||||
|
||||
-- GetUTimeTotalTime returns the total time the player including the current session
|
||||
function plyMeta:GetUTimeTotalTime()
|
||||
local total = self:GetNWFloat( "CFC_Time_TotalTime", 0 )
|
||||
|
||||
@ -61,10 +65,10 @@ if SERVER then
|
||||
|
||||
logger:info(
|
||||
string.format(
|
||||
"Player %s [%s] migrated from UTime with existing time of %d",
|
||||
ply:GetName(),
|
||||
steamID,
|
||||
totalTime
|
||||
"Player %s [%s] migrated from UTime with existing time of %d",
|
||||
ply:GetName(),
|
||||
steamID,
|
||||
totalTime
|
||||
)
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user