How to create zones that will be activated depending on time

Deazer

Head Developer
Staff member
Path: gameserver\data\zone
Format: XML, CronTab

And so let's start what it is! This system is designed to implement many ideas when implementing in-game events. As an example, at a certain time, a zone with a pvp flag or any other turns on and spawn mobs in this zone, or simply activate the zone. As an example, a more complex event will be given - disable peaceful zones in Gludio and enable PvP zones and populate it with mobs for the period of activity of this zone, and at the same time make an announcement of the launch of the zone and its collapse. In simple words, we activate the zone, spawn mobs using the cron timer and also use it to deactivate zones and spawn.

And so we went with the simplest option:
In this variant, we activate the pvp zone of the baium zone at 19:00 and turn it off at 20:00, while inside the zone we spawn [cron_spawn] a group from data/spawn, we also make an announcement about turning the zone on and off. Now we consider in detail:
name = "[baium_epic_fun]" - the very zone we work with. IMPORTANT * zone names must not be the same!
<set name = "enabled" val = "false" /> - in our example, the zone is disabled by default and is enabled only by timer.
<set name = "cronZoneEnablePattern" val = "0 19 * * *" /> - the parameter is responsible for activating the zone at the time we need. CronTab format - how to compose it https://crontab.guru/
<set name = "cronZoneDisablePattern" val = "0 20 * * *" /> - the parameter is responsible for deactivating the zone at the time we need. CronTab format - how to compose it https://crontab.guru/
<set name = "cronZoneEnableBroadcastSpawnEvent" val = "[cron_spawn]" /> - Spawn list that will be activated when the zone is enabled event_name = "[cron_spawn]" or any other name
<set name = "cronZoneDisableBroadcastDespawnEvent" val = "[cron_spawn]" /> - Spawn list that will be deactivated when the zone is enabled event_name = "[cron_spawn]" or any other name
<set name = "cronZoneEnableAnnounceCustomMessage" val = "voicedcommandhandlers.Debug.Enabled" /> - The announcement that will occur upon activation. Be in data/strings
<set name = "cronZoneDisableAnnounceCustomMessage" val = "voicedcommandhandlers.Debug.Disabled" /> - Announcement that will occur upon deactivation. Be in data/strings
IMPORTANT * The same is not necessary in the zone to use all parameters, let's say you do not specify the announcement - it will not be. Suppose you do not specify a spawn in the zone - it will not be there. It is not necessary to specify this, either cronZoneEnablePattern or cronZoneDisablePattern are required

XML:
    <zone name="[baium_epic_fun]" type="fun" >
        <set name="enabled" val="false" />
        <set name="cronZoneEnablePattern" val="0 19 * * *" />
        <set name="cronZoneDisablePattern" val="0 20 * * *" />
        <set name="cronZoneEnableBroadcastSpawnEvent" val="[cron_spawn]" />
        <set name="cronZoneDisableBroadcastDespawnEvent" val="[cron_spawn]" />
        <set name="cronZoneEnableAnnounceCustomMessage" val="voicedcommandhandlers.Debug.Enabled" />
        <set name="cronZoneDisableAnnounceCustomMessage" val="voicedcommandhandlers.Debug.Disabled" />
        <polygon>
            <coords loc="116616 17576 10032 10232" />
            <coords loc="117064 16552 10032 10232" />
            <coords loc="117032 15592 10032 10232" />
            <coords loc="116664 14632 10032 10232" />
            <coords loc="116024 14008 10032 10232" />
            <coords loc="115128 13640 10032 10232" />
            <coords loc="114136 13624 10032 10232" />
            <coords loc="113256 13992 10032 10232" />
            <coords loc="112568 14664 10032 10232" />
            <coords loc="112216 15592 10032 10232" />
            <coords loc="112216 16552 10032 10232" />
            <coords loc="112600 17432 10032 10232" />
            <coords loc="113288 18120 10032 10232" />
            <coords loc="114152 18472 10032 10232" />
            <coords loc="115144 18488 10032 10232" />
            <coords loc="116152 18024 10032 10232" />
        </polygon>
    </zone>

The spawn example itself:

XML:
<spawn name="[custom_spawn]" event_name="[cron_spawn]">
    <npc id="20001" count="1" respawn="60" pos="114856 16616 10080 38521" />
    <npc id="20001" count="1" respawn="60" pos="114636 16443 10080 40014" />
    <npc id="20001" count="1" respawn="60" pos="114504 16168 10080 46038" />
    <npc id="20001" count="1" respawn="60" pos="114520 16040 10080 50449" />
    <npc id="20001" count="1" respawn="60" pos="114616 15944 10080 3355" />
    <npc id="20001" count="1" respawn="60" pos="114877 16012 10080 1875" />
    <npc id="20001" count="1" respawn="60" pos="115024 16105 10080 7805" />
    <npc id="20001" count="1" respawn="60" pos="115278 16421 10080 5636" />
    <npc id="20001" count="1" respawn="60" pos="115416 16200 10080 46871" />
    <npc id="20001" count="1" respawn="60" pos="115328 16074 10080 40959" />
</spawn>

2) Now we are considering a more difficult option, fasten your seat belts. We are doing a complete deactivation of peaceful zones in the city of Gludio, making it a PvP zone, despawning peaceful NPCs and spawning Mobs. Then we turn on the peaceful zone, turn off the mobs and spawn peaceful NPCs.
And all of this will start at 16:00 and end at 16:30.
In the city of Gludio there are 2 zones that draw it [guldiocastle_town_peace1] and [guldiocastle_town_peace2] and so we turn them off for the period of our event and turn them off after
<set name = "cronZoneDisablePattern" val = "0 16 * * *" /> - turn off the peace zone [guldiocastle_town_peace1] and [guldiocastle_town_peace2]
<set name = "cronZoneEnablePattern" val = "31 16 * * *" /> - enable peace zones [guldiocastle_town_peace1] and [guldiocastle_town_peace2]
Despawn all peaceful NPCs - and then the pirouettes begin, we need to collect all peaceful NPCs into one group and assign it event_name = "[gludio_peace_npc]" in the spawn
At the end, we announce that the event is over - в data/strings add the line zone_gludio_pvp.Disable=The Town of Gludo has become peaceful!
Example:
XML:
<zone name="[guldiocastle_town_peace1]" type="peace_zone" >
        <set name="cronZoneDisablePattern" val="0 16 * * *" />
        <set name="cronZoneEnablePattern" val="31 16 * * *" />
        <set name="cronZoneDisableBroadcastDespawnEvent" val="[gludio_peace_npc]" />
        <set name="cronZoneDisableAnnounceCustomMessage" val="zone_gludio_pvp.Disable" />
        <polygon>
            <coords loc="-11998 123905 -3245 -2745" />
            <coords loc="-12880 126192 -3245 -2745" />
            <coords loc="-13928 126485 -3245 -2745" />
            <coords loc="-14408 126484 -3245 -2745" />
            <coords loc="-15239 126174 -3245 -2745" />
            <coords loc="-16120 125367 -3245 -2745" />
            <coords loc="-16551 124468 -3245 -2745" />
            <coords loc="-16550 123911 -3245 -2745" />
            <coords loc="-16509 123323 -3245 -2745" />
            <coords loc="-14638 122381 -3245 -2745" />
            <coords loc="-12022 122270 -3245 -2745" />
        </polygon>
    </zone>
    <zone name="[guldiocastle_town_peace2]" type="peace_zone" >
        <set name="cronZoneDisablePattern" val="0 16 * * *" />
        <set name="cronZoneEnablePattern" val="30 16 * * *" />
        <polygon>
            <coords loc="-14956 121115 -3156 -2656" />
            <coords loc="-12670 121093 -3156 -2656" />
            <coords loc="-12021 121755 -3156 -2656" />
            <coords loc="-12019 123005 -3156 -2656" />
            <coords loc="-15400 123009 -3156 -2656" />
        </polygon>
    </zone>

Now we need to activate the PvP zone instead of the disabled peaceful zones:
<set name = "cronZoneEnablePattern" val = "1 16 * * *" /> - enable pvp zones [guldiocastle_town_pvp1] and [guldiocastle_town_pvp2]
<set name = "cronZoneEnablePattern" val = "31 16 * * *" /> - enable peaceful zones [guldiocastle_town_pvp1] and [guldiocastle_town_pvp2]
Spawn all mobs - create our own group with mobs to spawn event_name = "[gludio_pvp_mobs]"
We announce that the event has begun - в data/strings add the line zone_gludio_pvp.Enable=The city of Gludo has become unsafe! Fight monsters and players for a reward

