//============================================================================= // LibraryMessage // // This class is a number of static methods that allow you to send a number of // useful and static messages to clients, logs and make warnings. // // A few of these have been wrapped into macros in order to simplify Calling // them. // // Use this directive to get the macros // `include ({PackageName}/Classes/LibraryMessage.uci) // // Use `DebugMessage if you are trying to print debug information. Its output // will be omitted if the class has not been compiled in debug mode (-debug) // Use `LogMessage to send a message to the hud. // Use `ClientMessage to send a message to all clients. // // Contact : bob.chatman@gmail.com // Website : www.gneu.org // License : Content is available under Creative Commons Attribution-ShareAlike // 3.0 License. //============================================================================= class LibraryMessage extends Object; // Edit this to your preference to make messages stand out among the clutter of // the log. const prefix = ' '; // If debugging is enabled, write the message to the log and try to write it to // the screen. public static function DebugMessage(Object sender, string message) { `if(`isdefined(DEBUG)) LogMessage(message); GenericClientMessage(sender, message); `endif } // Try to somehow write the message to the screen. private static function GenericClientMessage(Object sender, string message) { if(Actor(sender) != none) ClientMessage(Actor(sender), message); else if(ActorComponent(sender) != none) ClientMessage(ActorComponent(sender).Owner, message); else WorldInfoClientMessage(message); } // Write the message to the log. public static function LogMessage(string message) { `log(message,true,prefix); } // Write the message to the log. public static function WarnMessage(string message) { `warn(message,, prefix); } // Write the message to the screen. public static function ClientMessage(Actor sender, string message) { local PlayerController PC; foreach sender.LocalPlayerControllers(class'PlayerController', PC) { PC.ClientMessage(message); } } // Try to grab the WorldInfo and use that to write the message to the screen. public static function WorldInfoClientMessage(string message) { local WorldInfo wi; wi = GetWorldInfo(); if(wi != none) ClientMessage(wi, message); else { LogMessage(message); LogMessage("Could not send the previous message to clients because WorldInfo0 was not found."); } } // Try to grab the WorldInfo. private static function WorldInfo GetWorldInfo() { return WorldInfo(FindObject("WorldInfo_0", class'WorldInfo')); }