Clocky - Keep track of how long users have played on your server(s)!


If you want to use the MySQL saving, you'll need MySQLOO, found here:


What is Clocky

Clocky is something I made because I couldn’t find something to keep track of playtime on multiple servers at once.
What it does is keep track of how long you play, and depending on the config save it to MySQL.

How it works

Each server can be assigned a name, such as ‘TTT #1’ and ‘TTT #2’.
They will then be stored in a table, which is then turned into a string using vON (by Vercas) and stored to MySQL.
This allows you to easily keep track of individual servers, though if wanted they can be added to get the total playtime on all.
If you wish to just count them all together, you can assign each server the same name so that they will share the data.

Without MySQL it will store playtime to PData, file or both PData and file.

I’ve added some reasonable config options to let server owners decide how they want to save, how often they want to save, etc.

Clocky.MenuCommand = “!clocky” --What to say in chat to open the menu?

Clocky.Save.Type = “PData” --‘PData’, ‘file’ or ‘both’
Clocky.Save.Folder = “Clocky” --What folder in DATA to save to, if savetype is file
Clocky.Save.Autosave = true --Enable autosave?
Clocky.Save.Interval = 300 --How often to autosave

Clocky.Admin.Enabled = true --Enable the admin menu?
Clocky.Admin.Ranks = {‘admin’, ‘superadmin’} --What ranks can use the admin panel? These will not have access to config
Clocky.Admin.HighRanks = {‘superadmin’} --These ranks will also have access to config

Clocky.SQL.Enabled = false --Change this to true to enable SQL, fill in the required stuff below if true!
Clocky.SQL.Module = “mysqloo” --Choose between “mysqloo” and “tmysql”
Clocky.SQL.Standalone = false --Do you want it to save only to MySQL or still use PData/file alongside MySQL?
Clocky.SQL.Servername = “SERVER” --This is how Clocky will keep track of how long players have played on this specific server

Clocky.SQL.Host = “” --IP
Clocky.SQL.Port = 3306 --Port
Clocky.SQL.Database = “” --Name of the database
Clocky.SQL.Username = “” --The username used to connect to the database
Clocky.SQL.Password = “” —Password of the above user
Clocky.SQL.Socket = “” --Database socketing; leave blank unless you are not using default

As you can see, you don’t have to use MySQL. You can just disable that and swap to PData or files.
I’ve also made it so that if you want to transfer over playtimes you can save as file and then enable saving as file on the other server.
You can only do this if the server doesn’t have any MySQL stuff stored yet. It will then save the time from the file to MySQL. (Or you can just use the same servername)

Players can use some console commands, too:
clocky_showui 0/1 --Hide or show the UI
clocky_menu --Opens the menu (mainly for admins, WIP)

Here’s what it looks like in-game:

Here’s a WIP panel, mainly for admins. The only thing users will be able to do is hide or show UI. Right now, the config options don’t do anything yet (You will be able to change everything).
The list of time played does work and will update when a player leaves or joins. Their time played is simulated by the client.
Time played can be seen by every rank in Clocky.Admin.Ranks, whilst config options will only be able to be altered by HighRanks.
Access the menu from console with clocky_menu or by typing the configured command (!clocky by default).

I made this with the intention of it being lightweight.
I’ve tried to keep the amount of queries as low as possible and the client will simulate his own time played (though the server will be doing the actual saving and math).
Even though this is supposed to be lightweight, at the SQL part I feel like I started messing up some things.

If there's bugs or inefficient/messy code, please let me know so I can fix it. Feedback is appreciated!

[lua]code_gs: tmysql support, sockets and fixing spacing inconsistencies[/lua]


Workshop: (github one if you want the config, or decompile the .gma)

This is also my first release! :dance:

Good job, finally something to replace old crappy UTime.

Submitted a pull request for tmysql support.

Oh dear god, I’ve been looking for a replacement for UTime for some time now. Thanks

I’ll be honest, I personally don’t like the idea of a constant visual showing you your playtime, but many people seem to since I’ve come across a million servers with Utime.

Great idea to have it track multiple servers though, nice work!

I’ll add the option to hide it with a console command or something.

Edit: Added a clientside convar to hide/show it, clocky_showui 0/1

Y U NO SQLite, like Nutscript uses?

I’ll see about adding support for that.

(Though I think PData is already sqlite)

PData uses SQLite internally.

suggestion: have a chat command where you can type !ptime [steamid/player] to view their total time server-wide or for each server.

or if anybody has the time a simple php webpage that does that (better)

i could do an php page later on, but first breakfast. It is pretty basic. Grab the Table, convert SteamID to Username per Steam WEB API and echo it.

seems to cause some errors with my pointshop for some reason.
I’m not using the most up to date version of the pointshop, I believe it is the previous version.
Can supply screen shots of all the errors if need be.

Obviously you need to post errors.

This is what happens after I add clocky:

This is on my stable Prop Hunt server, that never has these errors until I add clocky.

and it just constantly spams those errors

Did you have autosaving on or off?

The problem should be fixed now, also merged with code_gs so there is tmysql support (thanks!).

yes autosave was on

[editline]19th August 2014[/editline]

Go this when I left the game (with latest update):

I think that’s something with IsValid, should have it fixed in a bit.

Getting my feet wet in derma:

Because I’ll once again be simulating this on the client to avoid server load, the actual times might sometimes be 1 minute off.

Edit: Update (WIP)

I’ve also added a way to let players open the menu by typing a command. Default is !clocky.

can vouch that this is working wonderfully! will be working on a webpage thing to display times too!

Having issues with the Hide and Seek game mode with latest version of Pointshop and this.

Will get errors tomorrow, time for bed.

mysqloo support plz…