W mysql wykonujemy zapytanie:
Kod :
ALTER TABLE `players` ADD `ontime` int(11) NOT NULL ;
Kod :
<event type="logout" name="PlayerLogout" script="logout.lua"/>
Przed:
Kod :
return TRUE
Kod :
setPlayerStorageValue(cid, 9999, os.time())
I wklejamy do niego to:
Kod :
function onLogout(cid)
local online = math.floor(os.time() - getPlayerStorageValue(cid, 9999))
setPlayerOnlineTime(cid, online)
end
Kod :
function getPlayerOnlineTime(uid)
if (isPlayer(uid) == TRUE) then
local select = db.getResult("SELECT `ontime` FROM `players` WHERE `name` = '" .. getPlayerName(uid) .. "' LIMIT 1;")
return select:getDataInt("ontime")
else
return FALSE
end
end
function setPlayerOnlineTime(uid, value)
if (isPlayer(uid) == TRUE) then
db.executeQuery("UPDATE `players` SET `ontime` = `ontime` + " .. value .. " WHERE `name`='" .. getPlayerName(uid) .. "' LIMIT 1;")
return TRUE
else
return FALSE
end
end
Kod :
local online = math.floor(os.time() - getPlayerStorageValue(cid, 9999))
setPlayerOnlineTime(cid, online)
Pozdrawiam.
Zakładki