Fixed lastseen and seen NULL for new players

This commit is contained in:
Timo Smit 2017-02-27 21:48:46 +01:00
parent 6eeec2d20a
commit cd7ad4fd9c
2 changed files with 3 additions and 3 deletions

View file

@ -31,8 +31,8 @@ local con
local cur
-- players
function sqlite3.addplayer(guid, ip)
cur = assert(con:execute("INSERT INTO `player` (`guid`, `ip`, `level_id`) VALUES ('"..util.escape(guid).."', '"..util.escape(ip).."', 0)"))
function sqlite3.addplayer(guid, ip, lastSeen, seen)
cur = assert(con:execute("INSERT INTO `player` (`guid`, `ip`, `level_id`, `lastseen`, `seen`) VALUES ('"..util.escape(guid).."', '"..util.escape(ip).."', "..tonumber(lastSeen)..", "..tonumber(seen)..")"))
end
function sqlite3.updateplayer(guid, ip, lastSeen)

View file

@ -139,7 +139,7 @@ function players.onClientConnect(clientId, firstTime, isBot)
db.addalias(player["id"], data[clientId]["name"], os.time())
end
else
db.addplayer(data[clientId]["guid"], data[clientId]["ip"])
db.addplayer(data[clientId]["guid"], data[clientId]["ip"], os.time(), 1)
local player = db.getplayer(data[clientId]["guid"])
db.addalias(player["id"], data[clientId]["name"], os.time())