| Home Page | Recent Changes | Preferences

AutoLoader/Example

This is an example based on the AutoLoader for ChatFilter

class ChatFilterLoader extends AutoLoader;

var config bool bEnabled;

We use this variable to give the user the ability to enable or disable the server actor from within the WebAdmin. This is just a forward variable, you have to do the check enabled state during the init of your server actor.

event PreBeginPlay()
{
  class'ChatFilter'.default.bEnabled = bEnabled;
  Super.PreBeginPlay();
}

Here is where we set the real enabled flag of the server actor. Ofcourse this has effect on the next map.

static function bool IsActive()
{
  return true;
}

This loader is always active.

static function bool EnableLoader(optional string SpecialActor)
{
  default.bEnabled = True;
  return true;
}

static function bool DisableLoader(optional string SpecialActor)
{
  default.bEnabled = False;
  return true;
}

These are used to toggle the enable status of the server actor, if you don't use an enabled option like I did you can just ignore these. Always return true, unless something failed when setting the enabled status, for example when it requires an other server actor to be active too.

function bool ApplyUpdate()
{
  return default.bEnabled;
}

Since we always have to change things in the configuration for this ServerActor we always want to apply an update when it's active.

static function FillPlayInfo(PlayInfo PI)
{
  Super.FillPlayInfo(PI);
  PI.AddSetting("Server Actors", "bEnabled", "Chat Filter", 10, 255, "Check");
}

Add a setting to the default → server actors page on the WebAdmin to enable/disable this server actor.

function bool ObjectNeedsUpdate(Object O, string PropName, string PropValue)
{
  if (Caps(PropName) == "SERVERPACKAGES")
  {
    if (!class'ChatFilter'.default.bCheckNicknames && !class'ChatFilter'.default.bFriendlyMessage && !Super.ObjectNeedsUpdate(O, PropName, PropValue))
    {
      RemoveArrayEntry(O, PropName, PropValue);
      return false;
    }
  }
  return Super.ObjectNeedsUpdate(O, PropName, PropValue);
}

ChatFilter requires a ServerPackage for some settings, here we check if it's required to change the value of the ServerPackages.

function int CheckArrayEntry(string PropName, array<string> PropArray)
{
  local int i;
  if (Caps(PropName) == "SERVERPACKAGES")
  {
    for (i = 0; i < PropArray.Length; i++)
    {
      if (Caps(PropArray[i]) == "\"CHATFILTERMSG\"")
      {
        return i;
      }
      if (Caps(PropArray[i]) == "\"CHATFILTERMSG151\"")
      {
        return i;
      }
      if (Caps(PropArray[i]) == "\"CHATFILTERMSG152\"")
      {
        return i;
      }
    }
  }
  return -1;
}

ChatFilter had some updates to the server package a couple of time. Because we don't want the old serverpackages still in the list (because we don't need them anyway), we have to remove them. The above routine checks the server actors list for packages with our name (note the double quotes).

Return the index of the entry to want removed from the ini file. Or -1 if you don't want anything removed.

defaultproperties
{
  bEnabled=true
  bIncludeServerActor=True
  ActorClass="ChatFilter.ChatFilter"
  FriendlyName="ChatFilter"
  ActorDescription="Filter chats on the server"
  RequiredIniEntries(0)=(ClassFrom="Engine.GameEngine",PropName="ServerPackages",PropValue="ChatFilterMsg154")
}

This is the real magic of the AutoLoader, usualy you only have to use this part to write an AutoLoader.

bIncludeServerActor
setting this to true will add the ActorClass to the ServerActors list
ActorClass
the class name of the ServerActor that this AutoLoader is for
FriendlyName
the friendly name to be used
ActorDescription
an description for the ServerActor
RequiredIniEntries(0)
This is an dynamic array containing addition changes to the ini file. These entries will automatically be added/removed when the AutoLoader is enabled/disabled.

.int file

To make this all work you have to create a .int file with the following content

[Public]
Object=(Class=Class,MetaClass=ConfigManager.AutoLoader,Name=ChatFilterLoader.ChatFilterLoader,Description="Filter chats on the server")

Now where the server restarts this new loader will be found.

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In