Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lua/autorun/sv_utime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ if not sql.TableExists( "utime" ) then
end

function onJoin( ply )
local uid = ply:UniqueID()
local oldID = ply:UniqueID()
local oldRow = sql.QueryRow( "SELECT player FROM utime WHERE player = " .. oldID .. ";" )
local uid = ply:SteamID64()
-- Update old entries to work seamlessly.
if( oldRow ) then
sql.Query("UPDATE utime SET player = " .. uid .. " WHERE player = " .. oldID .. ";")
end

local row = sql.QueryRow( "SELECT totaltime, lastvisit FROM utime WHERE player = " .. uid .. ";" )
local time = 0

Expand All @@ -32,7 +39,7 @@ end
hook.Add( "PlayerInitialSpawn", "UTimeInitialSpawn", onJoin )

function updatePlayer( ply )
sql.Query( "UPDATE utime SET totaltime = " .. math.floor( ply:GetUTimeTotalTime() ) .. " WHERE player = " .. ply:UniqueID() .. ";" )
sql.Query( "UPDATE utime SET totaltime = " .. math.floor( ply:GetUTimeTotalTime() ) .. " WHERE player = " .. ply:SteamID64() .. ";" )
end
hook.Add( "PlayerDisconnected", "UTimeDisconnect", updatePlayer )

Expand Down