• 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!

GlobalEvent System Online Points

Sarah Wesker

ƐƖєgαηт Sуηтαx ❤
Staff member
TFS Developer
Support Team
Joined
Mar 16, 2017
Messages
1,416
Solutions
155
Reaction score
1,972
Location
London
GitHub
MillhioreBT
Twitch
millhiorebt
Hi everyone, this script I had done a long time ago, but it really needed an improvement and maybe move it to Revscript.
If you want to see the new version click here

data/scripts/gainpoinperhour.lua
Lua:
local config = {
    storage = 20000,
    pointItemId = 2160,
    pointsPerHour = 1,
    checkDuplicateIps = false
}

local onlinePointsEvent = GlobalEvent("GainPointPerHour")

function onlinePointsEvent.onThink(interval)
    local players = Game.getPlayers()
    if #players == 0 then
        return true
    end

    local checkIp = {}
    for _, player in pairs(players) do
        local ip = player:getIp()
        if ip ~= 0 and (not config.checkDuplicateIps or not checkIp[ip]) then
            checkIp[ip] = true
            local seconds = math.max(0, player:getStorageValue(config.storage))
            if seconds >= 3600 then
                player:setStorageValue(config.storage, 0)
                local item = player:addItem(config.pointItemId, config.pointsPerHour)
                if item then
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("You have received %d %s for being online for an hour.", config.pointsPerHour, item:getName()))
                end
                return true
            end
            player:setStorageValue(config.storage, seconds +math.ceil(interval/1000))
        end
    end
    return true
end

onlinePointsEvent:interval(10000)
onlinePointsEvent:register()
 
Last edited:
this works to give players "x" ammount of points after "x" time they spend online right?
btw are you sure this timeMax = (20000), -- 1 hour, is 1 hour?

also need to know, there's a chance to recieve website points instead crystal coins? as long i see player receive crystal coins as points <<ItemType(config.itemPoint)>>

bloody sunday on zanarkand

84cf6c17f2.png


84cfaf2a5f.png
 
Last edited by a moderator:
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Has resivido ' .. config.pointsPerTime .. ' ' .. ItemType(config.itemPoint):getName() .. '.')
mejor asi, por el bien de la buena ortografía ! <3
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Has recibido ' .. config.pointsPerTime .. ' ' .. ItemType(config.itemPoint):getName() .. '.')
Buen script y me sirvió mucho, sigue así !
 
mejor asi, por el bien de la buena ortografía ! <3

Buen script y me sirvió mucho, sigue así !
Gracias por la corrección! la verdad creando script no me da tiempo de la ortografía
Thank you for the correction!
 
Last edited:
Last edited by a moderator:
tfs 1.2 please?
Post automatically merged:

Hi everyone, this script I had done a long time ago, but it really needed an improvement and maybe move it to Revscript.

data/scripts/gainpoinperhour.lua
Lua:
local config = {
    storage = 20000,
    pointItemId = 2160,
    pointsPerHour = 1,
    checkDuplicateIps = false
}

local onlinePointsEvent = GlobalEvent("GainPointPerHour")

function onlinePointsEvent.onThink(interval)
    local players = Game.getPlayers()
    if #players == 0 then
        return true
    end

    local checkIp = {}
    for _, player in pairs(players) do
        local ip = player:getIp()
        if ip ~= 0 and (not config.checkDuplicateIps or not checkIp[ip]) then
            checkIp[ip] = true
            local seconds = math.max(0, player:getStorageValue(config.storage))
            if seconds >= 3600 then
                player:setStorageValue(config.storage, 0)
                local item = player:addItem(config.pointItemId, config.pointsPerHour)
                if item then
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("You have received %d %s for being online for an hour.", config.pointsPerHour, item:getName()))
                end
                return true
            end
            player:setStorageValue(config.storage, seconds +math.ceil(interval/1000))
        end
    end
    return true
end

onlinePointsEvent:interval(10000)
onlinePointsEvent:register()

please could you convert it to tfs 1.2
 
Last edited:
Back
Top