Adds 'age' command to world.Topic, for the IRC bot. Also runs all keys through ckey() before using them, to avoid easily-fixed errors

This commit is contained in:
GinjaNinja32
2015-06-25 22:52:36 +01:00
parent 9f8f075df0
commit 5906ae7556
2 changed files with 40 additions and 2 deletions
+19
View File
@@ -177,6 +177,25 @@
return ..()
// here because it's similar to below
// Returns null if no DB connection can be established, or -1 if the requested key was not found in the database
/proc/get_player_age(key)
establish_db_connection()
if(!dbcon.IsConnected())
return null
var/sql_ckey = sql_sanitize_text(ckey(key))
var/DBQuery/query = dbcon.NewQuery("SELECT datediff(Now(),firstseen) as age FROM erro_player WHERE ckey = '[sql_ckey]'")
query.Execute()
if(query.NextRow())
return text2num(query.item[1])
else
return -1
/client/proc/log_client_to_db()