Exec Function
Exec Functions are functions that a player or user can execute by typing its name in the console. Basically, they provide a way to define new console commands in UnrealScript code.
exec function God() { if ( bGodMode ) { bGodMode = false; ClientMessage("God mode off"); return; } bGodMode = true; ClientMessage("God Mode on"); }
Passing Parameters
You can allow parameters for your console command by simply adding those parameters to the exec function's definition:
exec function Slap(string Player, int Strength) { Level.Game.Broadcast(None, Player @ "was slapped with strength" @ Strength); }
When entering this console command, separate the parameters with blanks (not commas). If the last function parameter is a string, it gobbles up everything that's remaining on the console command line.
(> Slap Mychaeel 1337 Mychaeel was slapped with strength 1337
You can make exec function parameters optional if you want.
Valid Places for Exec Functions
Exec functions can be placed anywhere, but they only actually work in the following classes:
Note: this is only for UT2003, not UT and Unreal
- GameInfo – only server-side (since the GameInfo actor isn't replicated to clients)
- PlayerController
- CheatManager? – natively supported extension within PlayerController
- PlayerInput – same as CheatManager?
- Pawn
- Weapon – only for the currently held weapon, not all weapons in the player's inventory
- HUD
Note that an exec function must be simulated to work client-side.
Related Topics
- GUIUserKeyBinding – adding your custom console commands to the game's Controls setup menu.