Does anyone know where I can find a custom-coded trigger that triggers the entering of console commands?
If not, can somebody please show me what the code for such an actor looks like. Maybe a ConsoleTrigger Actor that allows one to enter a console command in Actor Properties or change it in-game before it's triggered. Think of what can be made with this.
For example, in the Actor Properties for ConsoleTrigger there will be a category called ConsoleTrigger. In that category, there is a field called "Command". In that field you can type something like: KillAll Weapon—then you set the TriggerProperties stuff and it's done.
In-game you can type something like: Set ConsoleTrigger.ConsoleTrigger Command Exit
For a single player game or MonsterHunt, a map maker can make the player say stuff using the triggerable Say command; while also setting off a TriggeredAmbientSound of a character voice (like an in-game-talking NaPali character).
Triggering Console Commands
Re: Triggering Console Commands
Look at ConsoleCommand call for each actor. Pay attention where command run (server or client). Also avoid run client input as command on server side. it is lead to exec vulnerability.
Also docs say ConsoleCommand fine work on any actor. It is not true.
Better run it on PlayerPawn object, or it able not work.
Also docs say ConsoleCommand fine work on any actor. It is not true.
Better run it on PlayerPawn object, or it able not work.
Re: Triggering Console Commands
ONP has an actor like this (however the only campaign that use it was Seven Bullets if I'm not mistaken), here is the code:
However I'm not sure if it works online.
Code: Select all
// ============================================================
// This package is for use with the Partial Conversion, Operation: Na Pali, by Team Vortex.
// ConsoleCommandTrigger : I am very apprehensive about this, but nonetheless, here it is.
// Do NOT do something stupid!
// ============================================================
class ConsoleCommandTrigger expands Triggers;
var () string Command; //the actual console command
var () bool MessageResult; //if the command returns something, should it be shown to client. Note: only applies to native commands.
function Trigger( actor Other, pawn EventInstigator ){
local string result;
if (Command~="exit"||Command~="quit"||Command~="debug gpf"){
result="Warning: map author is a moron!";
MessageResult=true;
}
else
result=EventInstigator.ConsoleCommand(Command);
if (result==""||!MessageResult)
return;
if (Playerpawn(EventInstigator)!=none)
EventInstigator.Clientmessage(result);
else
Broadcastmessage(result);
}
Somewhere in Nevada...
- SteadZ
- Average
- Posts: 67
- Joined: Mon Mar 10, 2014 11:19 pm
- Personal rank: 1337
- Location: Scotland
- Contact:
Re: Triggering Console Commands
Legend Entertainment's Wheel of Time also contains such an actor, albeit in simpler form (and prettier - sorry UsAar33 )
Code: Select all
//=============================================================================
// CommandTrigger.uc
// $Author: Mfox $
// $Date: 1/06/00 2:42p $
// $Revision: 1 $
//=============================================================================
class CommandTrigger expands Trigger;
var() string CommandStr;
//=============================================================================
function Trigger( Actor Other, Pawn EventInstigator )
{
if( PlayerPawn(EventInstigator) != None )
{
PlayerPawn(EventInstigator).ConsoleCommand( CommandStr );
}
}
//=============================================================================
defaultproperties
{
CommandStr="SHOWUBROWSER"
}
- sektor2111
- Godlike
- Posts: 6423
- Joined: Sun May 09, 2010 6:15 pm
- Location: On the roof.
Re: Triggering Console Commands
For this thing you don't need any console. You can check what command does and rewrite the thing elsewhere in a custom actor, it's not a Rocket Science. It's how I used RememberSpot and ShowPath. I wrote around 3+ mutators, using them as base for extra features (DM enemy tracker, CTFFlag tracker, MonsterHunt tester for Bot Objectives which I updated 2-3 times if I well recall). Command "Loaded" was already implemented elsewhere not as command, but codes from command. A console command for me is useful when UScript cannot do actions directly, and they aim native C++ functions from Engine/Core which cannot be recreated in UScript stage, such as "Exit" "Quit", etc.
See what KillAll does...
Code: Select all
exec function KillAll(class<actor> aClass)
{
local Actor A;
if( !bAdmin && (Level.Netmode != NM_Standalone) )
return;
ForEach AllActors(class 'Actor', A)
if ( ClassIsChildOf(A.class, aClass) )
A.Destroy();
}
Edit: PS - I wasn't really inspired too much in the past. I totally forgot to implement this sort of code for destroying Items and Monsters (and even paths) if game has been ended - TeamCannons are already doing this by themselves. I don't see any reason to run things after ending game. Perhaps it worth some testing in a generic ServerActor...