The scheduled world events package provides the following functionality:
- Schedule events to occur at specific times
- Schedule events to end at specific times
- Reward player participation daily
- Integration with the Notifications Package
- Pre-wired for leaderboards
- Pre-wired for challenges and activities
To get started:
- Drop the User Scheduled World Events template on the User template
- Drop the Scheduled World Events Controller in the world
- Drop the Scheduled World Events Example in the world
What you’ll have now is an event scheduled to run at 12:00 in-game time, and end at 1:00 in-game time. The event rewards participation once for entering the trigger.
The events controller keeps track of what events have run, which events are running, and which events are upcoming. The events controller has the following properties:
- AnnouncementSound - Specific the sound to play when an announcement is upcoming, ended, or started.
- StartingSoonAnnouncement - If the notifications package is installed, this message will be Shouted to all users when an event is starting soon
- OnEvent - The OnEvent event is fired when any event is upcoming, started, or ended
The event script defines the generic properties of an event. It’s also responsible for tracking what users have participated in the event during the in-game day.
The following properties are available:
- Name - This property is used to identify the event in XP Events
- Location - Where the event occurs in the game world - this isn’t used directly in the package, but can be used for minimaps, world maps, compasses, etc.
- Start Time/End Time - Specify the start/end time of the event
- onRun/onEnd/onUpcoming Events - Fired when an event is run, ended, or upcoming. Typically hooked into by world scripts to run some sort of interactive event
- onParticipation Event - This event is fired when a player successfully participates in the event
- Messages - All properties in the “messages” group provide integrations with the Notifications package, and will shout the corresponding messages at their corresponding time
The Scheduled World Events package isn’t responsible for actual interactive events - those have to be implemented manually. Fortunately, it’s very easy to do.
The procedure of running an event is simple. When an event starts, the
onRun event is fired with a reference to the event script. Your event should hold a reference to the event, to use later.
function ExampleEvent:HandleRun(event) self.event = event end
At any time, you can reward participation to a player by calling the
RewardParticipation method on the event. For example, in the example event from the package, the following code is run when the player enters a trigger:
function ExampleEvent:HandleTriggerEnter(player) if not self.event then return end self.event:RewardParticipation(player) end
When this method is called, the event will track which players have already participated during the in-game day. In addition, it will Shout the participation message to the associated user, add 1 to the events-participated leaderboard, add 1 to the events-participated-weekly leaderboard, and fire the event XP Event with the name as defined on the script.
We should hook into the stop event handler as well so we can un-assign the event when the event is finished
function ExampleEvent:HandleEnd(event) self.event = nil end