How to make live events?

Hello there my name is Steve, i have saw a coupe of people do live events such as the jailbreak && madcity one,etc how can i do it thought?

I have searched for it in the devforum although i dont understand it

And no i dont want the full script, i just wanna know how it actually functions/works

3 Likes

For these, you’d utilise os.time – a function that returns the seconds elapsed in UTC time since the UNIX epoch (January 1st 1970), if no arguments have been passed. If you do use a table as an argument, you can specify a specific point in time using dictionaries. Say you want to get the time until the beginning of Summer 2020, you’d use this:

local begin = os.time {month = 6; day = 1; year = 2020}

With this, you can constantly check if the current seconds returned from os.time, with no arguments passed, is equal or greater than the seconds assigned to the begin variable:

while true do
    if os.time() >= begin then
        print("Trigger Summer 2020 event")
        break
    end
    wait(1)
end

You can refer to this lua manual for more: Programming in Lua : 22.1

5 Likes

Thank you so much for the help, this will probably be helpful in like a special event or something!

And also,how do make it so theres a countdown // timer for it?,i’m sure its hard but is it possible?

You can use another function of the os library: os.time

Here’s a link to the page for the os library. Scroll down until you see os.date, if you want to get documentation on the function

os.date is like the opposite of os.time: with os.time, with a table as an argument passed with the day, month, year and et cetera, it’ll give you the amount of seconds until that time from the UNIX epoch, while with os.date given the amount of seconds until a certain time, you can get the date of that time.

Essentially, you’d get the target time and the current time, returned by os.time with no arguments passed, subtract them and use os.date on the subtracted time. os.date returns a table of the date and time of the given seconds (i.e. day, month, year, hours, minutes, seconds, etc.). Here’s how it should go:

local target = os.time {month = 6; day = 1; year = 2020}

while (target - os.time()) >= 0 do
    local date_time = os.date("!*t", target - os.time())
    local day = tostring((date_time.day - 1) < 10 and "0" .. (date_time.day - 1) or date_time.day - 1)
    local hours = tostring(date_time.hour < 10 and "0" .. date_time.hour or date_time.hour)
    local minutes = tostring(date_time.min < 10 and "0" .. date_time.min or date_time.min)
    local seconds = tostring(date_time.sec < 10 and "0" .. date_time.sec or date_time.sec)

    print(day .. " days, " .. hours .. " hours, " .. minutes .. " minutes, " .. seconds .. " seconds")
    wait(1)
end

"!*t" is supposed to be the format string for UTC time, meaning that the date and time will be returned in UTC time, and will be the same on all devices

2 Likes

Quick bump. I made a detailed tutorial on how to make a super simple Live Events system!
Check it out here!

2 Likes

Thank you so much, will check it out!

Will check the video out, thanks!