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

Good Time Event - TFS 0.4 - 8.6

hanzoha

New Member
Joined
May 8, 2016
Messages
87
Reaction score
2
Hello guys! I found a mod that lets you have a double exp event every day for an hour. Everything works fine but I want to know if it's possible to add a message before the event starts, like: "Double exp starting in 5 minutes... starting in 4, etc...

Here's the mod:

Code:
<?xml version='1.0' encoding='UTF-8'?>
<mod name='HappyHours' version='1.0'  enabled='yes'>

    <config name='happyHoursConf'>
        <![CDATA[
            HH_STORAGE = 2327 -- 
            HH_EXTRA_EXP_PERCENT = 10 
       
            DAYS = {
                ['Monday'] = {
                    {from = '16:00:00', to = '22:00:00'}
                },
                ['Tuesday'] = {
                    {from = '16:00:00', to = '22:00:00'}
                },
                ['Sunday'] = {
                    {from = '16:00:00', to = '22:00:00'}
                },
                ['Wednesday'] = {
                    {from = '16:00:00', to = '22:00:00'}
                },
                ['Thursday'] = {
                    {from = '16:00:00', to = '22:00:00'}
                },
                ['Friday'] = {
                    {from = '16:00:00', to = '22:00:00'}
                },
                ['Saturday'] = {
                    {from = '16:00:00', to = '22:00:00'}
                },
                ['Sunday'] = {
                    {from = '16:00:00', to = '22:00:00'}
                }
            }
       
        ]]>
    </config>

    <lib name='happyHoursLib'>
        <![CDATA[
            function doPlayerSetSkills(cid, value)
                for i = 0, 8 do
                    doPlayerSetRate(cid, i, value)
                end
            end

            function stopNewWorld()
                doSetStorage(HH_STORAGE, -1)

                for _, cid in ipairs(getPlayersOnline()) do
                    doPlayerSetSkills(cid, 1)
                end

                doBroadcastMessage('Good time event is over')
            end
        ]]>
    </lib>
    <globalevent name="happyHoursStop" interval="1000" event="script">
        <![CDATA[
            domodlib('happyHoursConf')
            domodlib('happyHoursLib')

            local daysOpen = {}
       
            for k, v in pairs(DAYS) do
                table.insert(daysOpen, k)
            end
       
            function onThink(interval)
                if isInArray(daysOpen, os.date('%A')) then
                    for k, v in pairs(DAYS[os.date('%A')]) do
                        if isInArray(v.to, os.date('%X', os.time())) then
                                stopNewWorld()
                            break
                        end
                    end
                end
                return true
            end
        ]]>
    </globalevent>
    <globalevent name="happyHoursStart" interval="1000" event="script">
        <![CDATA[
            domodlib('happyHoursConf')
            domodlib('happyHoursLib')

            local daysOpen = {}
       
            for k, v in pairs(DAYS) do
                table.insert(daysOpen, k)
            end
       
            function onThink(cid, interval)
                if isInArray(daysOpen, os.date('%A')) then
                    for _, d in pairs(DAYS[os.date('%A')]) do
                        if isInArray(d.from, os.date('%X', os.time())) then
                            local newRate = 1 + (HH_EXTRA_EXP_PERCENT/100)

                            for _, cid in ipairs(getPlayersOnline()) do
                                doPlayerSetSkills(cid, newRate)
                            end
                       
                            doSetStorage(HH_STORAGE, 1)
                       
                            doBroadcastMessage('Double exp event is on.', MESSAGE_STATUS_WARNING)
                            break
                        end
                    end
                end
                return true
            end
        ]]>
    </globalevent>

    <event type='login' name='happyHoursLogin' event='script'>
        <![CDATA[
            domodlib('happyHoursConf')
            domodlib('happyHoursLib')

            function onLogin(cid)
                if getStorage(HH_STORAGE) == 1 then
                    local newRate = 1 + (HH_EXTRA_EXP_PERCENT/100)
                    doPlayerSetSkills(cid, newRate)
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'Hurry up, double exp is on.')
                else
                    doPlayerSetSkills(cid, 1)               
                end
                return true
            end
        ]]>
    </event>
</mod>
 
Would it be possible for you to write an explicit example?

BTW, does someone knows where can I find a proper way to learn how to code scripts?
Thanks!
 
not sure how to do timed global scripts but
Code:
<globalevent name="bonusXpBroadcast" interval="5000" event="script">
script here
</globalevent>
just change that to something and check for time left to the times specified in days table
essentially just take the globalevent script you already have and make it check time left and broadcast it
 
Back
Top