Displaying your COD4 stats in a WordPress widget

So, I finally got the thing running. Of course, it turned out to be harder than i thought…

Some things i ran into while implementing it:

  • It’s not exactly possible to read in bytes from a file with JavaScript. This isn’t an issue normally, as the usual environment for JS is the web, but you kind of would expect there’d be a way to do this with WSH. Workarounds exist, but are lacking.
  • PHP and the Google Charts API don’t play along too nicely when you have to deal with JSON encoded Dates. The Google API expects months starting with 0 (e.g. January = 0, February = 1), PHP delivers months starting with 1.

My approach basically boils down to this:

  • Run a WSH script regularly which executes a c program which decrypts the mpdata file, reads in the relevant bytes for kills and deaths.
  • It then makes a GET request to a PHP script which saves the kills, deaths and a unix timestamp to a file.
  • A WordPress widget displays the statistics as a Google Chart after converting the file to JSON.

The code is on github, it’s all very ugly, but working.

 

Share on Facebook0Tweet about this on TwitterShare on Google+0

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.