• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Premium Scroll

marcos16

Falkhonn
Joined
May 4, 2012
Messages
224
Reaction score
1
I'm using this mod for players to buy premium. But some people complain that the premium lasts 12 hr / 15 hr. And it does not last 24 hours. Could anyone help?

XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Buy premium command" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="buypremium_config"><![CDATA[
        config = {
            days = 1,
            cost = 1,
            maxDays = 360
        }
    ]]></config>
    <talkaction words="!buyvip; !pacc" event="buffer"><![CDATA[
        domodlib('buypremium_config')
        if(getPlayerPremiumDays(cid) > config.maxDays) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have reached your maximum VIP limit.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            return
        end
        if (not doPlayerRemoveItem(cid, 10571, 1)) then
            doPlayerSendCancel(cid, "You do not have vip coin.")
            return
        end
        doPlayerAddPremiumDays(cid, config.days)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought ".. config.days .." VIP day..")
    ]]></talkaction>
</mod>
 
Solution
If you are 10 AM on day 0, and you buy prem on this script, it will last until day 1. So 14 hours later you will loose prem.
Your database probably store premium time as days instead of a seconds timestamp.

Inaccurate quick fix:
Replace:
LUA:
doPlayerAddPremiumDays(cid, config.days)
With this:
LUA:
doPlayerAddPremiumDays(cid, config.days + 1)

When they buy 1 day of prem, they will get something between 1-2 days. Ensuring they at least got a day worth of prem.
If they buy 10 days, they will potentially get 10-11 days.

If you wanted to ensure more accurate durations (without source/db modifications), add a storage value that stores os.time() + days in seconds.
And add a globalevent/login script that will check if duration is...
I'm using this mod for players to buy premium. But some people complain that the premium lasts 12 hr / 15 hr. And it does not last 24 hours. Could anyone help?

XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Buy premium command" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
    <config name="buypremium_config"><![CDATA[
        config = {
            days = 1,
            cost = 1,
            maxDays = 360
        }
    ]]></config>
    <talkaction words="!buyvip; !pacc" event="buffer"><![CDATA[
        domodlib('buypremium_config')
        if(getPlayerPremiumDays(cid) > config.maxDays) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have reached your maximum VIP limit.")
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            return
        end
        if (not doPlayerRemoveItem(cid, 10571, 1)) then
            doPlayerSendCancel(cid, "You do not have vip coin.")
            return
        end
        doPlayerAddPremiumDays(cid, config.days)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought ".. config.days .." VIP day..")
    ]]></talkaction>
</mod>

At what times do they use the item?
At what times do they expire?

Most likely you have a daily restart? Where the days are removed.
So if they use the item at ex 00:00 and you have a restart at 10:00 then they would lose 1 day in 10h.
 
If you are 10 AM on day 0, and you buy prem on this script, it will last until day 1. So 14 hours later you will loose prem.
Your database probably store premium time as days instead of a seconds timestamp.

Inaccurate quick fix:
Replace:
LUA:
doPlayerAddPremiumDays(cid, config.days)
With this:
LUA:
doPlayerAddPremiumDays(cid, config.days + 1)

When they buy 1 day of prem, they will get something between 1-2 days. Ensuring they at least got a day worth of prem.
If they buy 10 days, they will potentially get 10-11 days.

If you wanted to ensure more accurate durations (without source/db modifications), add a storage value that stores os.time() + days in seconds.
And add a globalevent/login script that will check if duration is over by comparing previously stored storagevalue against current time, and remove the last day of prem once that occurs.
 
Solution

Similar threads

Back
Top