Live events for my game

Hello. I’m making a game that is almost complete. I’ve thought it’d be a great idea to add live events at pre-scheduled hours, across all servers, so I can keep the game fun and updated for the audience. An example of this is the Jailbreak volcano event, when this occurred a lot of players joined just to see the event happening live.

My question: What’s the best way to do this? I’ve thought of using os.time to check the time and day, so that when it reaches the hour the event happens. But now that MessagingService has been added, I’m not sure how I should do this.

Any ideas?

12 Likes

use os.Date and check the month / date have prescripted events like map changes when its christmass or halloween.

1 Like

He’s saying he wants to do this at certain times in a day - not at certain days in a year; but I suppose you could combine both of those for different things.

he still would be better off with os.date since os.time gives the seconds from the date that they started using time.

4 Likes

MessagingService is your best bet here - no need to deal with cross-server time desyncs, and no need to deal with the issues of HttpService based syncing.

I already made a simple API to make using it as easy as possible, here is an example for your needs:

Main Place Server Script:

local Manager = require(script.UniverseEvent)
local UEvent = Manager.new("LiveEvent")

UEvent.Event:Connect(function(name)
    if name == "ExampleEvent" then --whatever each event handler you want to be
       --you can do your live event/whatever here
   end
end)

Debug/Master Server:

local Manager = require(script.UniverseEvent)
local UEvent = Manager.new("LiveEvent")

local function StartEvent()
     UEvent:Fire("ExampleEvent")
end

--call StartEvent from admin commands/time loop/etc
13 Likes

How would you distinguish the master server from the main place server? How exactly does this work?

You could make each server have the ability to ‘start’ a place event via an admin command, but you need to make sure that only one server at a time can control place events if it is going to be time based (due to the event likely being sent many times over if each server sends an event on its own)

Its a quite difficult problem to solve, but I am working on an API to allow this to happen (coming soon™)

1 Like

Ah, Okay, I get it now, thanks for explaining it to me!

When the server starts I’d send a cross server message saying “Hey I’m the main server”. This server would tell every other server that “I designate the events”. Every other server would then be notified to “Ask main server for event”. In which they would subscribe to the Main servers topic. And the main server would send the event. Obviously if a main server is set no one else should become the main server. This should help with time based events. And if you were to manually set an event on another server. You could just overwrite the main server and demote him to listen instead. Which means the server you fired your admin command on would become the new main server. Likewise when the main server shutsdown he/she should also get demoted.

2 Likes

I think messaging service is overkill here. If one server has the event a minute before the next, what harm will come of it? The point of these events is to give people a reason to visit the server and see the event unfold (and hopefully bump the game up to the front page in the process). I would go with os.date. Messaging service just adds more places for things to go wrong.

2 Likes

You’re not wrong, but some implementations may require the messaging service. If the event is completely local and other servers are irrelevant then I can agree. But I think you’ve only considered your own use case here.

2 Likes