Creating Commandlets

I just tried following these steps in the documentation to create a new commandlet: UDK | MakingACommandlet

However,after adding the HelloWorld class and compiling, when running:

UDK.exe helloworld param1

The game starts up, and then complains that there is no map called “helloworld”.

Has anyone got this to work?

Batch files you mean ?

“The game starts up, and then complains that there is no map called “helloworld”.”
put in one of your maps names.

on the target line in our shortcut after the exe is our map name.

C:\UDK\UDK-2014-02\Binaries\Win32\FOPB.exe server warehouse2?dedicated=true?GameDifficulty=7?TimeOfDay=5?Weather=1?AdminPassword=ss?Game=Paintball.PBRescuePresident?MaxPlayers=16?NUMPLAY=2? –silent LOG=DEDPaintballLog.txt -ConsolePosX=0 -ConsolePosY=0

@gamepainters I’m trying to create new commandletts for automating certain tasks in-engine.

For instance I use some of the existing commandletts for things like importing .swf files without needing to go into the editor, etc.

They document how to create your own in the documentation here, but their simple “helloworld” example is not working for me:…ommandlet.html

In this case, I want to create a commandlet that can decode a save file that has been encoded in-engine. Currently I have to boot-up the game and run a command. It would be nice to just run a single shortcut and do this with a commandlett script. There are lots of other things I’d like to automate too.

I don’t find it hard to believe that the engine simply cannot run without a map loaded. Even if all you want to show is a menu, you still need to load a map, and there’s all that engine relevant stuff that’s in Worldinfo which is tied to a map isn’t it?
I’d just try using the smallest map possible that works for what you need the commandlet to do.

I know it’s still possible to boot up the game and manually type in the commands i need. But when I’m setting up automation pipelines for certain batch tasks, that is not really an option.

And the documentation states that custom commandlets are supported. I feel like I am just doing something wrong with how i’m setting it up, so wanted to check if anyone else is using them.

I’m working on setting one up to start our game with, beings you can only put in 256 characters into the target line. Hopefully i can add more thru the commandlet. I got the class to compile but it is not reconizing my map and its starting a listen server not a dedicated server. I’m having problems with it also. When i get it running properly, i will let you know what i did.

@gamepainters Thanks. I’m curious, are you saying you usually use custom launch params, and can pick them up in Unrealscript?

I’ve always wanted to do this, but thought it was only possible with engine source access. May I ask how you are reading the params in Unrealscript?

What we are doing at this moment is this. We took and made a shortcut from our exe to the desktop then in that shortcut i put into the target line this.

C:\UDK\UDK-2014-02\Binaries\Win32\FOPB.exe server warehouse2?dedicated=true?GameDifficulty=7?TimeOfDay=5?Weather=1?AdminPassword=ss?Game=Paintball.PBRescuePresident?MaxPlayers=16?NUMPLAY=2? –silent LOG=DEDPaintballLog.txt -ConsolePosX=0 -ConsolePosY=0

Then all i have to do is click that shortcut and it will start a dedicated server.

But what i hate is the target line will only accept 256 characters. So it limits you on what you can put into the target line. I was hoping to make a commandlet to start the dedicated server with. I was hoping to run way more parameters then you can put into the target line. But way its looking this might not work for what i was thinking.

@gamepainters The way I have it configured is that all dedicated server settings are in a custom ini file i created (DefaultDedServerSettings.ini). Then on init game, I apply them, without relying on purely launch params.

In your above example, you can access the query url part of the launch command from unrealscript, but not the other launch params (such as -ConsolePosX, or any of those), as far as i know. I would like to be able to access the entire launch string.

The target line is just for the starting of the 1st map after that the game.ini takes over and it uses everything in that file. I was hoping to get more parameters on the 1st map launch.

@Coldscooter does the log in the main function print for you
“hello world”** in your logs?

I can not get the main function log to print to my log file.**

@gamepainters I was never able to get it to run the commandlet, as it would always try to load a map with the name of my commandlet that i was passing in the command.

Have you been able to get the commandlet to run? How are you running the commandlet? I was running from a shortcut of UDK.ex with this in the target field:

../UDK.exe HelloWorldCommandlet testParam

Also tried:

../UDK.exe HelloWorld testParam

It always comes up with a warning saying “can’t fin map HelloWorld, would you like to load the default map?”.

no i cant seem to get it to run. It just loads the game as if you were trying to start the game normally as a player. I tried logging the params coming in but nothing, its like main does not run.

