Global event to track online time and exp gained each day (last 7 days) for pages:
github.com
github.com
Tested on TFS 1.4. Should work on any TFS 1.x.
Script includes 'database global storage' for TFS 1.x from Solved - Global Storage + TFS 1.2 (https://otland.net/threads/global-storage-tfs-1-2.245524/#post-2388322)
1. In
2. Create file
Gesior2012/pages/powergamers.php at master · gesior/Gesior2012
Gesior 2012 - Account Maker [website] for OTSes, account maker you can find in BRANCHES. Select 'branch'. - gesior/Gesior2012
Gesior2012/pages/onlinetime.php at master · gesior/Gesior2012
Gesior 2012 - Account Maker [website] for OTSes, account maker you can find in BRANCHES. Select 'branch'. - gesior/Gesior2012
Tested on TFS 1.4. Should work on any TFS 1.x.
Script includes 'database global storage' for TFS 1.x from Solved - Global Storage + TFS 1.2 (https://otland.net/threads/global-storage-tfs-1-2.245524/#post-2388322)
1. In
data/globalevents/globalevents.xml
add:
XML:
<globalevent name="powergamers" interval="60000" script="powergamers.lua"/>
data/globalevents/scripts/powergamers.lua
:
LUA:
--[[
Requires database schema:
CREATE TABLE `global_storage`
(
`key` INT UNSIGNED NOT NULL,
`value` VARCHAR(255) NOT NULL DEFAULT '0',
UNIQUE (`key`)
) ENGINE = InnoDB;
]]
local function getGlobalStorageValueDB(key)
local query = db.storeQuery("SELECT `value` FROM `global_storage` WHERE `key` = " .. key .. ";")
if query ~= false then
local val = result.getDataInt(query, "value")
result.free(query)
return val
end
return -1
end
local function setGlobalStorageValueDB(key, value)
db.query("INSERT INTO `global_storage` (`key`, `value`) VALUES (".. key ..", ".. value ..") ON DUPLICATE KEY UPDATE `value` = ".. tonumber(value))
end
function onThink()
if (tonumber(os.date("%d")) ~= getGlobalStorageValueDB(23456)) then
setGlobalStorageValueDB(23456, (tonumber(os.date("%d"))))
db.query("UPDATE `players` SET `onlinetime7`=`onlinetime6`, `onlinetime6`=`onlinetime5`, `onlinetime5`=`onlinetime4`, `onlinetime4`=`onlinetime3`, `onlinetime3`=`onlinetime2`, `onlinetime2`=`onlinetime1`, `onlinetime1`=`onlinetimetoday`, `onlinetimetoday`=0;")
db.query("UPDATE `players` SET `exphist7`=`exphist6`, `exphist6`=`exphist5`, `exphist5`=`exphist4`, `exphist4`=`exphist3`, `exphist3`=`exphist2`, `exphist2`=`exphist1`, `exphist1`=`experience`-`exphist_lastexp`, `exphist_lastexp`=`experience`;")
end
db.query("UPDATE `players` INNER JOIN `players_online` ON `players`.`id` = `players_online`.`player_id` SET `onlinetimetoday`=`onlinetimetoday`+60, `onlinetimeall`=`onlinetimeall`+60")
return true
end