I’d like to create a new file (other than Launch.log) to log all in-game chat among players, so server admins can check the chat history.
Does anyone know if this is possible with UDK?
I know I could create a .ini file to write data to, but that doesn’t seem appropriate. I also guess I could BasicSaveObject to write a file. But that seems like it would write the full file each time (rather than appending new logs to the end of the file).
I don’t think there’s an easy way to do this with just Unrealscript. I think if you don’t want to write to an ini or BasicSaveObject, then these are your options:
- Dive into the UE3 C++ code and look for GLog, and make a pointer just like it called GChatLog. Then look at UObject::LogInternal and make a function just like it called ChatLogInternal. Then look at
Log and make a macro just like it called
ChatLog. There’s probably more to it than that, but that’s where I would start.
- Grab a premade dll from somewhere. Someone must have written a really simple dll that opens a file and appends strings to the bottom. Distribute your game with that dll and make a UScript class bind to it.
- Write your own dll that does the above.
- Just log chats into the regular log, but put some kind of message ahead of it to make chat messages easier to find.
Thanks for the tips @Nathaniel3W. I think a custom DLL will probably be best.
However I am finding that the (currently only) DLL I’m using in my game sometimes doesn’t bind correctly. I only know this because sometimes a player will send me their Launch.log file and I’ll notice there is a line stating “WARNING Can’t bind to DLL myDll.dll”.
It seems to be very intermittent, and I can’t reproduce it on my local dev machines. So I’m hesitant to add features that are dependent on custom DLL’s before I’ve figured out what’s causing that.
I think I used to have a problem with binding 64-bit dlls and I had to run UDK in 32-bit mode to get everything working. I honestly haven’t tried in years though so I don’t know what could be going wrong there.
Do you only need the logging to work on the server? Do you control all the servers? If players can create their own servers, that might complicate things. I can understand why you wouldn’t want to troubleshoot someone else’s server to find out why the chat logs aren’t getting saved.
the only time i seen that warning is when i would run the 64 bit exe and the dll is 32 bit.
Can you run 2 logs in the command line at the same time?(<-have not tried that) If you can, just rename one log to what you want. then it will have both if that works.
Look at FileWriter and FileLog in Engine.
function ParseWeapon(class<Rx_Weapon> InClass)
{
local JsonObject Payload;
Writer.OpenFile(string(InClass), FWFT_Stats, ".json");
Payload = new class'JsonObject';
Payload.SetStringValue("bInfiniteAmmo", string(InClass.default.bHasInfiniteAmmo));
Payload.SetStringValue("bBurstFire", string(InClass.default.bBurstFire));
Payload.SetStringValue("bCanLock", string(InClass.default.bCanLock));
if (InClass.default.CustomWeaponName != "")
Payload.SetStringValue("Name", InClass.default.CustomWeaponName);
else
Payload.SetStringValue("Name", InClass.default.ItemName);
Payload.SetStringValue("HeadshotMulti", string(InClass.default.HeadShotDamageMult));
Writer.Logf(class'JsonObject'.static.EncodeJson(Payload));
Writer.CloseFile();
}
As an example; you can use Logf for however long the game/match lasts, then CloseFile at end of game.
Awesome! Thank you @NodSaibot