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

[TFS 1.3] Online Premium Points

lico69

New Member
Joined
Mar 11, 2011
Messages
38
Reaction score
1
Hello, I ask your help for a simple system of each one hour online the player should receive 1 point. Every 12 points (12 hours), through a talkaction he will buy 1 day of premium time. I already did some of the code and I need help for the rest, thanks!

Code:
local event = {}
local timeOnline = 60 * 60 * 1000

function addPremiumPoint(cid)
    local player = Player(cid)
    if player then
        local time = player:getStorageValue(25230)
        player:setStorageValue(25230, (time + 1))
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[FREE VIP] You have been online for an hour and have earned 1 premium point. For every 12 premium points you gain 1 VIP Day.")
        event[cid] = addEvent(addPremiumPoint, timeOnline, cid)
        return
    end
    event[cid] = nil
end

function onLogin(player)
    if player:getStorageValue(25230) == -1 then
      player:setStorageValue(25230, 0)
    end
   
    local cid = player:getId()
    if not event[cid] then
        event[cid] = addEvent(addPremiumPoint, timeOnline, cid)
    end
    return true
end
 
Solution
You get the picture:
Code:
local event = {}
local timeOnline = 60 * 60 * 1000

function addPremiumPoint(cid)
    local player = player(id)
    if not player then
        event[id] = nil
        return
    end
  
    player:setStorageValue(25230, math.max(1, player:getStorageValue(25230)) + 1)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[FREE VIP] You have been online for an hour and have earned 1 premium point. For every 12 premium points you gain 1 VIP Day.")
    event[id] = addEvent(addPremiumPoint, timeOnline, id)
end

function onLogin(player)
    if player:getStorageValue(25230) == -1 then
        player:setStorageValue(25230, 0)
    end

    local id = player:getId()
    if event[id] == nil then
        event[id] =...
You get the picture:
Code:
local event = {}
local timeOnline = 60 * 60 * 1000

function addPremiumPoint(cid)
    local player = player(id)
    if not player then
        event[id] = nil
        return
    end
  
    player:setStorageValue(25230, math.max(1, player:getStorageValue(25230)) + 1)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[FREE VIP] You have been online for an hour and have earned 1 premium point. For every 12 premium points you gain 1 VIP Day.")
    event[id] = addEvent(addPremiumPoint, timeOnline, id)
end

function onLogin(player)
    if player:getStorageValue(25230) == -1 then
        player:setStorageValue(25230, 0)
    end

    local id = player:getId()
    if event[id] == nil then
        event[id] = addEvent(addPremiumPoint, timeOnline, id)
    end

    return true
end

function onSay(player, words, param)
    local storage = player:getStorageValue(25230)
    if storage >= 12 then
        local days = storage / 12
        player:addPremiumDays(days)
        player:setStorageValue(25230, 0)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have bought " .. days .." days of premium account for ".. storage .." points.")
    end
    return false
end
 
Solution
Thank you for your help. I have a question too, this value would be fixed every 12 points add 1 premium day, imagine that the player has 25 points, he would need to use talkaction only once to get two premium days and only one point left.
 
You get the picture:
Code:
local event = {}
local timeOnline = 60 * 60 * 1000

function addPremiumPoint(cid)
    local player = player(id)
    if not player then
        event[id] = nil
        return
    end
 
    player:setStorageValue(25230, math.max(1, player:getStorageValue(25230)) + 1)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[FREE VIP] You have been online for an hour and have earned 1 premium point. For every 12 premium points you gain 1 VIP Day.")
    event[id] = addEvent(addPremiumPoint, timeOnline, id)
end

function onLogin(player)
    if player:getStorageValue(25230) == -1 then
        player:setStorageValue(25230, 0)
    end

    local id = player:getId()
    if event[id] == nil then
        event[id] = addEvent(addPremiumPoint, timeOnline, id)
    end

    return true
end

function onSay(player, words, param)
    local storage = player:getStorageValue(25230)
    if storage >= 12 then
        local days = storage / 12
        player:addPremiumDays(days)
        player:setStorageValue(25230, 0)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have bought " .. days .." days of premium account for ".. storage .." points.")
    end
    return false
end

for tfs 1.2 please?
 
Is this a globalevents? How should I call the script in my globalevents.xml?
And what would a talkaction be like for the purchase of just one day of premium?
 
Back
Top