• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction /played <- show total time online

Peonso

Godly Member
Joined
Jan 14, 2008
Messages
1,784
Solutions
30
Reaction score
1,584
The script will tell you your online time with the character. The format is "Total time played: 0 days, 1 hours, 15 minutes, since 10 Jun 2014."

You need the lua functions and database updates made by Gesior for his Powergamers script, HERE. Or the command won't work.

Add this line to /data/talkactions/talkactions.xml file:
Code:
<talkaction words="/played" script="played.lua"/>

Create file called "played.lua" in ..../data/talkactions/scripts directory:
Code:
function onSay(cid, words, param, channel)
    local v = ""
    local srt = ""
    local secs = ""
    secs = getPlayerOnlineTime(cid)
    -- converting secs --
    local hours = math.ceil(secs / 3600) - 1
    local minutes = math.ceil((secs - (3600 * hours)) / 60)
    if (minutes == 60) then
        minutes = 0
        hours = hours + 1
    end
    local days = math.ceil(hours / 24) - 1
    hours = math.ceil(hours - (24 * days))
    if (hours == 24) then
        hours = 0
        days = days + 1
    end
    -- end of conversion --
    str = "Total time played: ".. days .." days, ".. hours .." hours, ".. minutes .." minutes, since " .. os.date("%d %b %Y", getCreateDate(cid)) .. "."
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
    return true
end

function getPlayerOnlineTime(cid)
    local query = db.getResult("SELECT `onlinetimeall` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. ";")
    if query:getID() ~= -1 then
    return query:getDataInt("onlinetimeall")
    end
    query:free()
    return LUA_ERROR
end

function getCreateDate(cid)
    local query = db.getResult("SELECT `create_date` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. ";")
    if query:getID() ~= -1 then
    return query:getDataInt("create_date")
    end
    query:free()
    return LUA_ERROR
end

Tested with TFS 0.3.7.
 
Back
Top