Jump to content
The Inbetweeners Movie (2011) has won the movie voting! Vote for the next movie now https://warzone.gg/movievoting
Movie Night Movie Night: The Inbetweeners Movie (2011) - https://warzone.gg/movienightinfo?id=104
Game Night Game Night: CS:GO Strat Roulette (Counter Strike : Global Offensive ) - https://warzone.gg/gamenightinfo?id=53
Server Maintenance Successfully Completed
Sign in to follow this  
  • entries
  • comments
  • views

Automating Movie Nights

Sign in to follow this  


Over the past month, I've been working at automating the movie night events, so a human never needs to do anything, except one thing once every 6 months.

Phase 1: Automation of the Server

This was the first logical step. To do this, we have a separate movie night server with a module that does the following:

  • Only allows users to go in one theater, Public Theater #1
  • Disables unneeded things like Popcorn, fists and drug dealers
  • Disabling Text Hats
  • Disabling trails
  • Checks every 60 seconds to see if:
    • In 10 minutes, is their an event coming up?
    • If not, check again in 60 seconds
    • If so, get the information for such an event.
    • Remove the server password.
    • Allow users to join the server.
    • Wait 600 seconds and start playing trailers etc for 10 minutes.
    • Queue the movie
    • Wait for the movie to end and kick all players and set a password on the server.
    • Wait 1 week and repeat the process.

The start and end times of movie night events are stored in UNIX timestamps. A unix timestamp looks something like this: 1517142840 - To you that is probably a bunch of random numbers, however this is in fact the number of seconds since the 1st of Jan 1970. Unix timestamps are very easy to work with when calculating time. If you want to take a timestamp for now and add 2 hours to it, you can simply do:

$time = time();
$time = $time + (2 * 3600);

That aside, the automation of the ending is coming up later.

Once the automation of the server was complete, that already made life easier, however there was still more to do.

Phase 2: Event Promotion & Notification automation

The next phase for this is the automation of the promotion of the event and notifications to people who signed up.

This was fairly easy to achieve, and included gamenights also. (Gamenights cannot be automated due to a variety of reasons).

For Movie and Game events scheduled in the "Events" section of the website, it took these and displays them automatically on the homepage slider. This is always at the start so it's the first thing people see when they go to https://warzone.gg/

The next part is the automatic notifications.

Every 60 seconds on the website, a AJAX request is done that checks if any events you signed up for has started.

Like the gameserver, this also uses unix timestamps.

The scripts would receive events which are => to time(); and the end time is > time();

If you were signed up, the AJAX request would return information saying "There's an event starting now, you're signed up to it" and the Javascript would show you a notification and play an annoying notification sound.

This will be coming to the forum also, so no longer need to modify the template and say "This has started now, join!"

Phase 3: Complete Automation

This is what I'm working on now. This takes it to the next level. 

  • A script is ran once a collection of movies is selected for voting
  • The script will use an external API to get all required information such as:
    • Director
    • Actors
    • Release Date
    • Cover Image
    • Running Time (In Minutes)
      • This is converted from minutes to seconds (More on this later)
    • Genre
    • Plot
    • Ratings
    • Trailer
  • Store information in the movie voting table for later use.
  • A script runs every Tuesday at 5PM
    • Get 1 result only, order by votes Descending
    • This will return the highest voted movie on https://warzone.gg/movievoting
    • It will also contain all the movie information from the API that was fetched earlier.
    • Calculate the start and end time
      • Using PHP's DateTime Library, I can get the next Friday date by setting the date to "next friday"
      • Set the time to 19:00:00 (UK Time)
      • Take the duration that we converted from seconds earlier, take the starting UNIX time stamp and add the duration seconds to the start time (+ 10 minutes for the intermission time)
      • This then returns another UNIX timestamp that is roughly 2 hours (Depending on movie) after the starting timestamp
    • Create a movie night event automatically with all the information that we stored from the API
    • Remove the highest voted movie from the movie voting
    • Remove all votes
  • The homepage slider & Gameserver will now pick up on this as the event was scheduled as stated above in Phase 1 and Phase 2

At this point, the process is 90% automated, there are still some things a human needs to do, such as:

  • Obtaining and converting the movie once a week
  • Every 6 months, get a list of movies suggested by the community and add them to the voting.
  • Steam group notifications

Phase 3 is nearly complete and will be coming out in the next few days before the next movie night.

Sign in to follow this  


Recommended Comments

19 minutes ago, Avvie said:

I skimmed this but is this about like a new update for movie night?

Kinda, the end user wont notice anything, but for us the whole process of voting, making the event page etc is now automated and doesn't require manual intervention

Share this comment

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Add a comment...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use and our Privacy Policy policy.