Getting only the local player's car info with the plugin ?

JohnW63

I know it was mentioned in one of my threads, but I can't find it now.

I have worked out a plugin to check for a tire change in pits stops, which seems to work fine, in testing sessions, but gets lost when there are multiple cars. I suspect the "mInPits" variable needs to be checked ONLY when the local player is in the pits, not just any car. I tried using the IsPlayer variable but it hasn't worked , yet.

What I need is to know when the local player is in the pits and track their pit stop.
 
When you run through all the vehicles in UpdateScoring you should be testing for mIsPlayer (I think). If that's true the current vehicle index is the local player's - so then you check the mInPits value for that index. I'm pretty sure I've used it for a couple of things I've done so it should be reliable.
 
Yep, mIsPlayer is what you want to test. You can do something like this:
Code:
for( long i = 0; i < info.mNumVehicles; ++i ){
	VehicleScoringInfoV2 &vinfo = info.mVehicle[ i ];
	if(mIsPlayer[i]){
		//Do your stuff here
	}
	else{
		Return;
	}
}
 
This is what I've tried, so far:

Code:
VehicleScoringInfoV2 &vinfo = info.mVehicle[ i ];
	  if ( vinfo.mIsPlayer = true ) {
	  mCarInPits = vinfo.mInPits; 
	  mLapCount = vinfo.mTotalLaps; 
	  mStopCount = vinfo.mNumPitstops; 
	  }

Where the left hand variables are ones I created to access from the updatetelemetry section.

That hasn't worked. It doesn't output any pitstops from the telelmetry. It works in single car mode.
 
You forgot to put the index on mIsPlayer and you need to use two equal sings (==) when testing values.

It should look like this:
Code:
for( long i = 0; i < info.mNumVehicles; ++i ){
	VehicleScoringInfoV2 &vinfo = info.mVehicle[ i ];
	if(vinfo.mIsPlayer[i]){
		mCarInPits = vinfo.mInPits; 
		mLapCount = vinfo.mTotalLaps; 
		mStopCount = vinfo.mNumPitstops; 
	}
}

Note: if(vinfo.mIsPlayer){} is the same thing as saying if(vinfo.mIsPlayer == True){}. It's just less typing. :)
 
I get an error when I add the index. It says I need a pointer for that. Since it's already in a loop, going through all the cars, and incrementing , I didn't think I needed it.

I can't believe I messed up the = for == again.
 
Code:
	for (int i = info.mNumVehicles; i--; ) {
		if (info.mVehicle[i].mIsPlayer) {

That's what I have... I'm not sure why Noel has the extra index there either.
 
That's what I have... I'm not sure why Noel has the extra index there either.

Hahaha.. I guess I was having a Senior moment at just 35 years old.

Code:
for( long i = 0; i < info.mNumVehicles; ++i ){
	VehicleScoringInfoV2 &vinfo = info.mVehicle[ i ];
	if(vinfo.mIsPlayer){
		mCarInPits = vinfo.mInPits; 
		mLapCount = vinfo.mTotalLaps; 
		mStopCount = vinfo.mNumPitstops; 
	}
}

There, that is better. :)
 
Yep. That works. The darn "==" keeps giving me senior moments. It's not that I don't know the difference, it's that my brain doesn't remember I'm reading C code.
 

Back
Top