RevScript 1 Punto por hora ( TC, Tournament..)

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Hola a todos,

Aquí les dejo un script que utilizamos en Hellgrave para ganar 1 punto de TC cada hora a cada jugador en linea:

El Script se pondrá en data/scripts/globalevents o data/scripts/ carpeta que deseáis.

El script funciona de la siguiente manera:
- pointItemId = Item ID Del item ( en el caso 24774 es el tibia coin )
- pointsPerHour = Puntos por hora, es decir cuantos items dara 1, 2, 3...
- Mas abajo veremos un 3600, corresponde a los segundos = 1 hora, si deseamos 30 minutos pondremos 1800.


Código:
local config = {
    storage = 20000,
    pointItemId = 24774,
    pointsPerHour = 1,
    checkDuplicateIps = true
}

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_INFO_DESCR, "You received 1 Hellgrave Coin because you play 1 hour.")
                end
                return true
            end
            player:setStorageValue(config.storage, seconds +math.ceil(interval/1000))
        end
    end
    return true
end

onlinePointsEvent:interval(10000)
onlinePointsEvent:register()
 
Arriba