mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-30 15:37:36 +01:00
SQL update: track playtime per player per day for stats
This commit is contained in:
@@ -565,3 +565,18 @@ CREATE TABLE `oauth_tokens` (
|
||||
PRIMARY KEY (`token`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
||||
--
|
||||
-- Table structure for table `playtime_history`
|
||||
--
|
||||
DROP TABLE IF EXISTS `playtime_history`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `playtime_history` (
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`date` DATE NOT NULL,
|
||||
`time_living` SMALLINT NOT NULL,
|
||||
`time_ghost` SMALLINT NOT NULL,
|
||||
PRIMARY KEY (`ckey`, `date`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
@@ -564,3 +564,17 @@ CREATE TABLE `SS13_oauth_tokens` (
|
||||
PRIMARY KEY (`token`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `SS13_playtime_history`
|
||||
--
|
||||
DROP TABLE IF EXISTS `SS13_playtime_history`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `SS13_playtime_history` (
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`date` DATE NOT NULL,
|
||||
`time_living` SMALLINT NOT NULL,
|
||||
`time_ghost` SMALLINT NOT NULL,
|
||||
PRIMARY KEY (`ckey`, `date`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
@@ -0,0 +1,11 @@
|
||||
# Updating SQL from ver 9 to 10 - Kyet
|
||||
|
||||
# Add the 'playtime_history' table that tracks playtime per player per day
|
||||
CREATE TABLE `playtime_history` (
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`date` DATE NOT NULL,
|
||||
`time_living` SMALLINT NOT NULL,
|
||||
`time_ghost` SMALLINT NOT NULL,
|
||||
PRIMARY KEY (`ckey`, `date`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
@@ -319,7 +319,7 @@
|
||||
#define INVESTIGATE_BOMB "bombs"
|
||||
|
||||
// The SQL version required by this version of the code
|
||||
#define SQL_VERSION 9
|
||||
#define SQL_VERSION 10
|
||||
|
||||
// Vending machine stuff
|
||||
#define CAT_NORMAL 1
|
||||
|
||||
@@ -263,8 +263,11 @@ var/global/list/role_playtime_requirements = list(
|
||||
myrole = mob.mind.playtime_role
|
||||
else if(mob.mind.assigned_role)
|
||||
myrole = mob.mind.assigned_role
|
||||
var/added_living = 0
|
||||
var/added_ghost = 0
|
||||
if(mob.stat == CONSCIOUS && myrole)
|
||||
play_records[EXP_TYPE_LIVING] += minutes
|
||||
added_living += minutes
|
||||
if(announce_changes)
|
||||
to_chat(mob,"<span class='notice'>You got: [minutes] Living EXP!")
|
||||
for(var/category in exp_jobsmap)
|
||||
@@ -279,6 +282,7 @@ var/global/list/role_playtime_requirements = list(
|
||||
to_chat(mob,"<span class='notice'>You got: [minutes] Special EXP!")
|
||||
else if(isobserver(mob))
|
||||
play_records[EXP_TYPE_GHOST] += minutes
|
||||
added_ghost += minutes
|
||||
if(announce_changes)
|
||||
to_chat(mob,"<span class='notice'>You got: [minutes] Ghost EXP!")
|
||||
else
|
||||
@@ -289,6 +293,12 @@ var/global/list/role_playtime_requirements = list(
|
||||
var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]',lastseen = Now() WHERE ckey='[ckey]'")
|
||||
if(!update_query.Execute())
|
||||
var/err = update_query.ErrorMsg()
|
||||
log_game("SQL ERROR during exp_update_client write. Error : \[[err]\]\n")
|
||||
message_admins("SQL ERROR during exp_update_client write. Error : \[[err]\]\n")
|
||||
log_game("SQL ERROR during exp_update_client write 1. Error : \[[err]\]\n")
|
||||
message_admins("SQL ERROR during exp_update_client write 1. Error : \[[err]\]\n")
|
||||
return
|
||||
var/DBQuery/update_query_history = dbcon.NewQuery("INSERT INTO [format_table_name("playtime_history")] (ckey, date, time_living, time_ghost) VALUES ('[ckey]',CURDATE(),[added_living],[added_ghost]) ON DUPLICATE KEY UPDATE time_living=time_living+VALUES(time_living),time_ghost=time_ghost+VALUES(time_ghost)")
|
||||
if(!update_query_history.Execute())
|
||||
var/err = update_query_history.ErrorMsg()
|
||||
log_game("SQL ERROR during exp_update_client write 2. Error : \[[err]\]\n")
|
||||
message_admins("SQL ERROR during exp_update_client write 2. Error : \[[err]\]\n")
|
||||
return
|
||||
@@ -9,7 +9,7 @@
|
||||
## This value must be set to the version of the paradise schema in use.
|
||||
## If this value does not match, the SQL database will not be loaded and an error will be generated.
|
||||
## Roundstart will be delayed.
|
||||
DB_VERSION 9
|
||||
DB_VERSION 10
|
||||
|
||||
## Server the MySQL database can be found at.
|
||||
# Examples: localhost, 200.135.5.43, www.mysqldb.com, etc.
|
||||
|
||||
Reference in New Issue
Block a user