Player.TimeConnected

From GMod Wiki

Jump to: navigation, search
Function
Syntax Player:TimeConnected( )
Description:
Returns player's connection time as a real number in the format of seconds.
Returns: Number
In Object: Player
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.TimeConnected]Player.TimeConnected [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionPrints player id 1's connection time in seconds.
Used onNewerServer.png
Code
local objPl = player.GetByID(1)
objPl:ChatPrint(tostring(objPl:TimeConnected())
 
OutputConnection time in seconds.


DescriptionIt prints localplayer connection time in seconds on client-side.
Used onNewerClient.png
Code
 
LocalPlayer():ChatPrint(tostring(math.Round(CurTime()))) --Do check if CurTime() on client will return time since you connected to server.
 
--if CurTime() doesn't return time since connect on clientside, contact me if you need this to work on other players but show clientside.
local timeConnect = 0
hook.Add("InitPostEntity","GetConnectTime",function() timeConnect = CurTime() end)
function GetTimeConnected()
return CurTime() - timeConnect
end
 
OutputConnection time since you joined the server.

WARNING: THIS IS A WORKAROUND FOR CLIENTSIDE!

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox