2. Required Arguments

After you make sure you know how to reference the movie, its time to add in the other arguments that pnFlashGames requires. Below is a list of variables and an explanation of each one. Below the list an example of a full blown object tag for a pnFlashGames enabled game will be displayed.

pn_gid

This is the id for the game according to the database. This is how the game's information is found and is the game tables index for most arcades including PostNuke, Xoops, and MOS.

pn_uname

This is the username of the current player according to the CMS that the arcade is running in. If no username can be found then "Guest" or "Anonymous" will likely be passed. This is not a required value, but some games look for it in order to give a nice greeting or increase interactivity with the player.

pn_checksum

This is the MD5 checksum of the currently running game. This is required for commercial games. Here is the recommended PHP function for getting the checksum of a given game:

function pnFlashGames_getChecksum($file){
   if($fp = fopen($file, 'r')){
      $filecontent = fread($fp, filesize($file));
      fclose($fp);
      return md5($filecontent);
   }else{
      return false;
   }
}
pn_license

This is the license key exactly as the store outputed for this game on this domain. This will be different for every game and every domain and subdomain. This is required for commercial games.

pn_domain

This is the domain where the game is currently running. This includes any subdomain as well. So if your games are on games.myhost.com, that is what you would pass. Here is the PHP function that returns the correctly formatted domain specification:

function pnFlashGames_getDomain(){
   $url = "http://".$GLOBALS['HTTP_HOST']."/";

   // get host name from URL
   preg_match("/^(http:\/\/)?([^\/]+)/i", $url, $matches);
   $host = $matches[2];

   $host = str_replace("www.", "", $host);
   return $host;
}
pn_autoupdate

Component version 1.0 (commercial version 2.0) or higher. This tells the game whether or not to attempt to refresh the scores list automatically when a new score is saved. Valid options are "true" and "false". Default is "false". Setting this to "true" will cause the flash movie to execute a JavaScript function called "refreshScores();" whenever a score saving response is sent from the server. You must define that function on the same page as the object tag in order for it to work correctly. Setting this to "true" and not defining that function will cause a runtime error.

pn_script

Component version 1.0 (commercial version 2.0) or higher. This tells the game what script to communicate with for all its game related functions. If not defined, the default is "index.php". For example, for PostNuke this would be "index.php".

pn_modvar

Component version 1.0 (commercial version 2.0) or higher. This tells the game what the first variable name should be when communicating with pn_script. If not defined, the default is "module". In MOS, this would be "component". In Invision, this would be "option".

pn_modvalue

Component version 1.0 (commercial version 2.0) or higher. This is the value that the game assigns to pn_modvar. If not defined, the default is "pnFlashGames". So if you don't define pn_modvar or pn_modvalue, then when communicating with pn_script the game will pass "module=pnFlashGames" first. For example, for MOS this would be "PUArcade". These values are used to route the commands to the appropriate place within a CMS. In Invision, this would be "ibproarcade".

pn_extravars

Component version 1.0 (commercial version 2.0) or higher. This is a list of delimited name/value pairs that the game will pass back to pn_script whenever it communicates with it. Each pair is separated by the "|" character, and each name / value is seprated by the "~" character. For example, if you needed the game to pass to pn_script the name/value pair "type=arcade" you would pass in "pn_extravars=type~arcade". If you needed to pass "type=arcade" AND "name=flashgame" you would pass in "pn_extravars=type~arcade|name~flashgame". The default is null.

The arguments string itself actually gets passed just like you would pass variables via GET to a page. You will see the variables appended to each src specification after the movie.swf. Its just like passing variables to a page, only you are passing them to a .swf.

So, now lets look at the complete object tag for a typical commercial pnFlashGame. We will be passing in all the variables we need.

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="500" HEIGHT="500" id="Battle Pong" ALIGN="">
  <PARAM NAME=movie VALUE="modules/pnFlashGames/games/battlepong.swf?pn_gid=9&pn_uname=leason&pn_license=fa6074ca97ae6aad53146544633afa0c&pn_domain=site2&pn_checksum=4109e26405b78392d792f14370a92bfc&pn_extravars=var1~value1|var2~value2&pn_autoupdate=true">
  <PARAM NAME=quality VALUE=high>
  <PARAM NAME=bgcolor VALUE=000000>
  <PARAM NAME=menu VALUE=false>
  <EMBED src="modules/pnFlashGames/games/battlepong.swf?pn_gid=9&pn_uname=leason&pn_license=fa6074ca97ae6aad53146544633afa0c&pn_domain=site2&pn_checksum=4109e26405b78392d792f14370a92bfc&pn_extravars=var1~value1|var2~value2&pn_autoupdate=true" quality=high bgcolor=000000 WIDTH="500" HEIGHT="500" NAME="Battle Pong" ALIGN="" MENU=false TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
  </EMBED>
</OBJECT>