You could use a hook for "PlayerInitialSpawn" and create a timer for that player that updates every second.
function updatePlayer( ply )
// Your code to save the frags/data/etc.
end
function timerStart( ply )
timer.Create( "save_stats_"..tostring(ply:SteamID()), 1, 0, function() if not (ply and IsValid(ply)) then return end updatePlayer( ply ) end ) // Runs every second forever.
end
hook.Add( "PlayerInitialSpawn", "timerstarting", timerStart )
function destroyTimers(ply) // Destroy the timers when they disconnect and save their stats one more time.
if (ply and IsValid(ply)) then updatePlayer( ply ) end
if timer.Exists("save_stats_" ..tostring(ply:SteamID())) then
timer.Stop("save_stats_" ..tostring(ply:SteamID()))
timer.Destroy("save_stats_" ..tostring(ply:SteamID()))
end
end
hook.Add( "PlayerDisconnected", "PromotionCleanUP", destroyTimers )