Plugin development Chat text

C.Blanquer

Hi everyone!

I started to develop plugins for rFactor, i've downloaded the Internal Plugins examples and i've looked plugins.

I want to send automatic messages each 20 seconds(by example)

My function:

Code:
bool ExampleInternalsPlugin::RequestCommentary( CommentaryRequestInfo &info )
{
  // COMMENT OUT TO ENABLE EXAMPLE
  //return( false );
	
  // only if enabled, of course
  if( !mEnabled )
    return( false );

	FILE *fo = fopen( "examplefile.txt", "a" ); //Write a file to see if this function is being called, and it is.
	if( fo != NULL )
	{
		fprintf(fo, "SAMPLE\n");
		fclose( fo );
	}
	
  // Note: function is called twice per second

  // Say green flag event for no particular reason every 20 seconds ...
  const float timeMod20 = fmodf( mET, 20.0f );
  if( timeMod20 > 19.0f )
  {
    strcpy( info.mName, "GreenFlag" );
    info.mInput1 = 0.0f;
    info.mInput2 = 0.0f;
    info.mInput3 = 0.0f;
    info.mSkipChecks = true;
    return( true );
  }
    return( false );
}

Could someone give me a little help?

Thanks in advance!
 
RequestCommentary() function is for spoken commentary (Green Flag announcement for example), not for the chat messages.

Do you want to write a chat message as text?

EDIT: sorry I didn't understand this was for rF1.
 
Hi cosimo.

Yep, I'm trying to write a chat message as text for rF1, yesterday I got this function works, but I realized that this function was for spoken commentary (as you mentioned).

Now I'm trying to do something like this post which you replied 2 years ago.

If I get something, I'll let you know

Thanks!
 
Yes cosimo, I want to write chat messages in rF1, but I don't know if it possible

Best regards!
 
Im trying to call it in UpdateScoring function, but I don't know how i should declare a new MessageInfoV01 object.

This is that I have:

function:

bool WantsToDisplayMessage( MessageInfoV01 &msgInfo ) {
msgInfo.mDestination = 0;
msgInfo.mTranslate = 0;
sprintf(msgInfo.mText, "HOLA");
//mReportLapDistance = false;
return true;
}

Update scoring function
UpdateScoring( const ScoringInfoV2 &info ) {
...
MessageInfoV01 a;
WantsToDisplayMessage(a);
...
}

The identifier 'a' is not defined

How do I should do that?

Thanks in advance!
 
The way the plugin system works is the game calls the functions on its own. Some functions are called more frequently than others. UpdateScoring for example is called 5 times per second. I'm not sure what the exact rate is on wantstodisplaymessage is though. Basically if you return a true it will display your message. If you return a false it does nothing. So you have to create your own logic to handle when to return a true. For example you could increment a counter and every time wantstodisplaymessage is called and send a message when the counter is incremented enough to be 20secs.
 

Back
Top