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

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
User avatar
adamkooo2
Posts: 1347
Joined: 13 Jun 2014, 08:43
Location: Slovakia // Slovensko
Contact:

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

Post by adamkooo2 » 07 May 2019, 18:46

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:
/\rkady
Image

User avatar
Eole
Nadeo
Nadeo
Posts: 1261
Joined: 26 Apr 2011, 21:08

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

Post by Eole » 13 May 2019, 16:02

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)	{
	...
}
Contribute to the ManiaPlanet documentation on GitHub
A question about ManiaScript? Ask it here!

User avatar
adamkooo2
Posts: 1347
Joined: 13 Jun 2014, 08:43
Location: Slovakia // Slovensko
Contact:

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

Post by adamkooo2 » 13 May 2019, 18:35

Image
It seems that it gets the ghost somehow, but not his score
/\rkady
Image

User avatar
Eole
Nadeo
Nadeo
Posts: 1261
Joined: 26 Apr 2011, 21:08

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

Post by Eole » 14 May 2019, 13:18

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 ?
Contribute to the ManiaPlanet documentation on GitHub
A question about ManiaScript? Ask it here!

Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 1 guest