XML:
<zone name="[guldiocastle_town_pvp1]" type="battle_zone" >
        <set name="cronZoneEnablePattern" val="1 16 * * *" />
        <set name="cronZoneDisablePattern" val="30 16 * * *" />
        <set name="cronZoneEnableBroadcastSpawnEvent" val="[gludio_pvp_mobs]" />
        <set name="cronZoneEnableAnnounceCustomMessage" val="zone_gludio_pvp.Enable" />
        <polygon>
            <coords loc="-11998 123905 -3245 -2745" />
            <coords loc="-12880 126192 -3245 -2745" />
            <coords loc="-13928 126485 -3245 -2745" />
            <coords loc="-14408 126484 -3245 -2745" />
            <coords loc="-15239 126174 -3245 -2745" />
            <coords loc="-16120 125367 -3245 -2745" />
            <coords loc="-16551 124468 -3245 -2745" />
            <coords loc="-16550 123911 -3245 -2745" />
            <coords loc="-16509 123323 -3245 -2745" />
            <coords loc="-14638 122381 -3245 -2745" />
            <coords loc="-12022 122270 -3245 -2745" />
        </polygon>
    </zone>
    <zone name="[guldiocastle_town_pvp2]" type="battle_zone" >
        <set name="cronZoneEnablePattern" val="1 16 * * *" />
        <set name="cronZoneDisablePattern" val="30 16 * * *" />
        <polygon>
            <coords loc="-14956 121115 -3156 -2656" />
            <coords loc="-12670 121093 -3156 -2656" />
            <coords loc="-12021 121755 -3156 -2656" />
            <coords loc="-12019 123005 -3156 -2656" />
            <coords loc="-15400 123009 -3156 -2656" />
        </polygon>
    </zone>

Now the whole set of parameters:

"cronZoneEnablePattern" - the cron zone is turned on. Example <set name = "cronZoneEnablePattern" val = "0 18 * * *" />
"cronZoneEnableBroadcastSpawnEvent" - event to spawn upon activation <set name = "cronZoneEnableBroadcastSpawnEvent" val = "[gludio_peace_npc]" />
"cronZoneEnableBroadcastDespawnEvent" - what event to despawn upon activation <set name = "cronZoneEnableBroadcastSpawnEvent" val = "[gludio_pvp_mobs]" />
"cronZoneEnableAnnounceCustomMessage" - what we announce when the zone is turned on <set name="cronZoneEnableAnnounceCustomMessage" val="zone_gludio_pvp.Enable" />

"cronZoneDisablePattern" - when the cron zone is turned off. Example <set name="cronZoneEnablePattern" val="0 19 * * *" />
"cronZoneDisableBroadcastSpawnEvent" - what event to despawn when the zone is disabled <set name="cronZoneEnableBroadcastSpawnEvent" val="[gludio_peace_npc]" />
"cronZoneDisableBroadcastDespawnEvent" - what event to despawn by disabling the zone <set name="cronZoneEnableBroadcastSpawnEvent" val="[gludio_pvp_mobs]" />
"cronZoneDisableAnnounceCustomMessage" - that we are announcing off the zone <set name="cronZoneEnableAnnounceCustomMessage" val="zone_gludio_pvp.Disable" />

The whole system is limited only by your imagination, with the help of this tool you can do any game events, activate zones and spawn, rotate zones in your own way and whatever comes to your mind.
 
Last edited:
In Gludio example, Gludio peace mobs will never be spawned again because there's no cronZoneEnableBroadcastSpawnEvent in that zone declaration, right?
 
Last edited:
announce parameter is optional and after spawning peaceful NPCs, you need to spawn them at the end event
 
What I mean is that example is wrong.
You have to spawn and despawn in both zones.
Correct me if I'm wrong please.

XML:
<zone name="[guldiocastle_town_peace1]" type="peace_zone" >
        <set name="cronZoneDisablePattern" val="0 16 * * *" />
        <set name="cronZoneEnablePattern" val="31 16 * * *" />
        <set name="cronZoneDisableBroadcastDespawnEvent" val="[gludio_peace_npc]" />
        <!-- HERE: If you don't add Enable Broadcast Spawn Event, peaceful NPCs won't appear anymore -->
        <!--<ADD>-->
        <set name="cronZoneEnableBroadcastSpawnEvent" val="[gludio_peace_npc]" />       
        <!--</ADD>-->
        <set name="cronZoneDisableAnnounceCustomMessage" val="zone_gludio_pvp.Disable" />
 
before despawn old zones, after start new zones then on event finish enable old zones and peace spawn
 
I trying to create a fixed spawn three times, first time Friday, second spawn at saturday and last spawn at sunday, look

"0 20 * * Sun" i guess means 8pm every Sunday, but does not work and i try "0 20 * * 7", the same, 7 is Sunday but dont work, how can i make this, is really possible?
 
The system is cool, but if you need to restart or restart the server during the day, it won't start anymore. only if it is the automatic restart programmed in the server.prop
 
Is it possible to add an option in the admin menu for activating the zone?
For example, in the admin menu.
Custom Event [1]: Start / Stop [baium_epic_fun]
Custom Event [2]: Start / Stop [aq_epic_fun]
Custom Event [3]: Start / Stop [valaks_epic_fun]
It will be very useful for manually activating the zone events.
 
Back
Top