Trigger sending message to Console/Log

Tutorials and discussions about Mapping - Introduce your own ones!
Post Reply
Icedude
Novice
Posts: 3
Joined: Mon Feb 28, 2011 12:32 pm

Trigger sending message to Console/Log

Post by Icedude »

I'm making a CTF level for a university project, or rather two different versions of the same CTF level. One version of the level has a load of movers activated by triggers (both players touching them and players shooting them), and I need some way of monitoring when the movers are triggered.

Is there some way of rigging a trigger to output a message including a timestamp to the console or system log? Is there a specific actor which could be used to do this?

A way of finding out which player activated the trigger would help even more, but that seems pretty unlikely. A solution involving little unrealscripting would be preferable, as I have next to no knowledge about how to write it. Any help would be appreciated!
Last edited by Icedude on Mon Feb 28, 2011 2:49 pm, edited 1 time in total.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Trigger sending message to Console/Log

Post by JackGriffin »

Make a subclass of trigger and add this, replacing the relevant section:

Code: Select all

// Open the mover.
function DoOpen()
{
    local mover M;

    bOpening = true;
    bDelaying = false;
    InterpolateTo( 1, MoveTime );
    PlaySound( OpeningSound, SLOT_None );
    AmbientSound = MoveAmbientSound;
   log("## ADMIN- Mover opened:"@M@" by player:"@Instigator.PlayerReplicationInfo.PlayerName);
}

// Close the mover.
function DoClose()
{
    local actor A;

    bOpening = false;
    bDelaying = false;
    InterpolateTo( Max(0,KeyNum-1), MoveTime );
    PlaySound( ClosingSound, SLOT_None );
    if( Event != '' )
        foreach AllActors( class 'Actor', A, Event )
            A.UnTrigger( Self, Instigator );
    AmbientSound = MoveAmbientSound;
    log("## ADMIN- Mover closed:"@M@" by player:"@Instigator.PlayerReplicationInfo.PlayerName);
}

You can add timestamps and any other information in the log lines and it will show on your server log. If you have a lot of triggers this will make a lot of logging though. Make sure you don't have the logging suppressed too.
So long, and thanks for all the fish
User avatar
Sp0ngeb0b
Adept
Posts: 376
Joined: Wed Feb 13, 2008 9:16 pm
Location: Cologne
Contact:

Re: Trigger sending message to Console/Log

Post by Sp0ngeb0b »

This is basically the same but it's way less code and also fixes possible nones in the other log line:

Code: Select all

MyLogMover extends Mover;

// Open the mover.
function DoOpen()
{
   Super.DoOpen();

   log("## ADMIN- Mover opened:"@self" by player:"@Instigator.PlayerReplicationInfo.PlayerName);
}

// Close the mover.
function DoClose()
{
    Super.DoClose();

    log("## ADMIN- Mover closed:"@self" by player:"@Instigator.PlayerReplicationInfo.PlayerName);
}
Website, Forum & UTStats

Image
******************************************************************************
Nexgen Server Controller || My plugins & mods on GitHub
******************************************************************************
Icedude
Novice
Posts: 3
Joined: Mon Feb 28, 2011 12:32 pm

Re: Trigger sending message to Console/Log

Post by Icedude »

Thanks for the help! So in theory I just subclass mover, copy the code into the new subclass, make a new mover in this subclass in the level (a small cube off in another area somewhere), then set it to the same tag and other settings as the appropriate mover already in place?

Edit: or would there be a way to change the already existing movers over to this subclass without rebuilding and re-keying them entirely?
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Trigger sending message to Console/Log

Post by JackGriffin »

Don't alter the mover, alter the trigger. If you have movers that cycle or do more than a<->b you are going to end up with errors because the instigator could possibly be none. The OP wants to know who triggered the mover and your way will log every leg the mover makes.
So long, and thanks for all the fish
Icedude
Novice
Posts: 3
Joined: Mon Feb 28, 2011 12:32 pm

Re: Trigger sending message to Console/Log

Post by Icedude »

Ok, thanks to the code you provided, I've made a Keypoint subclass that outputs to the log when triggered:

Code: Select all

//=============================================================================
// LogWriteKeypoint.
// by Robert 'Icedude' Astley
// Thanks to JackGriffin and Sp0ngeb0b on ut99.org
//=============================================================================
class LogWriteKeypoint expands Keypoint;

function Trigger(actor Other, pawn EventInstigator)
	{
		Log("## ADMIN- Trigger Activated:"@self.Tag @"by player:"@EventInstigator.PlayerReplicationInfo.PlayerName);
	}
It works pretty much the way I wanted it to, simply by setting the tag to the same as the mover. If I knew how to add timestamps it would be perfect. Just wanted to say thanks again!
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Trigger sending message to Console/Log

Post by JackGriffin »

Icedude wrote:

Code: Select all

class LogWriteKeypoint expands Keypoint;

function Trigger(actor Other, pawn EventInstigator)
	{

                MyTimeStamp = TimeStamp;

		Log("## ADMIN- Trigger Activated:"@self.Tag @"by player:"@EventInstigator.PlayerReplicationInfo.PlayerName@"Timestamp:"@MyTimeStamp);
	}
Try that out. You might have to tweak a bit to get it just the way you want.
So long, and thanks for all the fish
Post Reply