I have not been around for last few days. We run the servercommandlet then in the parameters we tell it which kind of server we are going to run. Only way i can think of to get more parameters added is to use a .bat file as Neongho posted above. then you can have as many parameters as you want.

Did you get it working using the server commandlet ? You can set parameters dedicated=true? or listen=true? for which server your wanting to run.

like this in the login function in gameinfo class. Examples below

InPassword = ParseOption ( Options, "Password" );//admin pass

InTeam = GetIntOption( Options, "Team", 255 ); // default to "no team" 

Also in the init function in whatever you call your gametypes class that extends gameinfo or in the gametype init function, i think i would gather most in the gametypes base file.
These were in our Base gametypes file.

function Init()
InOpt = ParseOption(Options, "Weather");

if (InOpt != "")
  WeatherSetting = int(InOpt);

while(WeatherSetting == 0)
  WeatherSetting = rand(4);

InOpt = ParseOption(Options, "TimeOfDay");

if (InOpt != "")
  TimeOfDaySetting = int(InOpt);

while ( TimeOfDaySetting == 0 )
  TimeOfDaySetting = Rand(8);//select a random time to start at

if((TimeOfDaySetting == 7) || (TimeOfDaySetting == 8) || (TimeOfDaySetting == 1) || (TimeOfDaySetting == 2))
  bIsInNight = true;


function InitGameReplicationInfo()
 if(GameReplicationInfo != none)
    GRI = PBGameReplicationInfo(GameReplicationInfo);

 if(GRI != none)
   GRI.TimeOfDaySetting = TimeOfDaySetting;
    GRI.WeatherSetting = WeatherSetting;
   SetAllWeatherVars(PBGameReplicationInfo TheGRI)

function SetAllWeatherVars(PBGameReplicationInfo TheGRI)
 local PBGameReplicationInfo GRI; 

 if(TheGRI == none)
    GRI = PBGameReplicationInfo(GameReplicationInfo);
    TheGRI = GRI;

  TheGRI.bIsInNight = bIsInNight;

In the file hostgame theres a
function FinishStartDedicated()
in that function we set our parameters to be sent into the login or init functions.

Registry.GetData("SelectedTimeOfDay", TOD);
TravelURL $= "?TimeOfDay=" $ TOD;

Registry.GetData("SelectedWeather", Weather);
TravelURL $= "?Weather=" $ Weather; 

Also in the base gametype file that extends gameinfo theres a function called
function ProcessServerTravel(string URL, optional bool bAbsolute)
in that you must get your parameters also to send when traveling to next map.

Registry.GetData("SelectedWeather", Weather);
Registry.GetData("SelectedTimeOfDay", TOD);

GRI.WeatherSetting = int(GetWeather(Weather));
GRI.TimeOfDaySetting = int(GetTimeOfDay(TOD));

WorldInfo.NextURL $= "?Weather=" $ GetWeather(Weather); 
WorldInfo.NextURL $= "?TimeOfDay=" $ GetTimeOfDay(TOD);

//we set the bIsInNight and GRI.bIsInNightTime here once we know what time it is.
if((GRI.TimeOfDaySetting == 7) || (GRI.TimeOfDaySetting == 8) || (GRI.TimeOfDaySetting == 1) || (GRI.TimeOfDaySetting == 2))
  bIsInNight = true;  

function string GetWeather(String ActualWeather)
if(ActualWeather ~= "random")
    return "0";
else if(ActualWeather ~= "Clear") { return "1"; } 
else if(ActualWeather ~= "Cloudy") { return "2"; } 
else if(ActualWeather ~= "Rain") { return "3"; } 
else if(ActualWeather ~= "Snow") { return "4"; } 
return "0";

function string GetTimeOfDay(String ActualTime)
  if(ActualTime ~= "random") { return "0"; }
  else if((ActualTime ~= "midnight") || (ActualTime ~= "12am"))  { return "1"; }
  else if(ActualTime ~= "3am") { return "2"; }
  else if(ActualTime ~= "6am") { return "3"; }
  else if(ActualTime ~= "9am") { return "4"; }
  else if((ActualTime ~= "noon") || (ActualTime ~= "12pm"))  { return "5"; }
  else if(ActualTime ~= "3pm") { return "6"; }
  else if(ActualTime ~= "6pm") { return "7"; }
  else if(ActualTime ~= "9pm") { return "8"; }
  return "0";

The above code was how we put in our time of day and weather settings parameters.
Also make sure you make the gri vars you will need them later for checks thru out code

Hope it helps.