Page 1 of 1

[BUG + CTD] Unable to use custom ghost by script due to CTD

Posted: 07 May 2019, 18:46
by adamkooo2
Hi guys!

I made a Gamemode called Endurance, from idea by ThaumicTom. The mode ends therace in the middle of the normal race, when the race timer is on "0:00". The map record is saved by 2 functions: ScoreMgr.Map_SetNewRecord() and Solo_SetNewRecord().When I put wait command, it waits forever, without any error. No wait condiction really worked, I used wait(GhostP!=Null); , but it didn't work.

The code for saving the ghost: (info: ScoreMgr.Map_SetNewRecord() is skipped in all cases, cos GhostP is equal Null)

Code: Select all

	declare CGhost GhostP;
	declare persistent Integer EnduraceRecord for Map;	
	
	if(Players[0].CurRace.Score > EnduraceRecord)	{
		GhostP = ScoreMgr.Playground_GetPlayerGhost(Players[0]);
	
		Players[0].Score.BestRace.Score = Players[0].CurRace.Score;
		Players[0].Score.BestRace = Players[0].CurRace;
		EnduraceRecord = Players[0].Score.BestRace.Score;
	}
		
	if (Players[0].RaceStartTime != 0)	{
		//continue;
		UIManager.UIAll.UISequence = CUIConfig::EUISequence::None;
		sleep(1000);
		TM::Players_UnspawnAll();
	}
	
	if (GhostP != Null)	{
		ScoreMgr.Map_SetNewRecord(Players[0].Id, Map.MapInfo.MapUid, _ScContext, GhostP);	
	}
	else
	log("ghost is null");
	
	Solo_SetNewRecord(Players[0].Score, RaceLib::CalcRecordEndurance(Players[0].Score.BestRace.Score));
The code to load the user record:

Code: Select all

	declare CTaskResult_Ghost Ghost0;
	
	Ghost0 = ScoreMgr.Map_GetRecordGhost(Players[0].Id, Map.MapInfo.MapUid, ScContext);
	wait(!Ghost0.IsProcessing);
	if (Ghost0.Ghost != Null)	{
		Players[0].Score.BestRace = Ghost0.Ghost.Result;		
		RaceGhost_Add(Ghost0.Ghost, True);
	}
	
The code works normally in Race/Platform/Stunt mode, but not in Endurance mode, because the script saves the ghost in middle of the race, which causes CTD on load.

Thanks for your help :thx:

Re: [BUG + CTD] Unable to use custom ghost by script due to CTD

Posted: 13 May 2019, 16:02
by Eole
If you add a log before the if, does it return Null for the Ghost too ?

Code: Select all

declare CGhost GhostP;
declare persistent Integer EnduraceRecord for Map;
	
log(Now^"> Ghost : "^ScoreMgr.Playground_GetPlayerGhost(Players[0]));
	
if(Players[0].CurRace.Score > EnduraceRecord)	{
	...
}

Re: [BUG + CTD] Unable to use custom ghost by script due to CTD

Posted: 13 May 2019, 18:35
by adamkooo2
Image
It seems that it gets the ghost somehow, but not his score

Re: [BUG + CTD] Unable to use custom ghost by script due to CTD

Posted: 14 May 2019, 13:18
by Eole
adamkooo2 wrote: 13 May 2019, 18:35 but not his score
What do you mean ?

In the code sample you provided you retrieve the ghost only if the player improve the map record. So the ghost will be non Null only when the player beat the record. Yet you still update the record with Solo_SetNewRecord() in all cases later in the code. Is this normal ?