UE3 - UT3 Console Commands in UT3

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Barzahd

New Member
Jan 19, 2008
2
0
0
Okay, my goal here is simple. I'm trying to learn the UnrealScript for UT3 (along woth class structure, which seems vastly different from that of UT2004). All I am trying to do is make a simple script that echos a string of text back to the console.

I have tried several methods trying to get this to work, and so far I'vecome up with nothing. First thing I did was look in the CheatManager class, figuring I could extend that to do something similar.

For example, I was thinking it should work to take the existing code in CheatManager.uc:

Code:
exec function God()
{
	if ( bGodMode )
	{
		bGodMode = false;
		ClientMessage("God mode off");
		return;
	}

	bGodMode = true;
	ClientMessage("God Mode on");
}

and modify it to (in a new file called FubarClass.uc):

Code:
class FubarClass extends CheatManager;

exec function Fubar(bool IsFubar)
{
	if ( IsFubar )
	{
		ClientMessage("Fubar Toggled On");
	}

	else
             {
	             ClientMessage("Fubar Toggled Off");
             }
}

Which would simply work by passing in "true" or "false" after the command in the console.

Code:
 Fubar true

This compiles just fine, for the record. I then go in game, and type
Code:
 get FubarClass
and it says that it's an unrecognized class, as if its not being loaded at all. This would help explain what is happening (or not happening as it were), but it still doesn't help me figure out what I'm doing wrong.

It would seem that information on scripting for UT3 is extremely limited across the net. Even UnrealWiki doesnt have a lot on it just yet. If anyone can help with this I would greatly appreciate it.

Thanks guys,

-Barzahd
 

Nereid

・ ω ・
Apr 15, 2003
1,843
0
36
34
Vancouver
If you're trying to make a custom console command, you're probably better off creating an Interaction and loading that using a mutator, rather than extending CheatManager.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Interactions are no longer queried when looking for console commands implemented as exec functions. If you subclass CheatManager (better: UTCheatManager) you actually have to create an instance of your class and make it the current cheat manager.
IIRC the preferred method for implementing console commands is the Mutator.Mutate() function, though:
Code:
function Mutate(string MutateString, PlayerController Sender)
{
  local string Command;

  // IMPORTANT: Always call Super.FuncName() in overridden mutator functions!
  Super.Mutate(MutateString, Sender);

  Command = ParsePart(MutateString);
  if (Command ~= "god") {
    God();
  }
}

function string ParsePart(out string Text, optional string Delim = " ")
{
  local int Pos;
  local string Result

  Pos = InStr(Text, Delim);
  if (Pos == INDEX_NONE) {
    // delimiter not found, take entire string
    Result = Text;
    Text = "";
  } else {
    Result = Left(Text, Pos);
    Text = Mid(Text, Pos + Len(Delim));
  }
  return Result;
}

function God()
{
  // do stuff here
}

As a player, if the mutator is running, your command can be executed by typing "mutate god" at the console. If your function is supposed to take parameters, you need to parse them from the MutateString as well.
 

Barzahd

New Member
Jan 19, 2008
2
0
0
First off, Wormbo, thanks so much for your help. Definately pointed me in the right direction. Now I have a different issue. When I add my mutator into the game to be executed and try to load a mission, the game crashes. I'm sure I'm not executing this properly, but I cant figure out where to take it from here.

Here's the code from my Class File, FubarClass.uc:

Code:
class FubarClass extends UTMutator within CheatManager;



function Mutate(string MutateString, PlayerController Sender)
{
  local string Command;

  // IMPORTANT: Always call Super.FuncName() in overridden mutator functions!
  Super.Mutate(MutateString, Sender);

  Command = ParsePart(MutateString);
  if (Command ~= "fubar") {
    Fubar(); //changed function name
  }
}

function string ParsePart(out string Text, optional string Delim = " ")
{
  local int Pos;
  local string Result;

  Pos = InStr(Text, Delim);
  if (Pos == INDEX_NONE) {
    // delimiter not found, take entire string
    Result = Text;
    Text = "";
  } else {
    Result = Left(Text, Pos);
    Text = Mid(Text, Pos + Len(Delim));
  }
  return Result;
}

function Fubar() //changed function name
{
  // do stuff here
    ClientMessage("FubarClass Is Working! :D");
}
defaultproperties
{
    Name="FubarClass"
}

I also looked in the log to see what message it was giving out. Here is the relavant portion of the log file:

Code:
ScriptLog: Mutators FubarClass.FubarClass
Critical: appError called:
Critical: Object FubarClass None created in Level instead of CheatManager
Critical: Windows GetLastError: The operation completed successfully. (0)
Log: === Critical error: ===
Object FubarClass None created in Level instead of CheatManager

RaiseException() Address = 0x7c812a5b (filename not found) 
CxxThrowException() Address = 0x78158e69 (filename not found) 
StaticConstructObject('FubarClass','DM-Arsenal.TheWorld:PersistentLevel','None')
(script)Engine.GameInfo:AddMutator
(script)UTGame.UTGame:AddMutator
(script)Engine.GameInfo:InitGame
(script)UTGame.UTGame:InitGame

I find the part about creating "FubarClass None" particularly interesting. Does this imply that I am missing a function or object/instance of something? I'm thinking maybe the crash is related to that part, but I am unsure. Sorry if I seem a little noobish here, just a bit unfamiliar with UnrealScript.

Thanks again for all your help.

-Barzahd
 
Last edited: