Forum Mod Bakery Docs

I am having mission script troubles

Posted in Support
Please login to contribute to the conversation.
[deleted user]
8 yrs ago (Statistics)
Hello, I need some help debugging my scripts for why my mod is crashing.
m2sdi.mfk
SelectMission("m2sd");  // m1sd

SetMissionResetPlayerOutCar("m2_marge_2","m2_margecar_2");
SetDynaLoadData("l4z7.p3d;l4r6.p3d;l4r7.p3d;");

UsePedGroup(6);

AddStage(0);
		SetMaxTraffic(3); 
		SetStageMessageIndex(33);
		SetHUDIcon("cemetery")
		AddObjective("goto");
			AddNPC("bart","m4_moleman_sd");
			SetDestination("m5_graveyard");
			SetStageTime(30);
		CloseObjective();
CloseStage();

AddStage(1);
	SetStageMissionIndex(25);
	SetHUDIcon("lisa");
	AddObjective("timer");
		SetDurationTime(3);
	CloseObjective();
CloseStage();

AddStage(2);
	SetStageMissionIndex(26);
	SetHUDIcon("bart");
	AddObjective("timer");
		SetDurationTime(3);
	CloseObjective();
CloseStage();

AddStage(3);
	SetStageMissionIndex(27);
	SetHUDIcon("lisa");
	AddObjective("timer");
		SetDurationTime(3);
	CloseObjective();
CloseStage();

AddStage("final");
	SetStageMissionIndex(28);
	SetHUDIcon("bart");
	AddObjective("timer");
		SetDurationTime(3);
	CloseObjective();
CloseStage();

CloseMission();
m2i.mfk
SelectMission("m2"); // m1

SetMissionResetPlayerInCar("m5_graveyard");
SetDynaLoadData("l4z7.p3d;l4r6.p3d;l4r7.p3d;");

UsePedGroup(6);

AddStage(0); // find the armored car
	SetMaxTraffic(5);
	SetStageMessageIndex(29);
	AddObjective("goto");
		SetDestination("m5_grampa_sd", "carsphere");
		SetCollectibleEffect("wrench_collect");
	CloseObjective();
	AddCondition("outofvehicle");
		SetCondTime( 10000 );
	CloseCondition();
	AddCondition( "damage" );
		SetCondMinHealth( 0.0 );
		SetCondTargetVehicle( "elect_v" );
	CloseCondition();
CloseStage();

AddStage(1);
	SetStageMessageIndex(30);
	SetMaxTraffic(3);
	ActivateVehicle("cArmor","NULL","target");
	SetVehicleAIParams( "cArmor", -10, -9 ); //  <=== name, min, max; 0,1 = really dumb, no shortcuts
	AddStageWaypoint( "m2_waypoint1" );
	AddStageWaypoint( "m2_waypoint2" );
	AddStageWaypoint( "m2_waypoint3" );
	AddStageWaypoint( "m2_waypoint4" );
	AddStageWaypoint( "m2_waypoint5" );
	AddStageWaypoint( "m2_waypoint6" );
	AddStageWaypoint( "m2_waypoint1" );
	AddStageWaypoint( "m2_waypoint2" );
	AddStageWaypoint( "m2_waypoint3" );
	AddStageWaypoint( "m2_waypoint4" );
	AddStageWaypoint( "m2_waypoint5" );
	AddStageWaypoint( "m2_waypoint6" );
	AddObjective("destroy");
		SetObjTargetVehicle("cArmor");
	CloseObjective();
	AddStageTime(210);
	AddCondition("timeout");
		//SetHitNRun();
	CloseCondition();
	AddCondition("outofvehicle");
		SetCondTime( 10000 );
	CloseCondition();
	AddCondition( "damage" );
		SetCondMinHealth( 0.0 );
		SetCondTargetVehicle( "elect_v" );
	CloseCondition();
	ShowStageComplete();
CloseStage();
m2l.mfk
LoadP3DFile( "art\missions\level01\m2.p3d" );

LoadDisposableCar( "art\cars\cArmor.p3d","cArmor","AI" );
m2sdl.mfk
LoadP3DFile( "art\frontend\dynaload\images\msnicons\char\lisa.p3d" );
LoadP3DFile( "art\frontend\dynaload\images\msnicons\char\bart.p3d" );
LoadP3DFile( "art\frontend\dynaload\images\msnicons\location\cemetery.p3d" );

thanks,

hipporeno
You're not closing the mission if that's relevant. Make sure all your files end with:
CloseMission();

You're also using elect_v as the target car. This is for AI cars that have been added, which I do not see them in action.
To add on to @Jake's solution, in your m2i file, there isn't a location for the armored car to spawn in the first stage, therefore making the game confused as to how to activate a vehicle that doesn't exist yet.

Also, why are you adding a time limit in your m2sdi file?
Yes, do not use time limit in a pre-mission, it will corrupt the game.
I also noticed this:

AddCondition( "damage" );
        SetCondMinHealth( 0.0 );
        SetCondTargetVehicle( "elect_v" );
 CloseCondition();

Why is "elect_v" in here? This is also present in the "find the armored car" stage, yet as far as I can tell you're not forcing the player to use this car. This condition doesn't actually do anything in the final game as far as I know (yet Radical seems to use it in every forced car stage), but referring to a car that isn't used might also cause corruption somehow.

To add to SomeBot's statement, you can either replace
ActivateVehicle("cArmor","NULL","target");
with
AddStageVehicle("cArmor","locator_for_car_to_spawn","target","rlyhrd.con", "car_driver_name");
, or add
AddStageVehicle("cArmor","locator_for_car_to_spawn","NULL","rlyhrd.con", "car_driver_name");
to the "find the armored car" stage. The first option will cause the armored car to instantly spawn with the behavior you want right out of thin air, while the second option will spawn the car ahead of time and wait until "ActivateVehicle" tells it what to do next.
[deleted user]
8 yrs ago (Statistics)
wow, thanks guys for the help!