Hi, I'm trying to use WantsToDisplayMessage() to display a simple message in the chat when my plugin starts up correctly. I can't seem to do that. This is the relevant part of the code I'm trying to use: Code: bool WantsToDisplayMessage( MessageInfoV01 &msgInfo ) { static bool displayed_welcome = false; static const char message_text[128] = "Delta-Best Plugin enabled!"; if (! displayed_welcome) { displayed_welcome = true; msgInfo.mDestination = 1; /* Chat */ msgInfo.mTranslate = 0; /* Don't translate */ strncpy(msgInfo.mText, message_text, sizeof(message_text)); return true; } return false; } What am I doing wrong?
I see the problem. You are initializing displayed_welcome everytime so it is always going to be set to false before you test. You need to move move that variable out of the function and into a global area.
Oh, ok, then I misunderstood how static works in methods. Thanks, I'll try that. I'm sure it will work.
Here's a copy of code from a plug-in I wrote a while ago, and this does display a message in the message center: Code: bool LapDistancePlugin::WantsToDisplayMessage( MessageInfoV01 &msgInfo ) { if (mReportLapDistance == true) { msgInfo.mDestination = 0; msgInfo.mTranslate = 0; sprintf(msgInfo.mText, "Distance: %.0lfm", mLapDistance); mReportLapDistance = false; return true; } return false; } Edit: Ah, could it be the "<class name>::" prefix that is missing in your code? In that case it just becomes a local method I think, which would explain that it doesn't work. It's simply never called.
Bingo! Thanks Jorgen, that must be the problem, no doubt (the missing class name). I haven't tried yet, but I'm going to in a few minutes
The missing class name was one problem. The other was that I have to wait until the EnterRealtime event before sending a message, or the message will be lost!
Are you sure it is lost or is this something to do with the 15sec delay before the plugin is loaded? I hate this stupid delay when trying to troubleshoot.
Well, the plugin is indeed loaded before EnterRealtime. The message is triggered as soon as the plugin icon goes away now, so I'm happy
Is this supposed to work with DX11? I have spent an hour now testing, and the function doesn't seem to be called at all.