Blog Archives

Remote Web Server Mod

Here is a simple example of how you can send information from a Rune mod to a remote web server.

All you really need is web host that supports php. There are many free web hosts that do this. Try using google.

In this example I am sending the current map and the number of players who are currently playing on the server, then the php script at the remote web server save these variables to a text file, which can be viewed in a normal web browser.

The mod is running as a ServerActor and does not need to be downloaded by players.

DOWNLOAD:
WebServerMod.zip | WebServerModSrc.zip

CODE:

The ServerActor:

// WebServerMod.uc
Class WebServerMod extends Info;

var UBrowserHTTPClient WebCon;
var string WebHost, WebFile;
var int WebPort, WebTimeOut;
var string WebVars;

event PostBeginPlay()
{
	local string MapName;
	local int Players;

	MapName = left(level, instr(level, "."));
	Players = Level.Game.NumPlayers;

	// Would look something like this in a browser:
	// www.website.com/folder/WebServerScript.php?map=DM-Coliseum&players=16
	WebVars = "?map="$MapName$"&players="$Players;

	WebCon = Spawn(Class'UBrowserHTTPClient');
	WebCon.Browse(WebHost, WebFile$WebVars, WebPort, WebTimeOut);

	log("Browse:"$WebHost$WebFile$WebVars$":"$WebPort);
}

DefaultProperties
{
	WebHost="www.website.com"
	WebFile="/folder/WebServerScript.php"
	WebPort=80
	WebTimeOut=5
}

The php script:

// WebServerScript.php
<?php

$MapName = $_REQUEST['map'];
$NumberOfPlayers = $_REQUEST['players'];

$LogFileName = "WebServerMod.log";
$LogFile = fopen($LogFileName, 'w') or die("can't open file");

$NewLine = "\n";

fwrite($LogFile, "Map: ");
fwrite($LogFile, $MapName);

fwrite($LogFile, $NewLine);

fwrite($LogFile, "Players: ");
fwrite($LogFile, $NumberOfPlayers);

fclose($LogFile);
?>

You could use this kind of thing for many many many other things too:

– update server stats
– update players stats
– create player chat system
– player rating of maps on download sites
– …much more, use your imagination

Note: I just realized that this mod sends the amount of players at the beginning of the map, and there might not be any players on the server so early. But it doesn’t matter, it’s just an example, you should still see the map name at least in the text file if you try it.

Game Configuration

After you have installed Rune, there are some things you should change before you do anything else.

1. Disable CD checking

You will notice if you try to start the game without the Rune CD that you will get a bunch of errors, and you can’t start the game. To start the game without a CD go to the game System folder (default is C:\Rune\System) and open the file Rune.ini with a text editor. Look for a line that start with “CdPath” and delete it or uncomment it. Lines can be uncommented in ini files with either putting a ‘ or // at the start of the line. So make these changes and save the file:

...
ViewportManager=WinDrv.WindowsClient
Render=Render.Render
Input=Engine.Input
Canvas=Engine.Canvas
//CdPath=D:

2. Download new graphics renderers

Unless you are using Rune Classic you should download new versions of the graphic renderers:

Rune 1.07
OpenGL | Direct3D9

Rune 1.00
OpenGL

After you have put those new renderers in your System folder, start up the game and go to Options->Video and change your settings.

3. Change some Rune.ini settings

Don’t auto delete files downloaded from servers:

PurgeCacheDays=0

Increase size of game cache:

CacheSizeMegs=8

Disable web server:

//ServerActors=UWeb.WebServer

More to come…