![]() |
|
|
#1 |
|
Registered User
Join Date: Oct. 19th, 2009
Posts: 24
|
Altering MessageTrigger to write Message to Log
To get some statistics (for a single player level) I'd like to alter my MessageTrigger to write the Messages to a Log File (.txt) instead of dumping them on the screen. I slightly altered the MessageTrigger code, but I can't get my trigger to open a log file. Most probably I can't seem to figure to which class the logfile should be appointed to. Here is my code. I have highlighted my changes. Anyone got any advice?
Code:
class MessageTrigger extends Triggers;
var() enum EMT_MessageType
{
EMT_Default,
EMT_CriticalEvent,
EMT_DeathMessage,
EMT_Say,
EMT_TeamSay,
EMT_WriteToLog
} MessageType;
var() localized string Message;
var() byte Team;
event Trigger( Actor Other, Pawn EventInstigator )
{
local name MSGType;
local Controller C;
local PlayerController P;
switch ( MessageType )
{
case EMT_CriticalEvent : MSGType = 'CriticalEvent'; break;
case EMT_DeathMessage : MSGType = 'xDeathMessage'; break;
case EMT_Say : MSGType = 'SayMessagePlus'; break;
case EMT_TeamSay : MSGType = 'TeamSayMessagePlus'; break;
case EMT_WriteToLog : MSGType = 'WriteToLog'; break;
default : MSGType = 'StringMessagePlus'; break;
}
for ( C=Level.ControllerList; C!=None; C=C.NextController )
{
P = PlayerController(C);
if ( P != None && CheckTeam(P) )
{
if (MSGType == 'WriteToLog')
{
OpenLog('test');
Logf(Message);
CloseLog();
}
else
{
P.TeamMessage(C.PlayerReplicationInfo, Message, MSGType);
}
}
}
}
http://wiki.beyondunreal.com/UE2:FileLog_(UT2004) Last edited by Superbabs84321; 27th Aug 2010 at 08:24 AM. |
|
|
|
|
|
#2 |
|
Registered User
Join Date: Apr. 5th, 2009
Posts: 142
|
Firstly, do not alter default packages. Create a new subclass instead of editing the existing MessageTrigger.
Secondly, you have to spawn a FileLog, and call the OpenLog, Logf, and CloseLog on it; the functions aren't visible from the MessageTrigger class. eg Code:
local FileLog logObject; logObject = spawn(class'FileLog'); logObject.openLog(filename); logObject.logf(message); logObject.closeLog(); logObject.destroy(); Also, you may want to move the code that does it outside the loop, else it will write to the log once for each person on the player's team.
__________________
UT Space Battle Main Homepage - https://sourceforge.net/projects/utspacebattle/ UT3 Site - http://www.moddb.com/mods/ut-space-battle UT2004 Site - http://www.moddb.com/mods/ut-space-battle-ut2004 |
|
|
|
|
|
#3 | |||||
|
Registered User
Join Date: Oct. 19th, 2009
Posts: 24
|
Quote:
Quote:
Quote:
Quote:
Quote:
Thank you very much for your help so far. The code works! PS I'd like to print also the levelname and the current time (either the gametime, the runtime, or the systemtime will do) together with the message, but I am not sure yet how I access these (wiki says they should be in the LevelInfo). If you got a suggestion... |
|||||
|
|
|
|
|
#4 |
|
The "do not alter default packages" thing affects the game itself, not individual levels. Just by saving a stock package (even without actual modifications) you basically render your entire game useless for online play.
__________________
Wormbo's UT/UT2004/UT3 mods | PlanetJailbreak | Unreal Wiki | Liandri Archives Everything you ever wanted to know about replication (but were afraid to ask) [in German] | UnrealScript security considerations <elmuerte> you shouldn't do all-nighters, it's a waste of time and effort <TNSe> nono <TNSe> its always funny to find code a week later you dont even remember writing <Pfhoenix> what's worse is when you have a Star Wars moment <Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!" |
|
|
|
|
|
|
#5 |
|
Registered User
Join Date: Oct. 19th, 2009
Posts: 24
|
Perhaps I should have made myself more clear: Not only is the level only for research purposes, but the whole game installation. The computer isn't even connected to the internet.
|
|
|
|
![]() |
| Tags |
| log messagetrigger |
| Thread Tools | |
| Display Modes | |
|
|