Added connection count and last connection information

This commit is contained in:
Timo Smit 2017-02-17 12:08:42 +01:00
parent 935f71d4ab
commit fafc53710b
2 changed files with 4 additions and 2 deletions

View file

@ -14,6 +14,8 @@ CREATE TABLE IF NOT EXISTS `player` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`guid` TEXT NOT NULL UNIQUE,
`ip` TEXT NOT NULL,
`lastseen` INTEGER NOT NULL,
`seen` INTEGER NOT NULL,
`level_id` INTEGER NOT NULL,
CONSTRAINT `player_level` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);

View file

@ -35,8 +35,8 @@ function sqlite3.addplayer(guid, ip)
cur = assert(con:execute("INSERT INTO `player` (`guid`, `ip`, `level_id`) VALUES ('"..util.escape(guid).."', '"..util.escape(ip).."', 0)"))
end
function sqlite3.updateplayerip(guid, ip)
cur = assert(con:execute("UPDATE `player` SET `ip`='"..util.escape(ip).."' WHERE `guid`='"..util.escape(guid).."'"))
function sqlite3.updateplayer(guid, ip, lastSeen)
cur = assert(con:execute("UPDATE `player` SET `ip`='"..util.escape(ip).."', `lastseen`="..lastSeen..", `seen`=`seen`+1 WHERE `guid`='"..util.escape(guid).."'"))
end
function sqlite3.updateplayerlevel(id, level)