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

Script for online time.

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
Hello Guys.

I need (please xD) a script that every 1 hour player are online he wins a premium point on gesior (that points used to buy itens on site)

So if player stays 24h online on the server, he will win 24 points -> each hour online = 1 premium point.

Ideas?
 
This is the support board, not request.
So to help you with this.. You can either use a check each hour after the player logged in, if the player is still online -> query to give 1 point etc
Another way (won't be 100%) would be to just use an onInterval set once again to one hour to give all players 1 point.
 
This is the support board, not request.
So to help you with this.. You can either use a check each hour after the player logged in, if the player is still online -> query to give 1 point etc
Another way (won't be 100%) would be to just use an onInterval set once again to one hour to give all players 1 point.
Ye, i already tought about this checker, but i dont know how to make a checker like:

Code:
Ifplayeronlinetime = 1hour then

Any ideas?
 
Ye, i already tought about this checker, but i dont know how to make a checker like:

Code:
Ifplayeronlinetime = 1hour then

Any ideas?

Well it depends on how you wanna code it.
If you are starting at login (the best way imo) then use addEvent(myFunction, player:getId()) then at that function try to compile the player userdata, if you can then add one point and then execute another addEvent function.
That way it will continue till the player is not online (the function will not be pushed out next hour, since the player does not exist).

If you are using the interval script then just iterate through all the players and add one point.
Another way (smarter) would be to store all the player ids / names in a global array to then compile the userdata from that, if it compiles then the player was online the last hour and gets the point.
 
My idea is like this.
You need to make script onLogin and onLogout
When login storage = 1 when logout storage = 0

..and globalevent every 1 hour
if storage = 1 then
execute query to add 1 point for all online players
Global event executes-
20 minutes after player logins-
40 minutes later global event executes, player doesn't have enough time online
20 minutes after player has been on for 1 hour and didn't receive any points.
palyer is disappointed and quits the server
 
I really dont know how to do the script, but i can help with some codes:

Code:
    local points = 1
    local aid = getPlayerAccountId(cid)
    local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id`= "..aid..";")

  if query:getDataInt("premium_points") > 0 then
  doAccountAddPoints(cid, points)
   return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "U win "..points.." for being 1  hour online!")
   end

EDIT: Lib funcion:

Code:
function doAccountAddPoints(cid, count)
        return db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end
 
Last edited:
Global event executes-
20 minutes after player logins-
40 minutes later global event executes, player doesn't have enough time online
20 minutes after player has been on for 1 hour and didn't receive any points.
palyer is disappointed and quits the server
Right after i writed idea i knew it was wrong after first reading and you just quoted it pfff xP

So you will need a counter that starts after you login and globalevent checker that check if you have on timer 1*60*60 seconds
 
Right after i writed idea i knew it was wrong after first reading and you just quoted it pfff xP

So you will need a counter that starts after you login and globalevent checker that check if you have on timer 1*60*60 seconds

I edited my last post with the lib function!

Ye, the thing is i dont know how to make this checkers XD

I will try do something.. if any1 got a idea, it will be very niceee
 
I think i just need to know how to make the code to check player online time.

Function GetPlayerOnlineTime or something like that exist on tfs 0.3.6 (8.6) ?
 
Hehe now im smartass.
See this its tested.

creaturescripts/creaturescripts.xml
Code:
<event type="think" name="addpointTimer" script="addpointTimer.lua" />
creaturescripts/addpointTimer.lua
Code:
function onThink(creature, interval)
    local player = Player(creature)
    local cid = Player(creature)
    if not Player(player) then
        return creature:unregisterEvent("addpointTimer")
    end
   
    local time = 10 -- time to add points change to 1*60*60 after you test it
    local count = 1 -- how many points to add

    if player:getStorageValue(455577) < os.time() then
        db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
        player:setStorageValue(455577, os.time() + time)
    end
    local remaining = math.ceil(player:getStorageValue(455577) - os.time())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, "Time before adding point: "..remaining..".") -- remove this line its for testing to see if it works
    return true
end
login.lua
..below
Code:
function onLogin(player)
..add
Code:
    local time = 10 -- time to add points set to 1*60*60 after you test it
            player:registerEvent("addpointTimer")
            player:setStorageValue(455577, os.time() + time)
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Every 1 hour online you will earn 1 point to sms shop.")
 
Hehe now im smartass.
See this its tested.

creaturescripts/creaturescripts.xml
Code:
<event type="think" name="addpointTimer" script="addpointTimer.lua" />
creaturescripts/addpointTimer.lua
Code:
function onThink(creature, interval)
    local player = Player(creature)
    local cid = Player(creature)
    if not Player(player) then
        return creature:unregisterEvent("addpointTimer")
    end

    local time = 10 -- time to add points change to 1*60*60 after you test it
    local count = 1 -- how many points to add

    if player:getStorageValue(455577) < os.time() then
        db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
        player:setStorageValue(455577, os.time() + time)
    end
    local remaining = math.ceil(player:getStorageValue(455577) - os.time())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, "Time before adding point: "..remaining..".") -- remove this line its for testing to see if it works
    return true
end
login.lua
..below
Code:
function onLogin(player)
..add
Code:
    local time = 10 -- time to add points set to 1*60*60 after you test it
            player:registerEvent("addpointTimer")
            player:setStorageValue(455577, os.time() + time)
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Every 1 hour online you will earn 1 point to sms shop.")

Let me test!

I will check the time (local time = 10) twice?

On login.lua and on addpointTimer.lua ?

And more, my login.lua does not have a
function onLogin(player)
 
Last edited:
First onLogin makes script run, else it will not run its only to start it and does nothing else.
Second script onThink counts..
show me your creaturescripts/scripts/login.lua
 
First onLogin makes script run, else it will not run its only to start it and does nothing else.
Second script onThink counts..
show me your creaturescripts/scripts/login.lua

login.lua
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)

if (getPlayerLastLoginSaved(cid) == 0) then
    doTeleportThing(cid, {x=24,y=2235,z=8})
end

if getPlayerStorageValue(cid, 19333) == -1 then
        setPlayerStorageValue(cid, 19333, 0)
elseif getPlayerStorageValue(cid, 19334) == -1 then
setPlayerStorageValue(cid, 19334, 0)
    end
   
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type {account} to manage your account and if you want to start over then type {cancel}.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type {account} to create an account or type {recover} to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "petKill")  registerCreatureEvent(cid, "loguthunt")  registerCreatureEvent(cid, "huntdeath")  registerCreatureEvent(cid, "killitem")  registerCreatureEvent(cid, "SkullAmulet")  registerCreatureEvent(cid, "SkullCheck")  registerCreatureEvent(cid, "magebomb")  registerCreatureEvent(cid, "perdereifeto")  registerCreatureEvent(cid, "RushOutfit")  registerCreatureEvent(cid, "pvpsystem")  registerCreatureEvent(cid, "RushAttack")  registerCreatureEvent(cid, "RushDead")  registerCreatureEvent(cid, "petDeath")  registerCreatureEvent(cid, "RushCombat")  registerCreatureEvent(cid, "ReflectSpellKnight")  registerCreatureEvent(cid, "ReflectSpellPally")  registerCreatureEvent(cid, "ReflectSpellMage")  registerCreatureEvent(cid, "TiraBattle")  registerCreatureEvent(cid, "PointSystem")  registerCreatureEvent(cid, "petSta")  registerCreatureEvent(cid, "deathBroadcast")  registerCreatureEvent(cid, "addons")  registerCreatureEvent(cid, "GuildMotd")
registerCreatureEvent(cid, "CombatDodge")
    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
        registerCreatureEvent(cid, "Reward")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
   
registerCreatureEvent(cid, "exppremium")
registerCreatureEvent(cid, "premiumaura")

registerCreatureEvent(cid, "advance")
registerCreatureEvent(cid, "FimVip")
registerCreatureEvent(cid, "SkullCheck")
    registerCreatureEvent(cid, "ReportBug")

registerCreatureEvent(cid, VipReceive)
registerCreatureEvent(cid, "PlayerKill")
    if (InitArenaScript ~= 0) then
    InitArenaScript = 1
    -- make arena rooms free
        for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end
    -- if he did not make full arena 1 he must start from zero
    if getPlayerStorageValue(cid, 42309) < 1 then
        for i = 42300, 42309 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 2 he must start from zero
    if getPlayerStorageValue(cid, 42319) < 1 then
        for i = 42310, 42319 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 3 he must start from zero
    if getPlayerStorageValue(cid, 42329) < 1 then
        for i = 42320, 42329 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
   
    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0) -- did not arena level
    end
    setPlayerStorageValue(cid, 42350, 0) -- time to kick 0
    setPlayerStorageValue(cid, 42352, 0) -- is not in arena 
return true
end
 
login.lua
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local time = 10 -- time to add points set to 1*60*60 after you test it
            registerCreatureEvent(cid, "addpointTimer")
            setPlayerStorageValue(cid, 455577, os.time() + time)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Every 1 hour online you will earn 1 point to sms shop.")

if (getPlayerLastLoginSaved(cid) == 0) then
    doTeleportThing(cid, {x=24,y=2235,z=8})
end

if getPlayerStorageValue(cid, 19333) == -1 then
        setPlayerStorageValue(cid, 19333, 0)
elseif getPlayerStorageValue(cid, 19334) == -1 then
setPlayerStorageValue(cid, 19334, 0)
    end
  
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type {account} to manage your account and if you want to start over then type {cancel}.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type {account} to create an account or type {recover} to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "petKill")  registerCreatureEvent(cid, "loguthunt")  registerCreatureEvent(cid, "huntdeath")  registerCreatureEvent(cid, "killitem")  registerCreatureEvent(cid, "SkullAmulet")  registerCreatureEvent(cid, "SkullCheck")  registerCreatureEvent(cid, "magebomb")  registerCreatureEvent(cid, "perdereifeto")  registerCreatureEvent(cid, "RushOutfit")  registerCreatureEvent(cid, "pvpsystem")  registerCreatureEvent(cid, "RushAttack")  registerCreatureEvent(cid, "RushDead")  registerCreatureEvent(cid, "petDeath")  registerCreatureEvent(cid, "RushCombat")  registerCreatureEvent(cid, "ReflectSpellKnight")  registerCreatureEvent(cid, "ReflectSpellPally")  registerCreatureEvent(cid, "ReflectSpellMage")  registerCreatureEvent(cid, "TiraBattle")  registerCreatureEvent(cid, "PointSystem")  registerCreatureEvent(cid, "petSta")  registerCreatureEvent(cid, "deathBroadcast")  registerCreatureEvent(cid, "addons")  registerCreatureEvent(cid, "GuildMotd")
registerCreatureEvent(cid, "CombatDodge")
    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
        registerCreatureEvent(cid, "Reward")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
  
registerCreatureEvent(cid, "exppremium")
registerCreatureEvent(cid, "premiumaura")

registerCreatureEvent(cid, "advance")
registerCreatureEvent(cid, "FimVip")
registerCreatureEvent(cid, "SkullCheck")
    registerCreatureEvent(cid, "ReportBug")

registerCreatureEvent(cid, VipReceive)
registerCreatureEvent(cid, "PlayerKill")
    if (InitArenaScript ~= 0) then
    InitArenaScript = 1
    -- make arena rooms free
        for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end
    -- if he did not make full arena 1 he must start from zero
    if getPlayerStorageValue(cid, 42309) < 1 then
        for i = 42300, 42309 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 2 he must start from zero
    if getPlayerStorageValue(cid, 42319) < 1 then
        for i = 42310, 42319 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 3 he must start from zero
    if getPlayerStorageValue(cid, 42329) < 1 then
        for i = 42320, 42329 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
  
    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0) -- did not arena level
    end
    setPlayerStorageValue(cid, 42350, 0) -- time to kick 0
    setPlayerStorageValue(cid, 42352, 0) -- is not in arena
return true
end
creaturescripts/addpointTimer.lua
Code:
function onThink(creature, interval)
    local cid = Player(creature)
    if not Player(cid) then
        return unregisterCreatureEvent(cid, "addpointTimer")
    end
  
    local time = 10 -- time to add points change to 1*60*60 after you test it
    local count = 1 -- how many points to add
  
    if getPlayerStorageValue(cid, 455577) < os.time() then
        --db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
        setPlayerStorageValue(cid, 455577, os.time() + time)
    end
    local remaining = math.ceil(getPlayerStorageValue(cid, 455577) - os.time())
    doPlayerSendDefaultCancel(cid, "Time before adding point: "..remaining..".") -- remove this line its for testing to see if it works
    return true
end
Why you didnt say your tfs version in thread title? ._.
I have nothing else to do than finding which functions are for you.
 
Hehe now im smartass.
See this its tested.

creaturescripts/creaturescripts.xml
Code:
<event type="think" name="addpointTimer" script="addpointTimer.lua" />
creaturescripts/addpointTimer.lua
Code:
function onThink(creature, interval)
    local player = Player(creature)
    local cid = Player(creature)
    if not Player(player) then
        return creature:unregisterEvent("addpointTimer")
    end
  
    local time = 10 -- time to add points change to 1*60*60 after you test it
    local count = 1 -- how many points to add

    if player:getStorageValue(455577) < os.time() then
        db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
        player:setStorageValue(455577, os.time() + time)
    end
    local remaining = math.ceil(player:getStorageValue(455577) - os.time())
    player:sendTextMessage(MESSAGE_STATUS_SMALL, "Time before adding point: "..remaining..".") -- remove this line its for testing to see if it works
    return true
end
login.lua
..below
Code:
function onLogin(player)
..add
Code:
    local time = 10 -- time to add points set to 1*60*60 after you test it
            player:registerEvent("addpointTimer")
            player:setStorageValue(455577, os.time() + time)
            player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Every 1 hour online you will earn 1 point to sms shop.")

The function onThink does not have the creature argument, it has the interval and lastExecution.
Why use Player(creature)? If you have the creature userdata use creature:getPlayer()
No ide why you make cid try to compile the userdata again, maybe you ment to use player:getId()?
Use if not player then .., no need to recompile the userdata here.
Decide if you wanna use creature or player xD If you wanna use creature then just use if not creature:isPlayer() then ...

What you actually have to do is as I said above, iterate through all the players that are online.
FYI. No globalevents has any creature userdata linked to it, since it only executes at certain times(interval, startup, shutdown etc etc).
 
login.lua
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local time = 10 -- time to add points set to 1*60*60 after you test it
            registerCreatureEvent(cid, "addpointTimer")
            setPlayerStorageValue(cid, 455577, os.time() + time)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Every 1 hour online you will earn 1 point to sms shop.")

if (getPlayerLastLoginSaved(cid) == 0) then
    doTeleportThing(cid, {x=24,y=2235,z=8})
end

if getPlayerStorageValue(cid, 19333) == -1 then
        setPlayerStorageValue(cid, 19333, 0)
elseif getPlayerStorageValue(cid, 19334) == -1 then
setPlayerStorageValue(cid, 19334, 0)
    end

    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type {account} to manage your account and if you want to start over then type {cancel}.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type {account} to create an account or type {recover} to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "petKill")  registerCreatureEvent(cid, "loguthunt")  registerCreatureEvent(cid, "huntdeath")  registerCreatureEvent(cid, "killitem")  registerCreatureEvent(cid, "SkullAmulet")  registerCreatureEvent(cid, "SkullCheck")  registerCreatureEvent(cid, "magebomb")  registerCreatureEvent(cid, "perdereifeto")  registerCreatureEvent(cid, "RushOutfit")  registerCreatureEvent(cid, "pvpsystem")  registerCreatureEvent(cid, "RushAttack")  registerCreatureEvent(cid, "RushDead")  registerCreatureEvent(cid, "petDeath")  registerCreatureEvent(cid, "RushCombat")  registerCreatureEvent(cid, "ReflectSpellKnight")  registerCreatureEvent(cid, "ReflectSpellPally")  registerCreatureEvent(cid, "ReflectSpellMage")  registerCreatureEvent(cid, "TiraBattle")  registerCreatureEvent(cid, "PointSystem")  registerCreatureEvent(cid, "petSta")  registerCreatureEvent(cid, "deathBroadcast")  registerCreatureEvent(cid, "addons")  registerCreatureEvent(cid, "GuildMotd")
registerCreatureEvent(cid, "CombatDodge")
    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
        registerCreatureEvent(cid, "Reward")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")

registerCreatureEvent(cid, "exppremium")
registerCreatureEvent(cid, "premiumaura")

registerCreatureEvent(cid, "advance")
registerCreatureEvent(cid, "FimVip")
registerCreatureEvent(cid, "SkullCheck")
    registerCreatureEvent(cid, "ReportBug")

registerCreatureEvent(cid, VipReceive)
registerCreatureEvent(cid, "PlayerKill")
    if (InitArenaScript ~= 0) then
    InitArenaScript = 1
    -- make arena rooms free
        for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end
    -- if he did not make full arena 1 he must start from zero
    if getPlayerStorageValue(cid, 42309) < 1 then
        for i = 42300, 42309 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 2 he must start from zero
    if getPlayerStorageValue(cid, 42319) < 1 then
        for i = 42310, 42319 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 3 he must start from zero
    if getPlayerStorageValue(cid, 42329) < 1 then
        for i = 42320, 42329 do
            setPlayerStorageValue(cid, i, 0)
        end
    end

    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0) -- did not arena level
    end
    setPlayerStorageValue(cid, 42350, 0) -- time to kick 0
    setPlayerStorageValue(cid, 42352, 0) -- is not in arena
return true
end
creaturescripts/addpointTimer.lua
Code:
function onThink(creature, interval)
    local cid = Player(creature)
    if not Player(cid) then
        return unregisterCreatureEvent(cid, "addpointTimer")
    end

    local time = 10 -- time to add points change to 1*60*60 after you test it
    local count = 1 -- how many points to add

    if getPlayerStorageValue(cid, 455577) < os.time() then
        --db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
        setPlayerStorageValue(cid, 455577, os.time() + time)
    end
    local remaining = math.ceil(getPlayerStorageValue(cid, 455577) - os.time())
    doPlayerSendDefaultCancel(cid, "Time before adding point: "..remaining..".") -- remove this line its for testing to see if it works
    return true
end
Why you didnt say your tfs version in thread title? ._.
I have nothing else to do than finding which functions are for you.

Sorry for not mention my tfs and ot version on main post, my mistake. I will test the script now!!

EDIT:

Got a error on console:

Code:
[29/07/2015 22:30:06] [Error - CreatureScript Interface]
[29/07/2015 22:30:06] data/creaturescripts/scripts/addpointTimer.lua:onThink
[29/07/2015 22:30:06] Description:
[29/07/2015 22:30:06] data/creaturescripts/scripts/addpointTimer.lua:2: attempt to call global 'Player' (a nil value)
[29/07/2015 22:30:06] stack traceback:
[29/07/2015 22:30:06]     data/creaturescripts/scripts/addpointTimer.lua:2: in function <data/creaturescripts/scripts/addpointTimer.lua:1>
 
The function onThink does not have the creature argument, it has the interval and lastExecution.
Why use Player(creature)? If you have the creature userdata use creature:getPlayer()
No ide why you make cid try to compile the userdata again, maybe you ment to use player:getId()?
Use if not player then .., no need to recompile the userdata here.
Decide if you wanna use creature or player xD If you wanna use creature then just use if not creature:isPlayer() then ...

What you actually have to do is as I said above, iterate through all the players that are online.
FYI. No globalevents has any creature userdata linked to it, since it only executes at certain times(interval, startup, shutdown etc etc).
You talk so much and you wont help.
This is the only way i could make it work, if i remove creature from onThink it is not working.

#edit
see this:
Code:
function onThink(interval)

    local time = 10 -- time to add points change to 1*60*60 after you test it
    local count = 1 -- how many points to add

    if getPlayerStorageValue(cid, 455577) < os.time() then
        --db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
        setPlayerStorageValue(cid, 455577, os.time() + time)
    end
    local remaining = math.ceil(getPlayerStorageValue(cid, 455577) - os.time())
    doPlayerSendDefaultCancel(cid, "Time before adding point: "..remaining..".") -- remove this line its for testing to see if it works
    return true
end
If the timer will work, only thing you have to do is to make db.query command work

What you actually have to do is as I said above, iterate through all the players that are online.
FYI. No globalevents has any creature userdata linked to it, since it only executes at certain times(interval, startup, shutdown etc etc).
This is too much complicated idea. You need checker to all online and what if someone log out? Script would be really long, onthink for each player is best idea.
 
Last edited:
You talk so much and you wont help.
This is the only way i could make it work, if i remove creature from onThink it is not working.

#edit
see this:
Code:
function onThink(interval)

    local time = 10 -- time to add points change to 1*60*60 after you test it
    local count = 1 -- how many points to add
 
    if getPlayerStorageValue(cid, 455577) < os.time() then
        --db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
        setPlayerStorageValue(cid, 455577, os.time() + time)
    end
    local remaining = math.ceil(getPlayerStorageValue(cid, 455577) - os.time())
    doPlayerSendDefaultCancel(cid, "Time before adding point: "..remaining..".") -- remove this line its for testing to see if it works
    return true
end
If the timer will work, only thing you have to do is to make db.query command work

New error:

Code:
[29/07/2015 22:40:23] [Error - CreatureScript Interface]
[29/07/2015 22:40:24] data/creaturescripts/scripts/addpointTimer.lua:onThink
[29/07/2015 22:40:24] Description:
[29/07/2015 22:40:24] data/creaturescripts/scripts/addpointTimer.lua:6: attempt to compare boolean with number
[29/07/2015 22:40:24] stack traceback:
[29/07/2015 22:40:24]    data/creaturescripts/scripts/addpointTimer.lua:6: in function <data/creaturescripts/scripts/addpointTimer.lua:1>

[29/07/2015 22:40:24] [Error - CreatureScript Interface]
[29/07/2015 22:40:24] data/creaturescripts/scripts/addpointTimer.lua:onThink
[29/07/2015 22:40:24] Description:
[29/07/2015 22:40:24] (luaGetCreatureStorage) Creature not found
 
Code:
[29/07/2015 22:40:23] [Error - CreatureScript Interface]
[29/07/2015 22:40:24] data/creaturescripts/scripts/addpointTimer.lua:onThink
[29/07/2015 22:40:24] Description:
[29/07/2015 22:40:24] data/creaturescripts/scripts/addpointTimer.lua:6: attempt to compare boolean with number
[29/07/2015 22:40:24] stack traceback:
[29/07/2015 22:40:24]    data/creaturescripts/scripts/addpointTimer.lua:6: in function <data/creaturescripts/scripts/addpointTimer.lua:1>

[29/07/2015 22:40:24] [Error - CreatureScript Interface]
[29/07/2015 22:40:24] data/creaturescripts/scripts/addpointTimer.lua:onThink
[29/07/2015 22:40:24] Description:
[29/07/2015 22:40:24] (luaGetCreatureStorage) Creature not found
Code:
function onThink(cid, interval)

    local time = 10 -- time to add points change to 1*60*60 after you test it
    local count = 1 -- how many points to add
  
    if getPlayerStorageValue(cid, 455577) < os.time() then
        --db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
        setPlayerStorageValue(cid, 455577, os.time() + time)
    end
    local remaining = math.ceil(getPlayerStorageValue(cid, 455577) - os.time())
    doPlayerSendDefaultCancel(cid, "Time before adding point: "..remaining..".") -- remove this line its for testing to see if it works
    return true
end
 
Back
Top