Jump to content
Ghost Graphic Designs

Script problem (Instant CTD)

Recommended Posts

Hi.

 

I've recently been working on some sort of german-style dispatch system 

The alarm script is basically a system in which you select a person with a script for each vehicle. It plays an alarm sound, spawns the personnel on the specified VO and sends them to their vehicle (which has a custom name specified in the properties editor), after that, the vehicle turns on its lights and goes to the location that the player selected.

The scripts are added via-freeplayscript, in which the dispatcher also has a custom name. You add the scripts that you'd like the dispatcher to have and also the group that it belongs to (1,2,3,4,etc.), after that, you're all set. for a private project and I've crossed into a problem:

  • Whenever the dispatcher has more than 1 alarm-script on the commands section, it crashes right when I click the unit.
  • If the dispatcher only has 1 alarm script it works fine.

I also took a look into the logfile and the only thing that looks abnormal is the classic: !WARNING: global listener object is still registered! Unregister listener before destroying object! 

 

Two alarm scripts and part of the fp_freeplay script (the dispatcher group and script assignments) are below:

 

ALARMSCRIPT 1:

//////////////////////////////////////////////////////////////////////////////////////////////////////////// Script de alarme de viaturas	   								                                        //// ************************************************							                            ////													                                                    ////	1.0| AlarmVIATURA X										                                            ////													                                                    //// _____________________										                                        //// original por a-rescue. Editado por Ghost Graphic Designs                                  		    //// Edições não permitidas sem autorização									                            ////////////////////////////////////////////////////////////////////////////////////////////////////////////const char IMG_ICON[]           = "absc33";  // Name des Iconsconst char IMG_CURSOR[]         = "sendto";  // Name des Cursorsconst char COMMANDABLE_TRUE[]   = "DUMMYSetCommandableTrue";const char COMMANDABLE_FALSE[]  = "DUMMYSetCommandableFalse";const char FREEFORALERT_TRUE[]  = "DUMMYFPSetFreeForAlertTrue";const char FREEFORALERT_FALSE[] = "DUMMYFPSetFreeForAlertFalse";const char FREEFORALERT[]       = "DUMMYFPIsFreeForAlert";const char INBASE_TRUE[]        = "DUMMYFPSetInBaseTrue";const char INBASE_FALSE[]       = "DUMMYFPSetInBaseFalse";const char INBASE[]             = "DUMMYFPIsInBase";// 1.0object AlarmABSC03 : CommandScript  // Name des Commands{	AlarmABSC03()               // Name des Commands	{		SetIcon(IMG_ICON);		SetCursor(IMG_CURSOR);		SetValidTargets(ACTOR_FLOOR | ACTOR_STREET);	}		bool CheckPossible(GameObject *Caller)	{		GameObjectList ol;		GameObject *o;		ol = Game::GetGameObjects("ABSC03"); //Name des zu alarmierenden Fahrzeuges		o = *ol.GetObject(0);		Vehicle v(o);		if (!v.HasCommand(FREEFORALERT))			return false;					return true;	}		bool CheckTarget(GameObject *Caller, Actor *Target, int childID)	{		if (Caller->GetID() == Target->GetID())			return false;					return true;	}		void PushActions(GameObject *Caller, Actor *Target, int childID)	{		GameObjectList ol;		GameObject *o;		ActorList al;		Actor spawnpoint;		Vector spawnpos;		float rot[9];		float childRot[9];		Vector tpos;		PersonList pl;        Person p;            ActorList al;		Actor spawnpoint;		Vector spawnpos;		ol = Game::GetGameObjects("ABSC03");  //Name des zu alarmierenden Fahrzeuges		o = *ol.GetObject(0);		Vehicle v(o);		if (v.IsDestroyed())		{			Mission::PlayHint("A viatura está inoperacional e não está disponível de momento.");			return;		}		if (!v.HasCommand(FREEFORALERT))		{			Mission::PlayHint("Veículo está ocupado numa ocorrência.");			return;		}		else		{			Mission::PlayHint("Saída da ABSC 03!");   //Alarmmeldung die angezeigt werden soll			Audio::PlaySample("mod:Audio/FX/sinos.wav");  //Pfad zum Alarmsound der abspielt werden soll			v.PushActionExecuteCommand(ACTION_NEWLIST, FREEFORALERT_FALSE, &v, 1, true);            al=Game::GetActors("lisbonenses_persons");  //Name des viruelles Objektes wo die EinsatzkrŠfte erstellt werden soll			if(al.GetNumActors() > 0)			{				spawnpoint = *al.GetActor(0);				spawnpos   = spawnpoint.GetPosition();			}			else			{				Mission::PlayHint("Pessoal não foi encontrado!");				return;			}			bool ob_personal = false;			pl = v.GetPassengers();			for(int i=0; i < pl.GetNumPersons(); i++)			{				if (pl.GetPerson(i)->HasCommand("entercar"))				{					ob_personal = true;				}			}			bool vinbase = false;			if(v.HasCommand(INBASE))			{				vinbase = true;			}//Personal Block////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			if (!ob_personal && vinbase)			{				p = Game::CreatePerson("mod:Prototypes/Persons/01 TAS/TAS1.e4p","ABSC03"); //Pfad zum Prototyp der Einsatzkraft & Name der Einsatzkraft (wie Fahrzeug)				p.GetRotation(rot[0], rot[1], rot[2], rot[3], rot[4], rot[5], rot[6], rot[7], rot[8]);				Math::EulerToMatrix(0.f, 0.f, 0.f, childRot);				Math::MultiplyMatrices(childRot, rot);				p.SetRotation(childRot[0], childRot[1], childRot[2], childRot[3], childRot[4], childRot[5], childRot[6], childRot[7], childRot[8]);				GameObject *px(p);				Game::FindFreePosition(px, spawnpos, 100);				p.SetPosition(spawnpos);				p.PushActionExecuteCommand(ACTION_NEWLIST, COMMANDABLE_FALSE, &p, 1, true);				p.PushActionExecuteCommand(ACTION_APPEND, COMMANDABLE_TRUE, &p, 1, true);				p.PushActionExecuteCommand(ACTION_APPEND, "entercar", o, 0, false);			}//Personal Block////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			if (!ob_personal && vinbase)			{				p = Game::CreatePerson("mod:Prototypes/Persons/01 TAS/TAS1.e4p","ABSC03"); //Pfad zum Prototyp der Einsatzkraft & Name der Einsatzkraft (wie Fahrzeug)				p.GetRotation(rot[0], rot[1], rot[2], rot[3], rot[4], rot[5], rot[6], rot[7], rot[8]);				Math::EulerToMatrix(0.f, 0.f, 0.f, childRot);				Math::MultiplyMatrices(childRot, rot);				p.SetRotation(childRot[0], childRot[1], childRot[2], childRot[3], childRot[4], childRot[5], childRot[6], childRot[7], childRot[8]);				GameObject *px(p);				Game::FindFreePosition(px, spawnpos, 100);				p.SetPosition(spawnpos);				p.PushActionExecuteCommand(ACTION_NEWLIST, COMMANDABLE_FALSE, &p, 1, true);				p.PushActionExecuteCommand(ACTION_APPEND, COMMANDABLE_TRUE, &p, 1, true);				p.PushActionExecuteCommand(ACTION_APPEND, "entercar", o, 0, false);			}//FŸr weitere EinsatzkrŠfte einfach neue Blšcke hier hinzufŸgen			bool ready = false;			if (ob_personal)			{				ready= true;			}			if (vinbase)			{				v.PushActionWait(ACTION_APPEND, 8.0); //Zeit bevor Tor aufgeht				v.PushActionExecuteCommand(ACTION_APPEND, "VcmdFlashingLights", o, 0, false);		        v.PushActionWait(ACTION_APPEND, 3.0); //Zeit bis Fahrzeug fŠhrt nachdem das Tor offen ist			}			if (!ready && !vinbase))			{				Mission::PlayHint("Sem pessoal é impossível sair!");			}			v.PushActionExecuteCommand(ACTION_APPEND, COMMANDABLE_TRUE, &v, 1, true);			if(!v.HasCommand("DUMMYHasSiren"))			{				v.PushActionExecuteCommand(ACTION_APPEND, "VCmdSiren", o, 0, false);			}			v.PushActionExecuteCommand(ACTION_APPEND, INBASE_FALSE, &v, 1, true);			if (ready && !vinbase))			{                            if(!v.HasCommand("DUMMYHasSiren"))			    {					v.PushActionExecuteCommand(ACTION_APPEND, "VCmdSiren", o, 0, false);			    }			} 			tpos = Game::GetCommandPos();			v.PushActionMove(ACTION_APPEND, tpos);		}	}};

ALARMSCRIPT2:

//////////////////////////////////////////////////////////////////////////////////////////////////////////// Script de alarme de viaturas	   								                                        //// ************************************************							                            ////													                                                    ////	1.0| AlarmVIATURA X										                                            ////													                                                    //// _____________________										                                        //// original por a-rescue. Editado por Ghost Graphic Designs                                  		    //// Edições não permitidas sem autorização									                            ////////////////////////////////////////////////////////////////////////////////////////////////////////////const char IMG_ICON[]           = "absc01";  // Name des Iconsconst char IMG_CURSOR[]         = "sendto";  // Name des Cursorsconst char COMMANDABLE_TRUE[]   = "DUMMYSetCommandableTrue";const char COMMANDABLE_FALSE[]  = "DUMMYSetCommandableFalse";const char FREEFORALERT_TRUE[]  = "DUMMYFPSetFreeForAlertTrue";const char FREEFORALERT_FALSE[] = "DUMMYFPSetFreeForAlertFalse";const char FREEFORALERT[]       = "DUMMYFPIsFreeForAlert";const char INBASE_TRUE[]        = "DUMMYFPSetInBaseTrue";const char INBASE_FALSE[]       = "DUMMYFPSetInBaseFalse";const char INBASE[]             = "DUMMYFPIsInBase";// 1.0object AlarmABSC01 : CommandScript  // Name des Commands{	AlarmABSC01()               // Name des Commands	{		SetIcon(IMG_ICON);		SetCursor(IMG_CURSOR);		SetValidTargets(ACTOR_FLOOR | ACTOR_STREET);	}		bool CheckPossible(GameObject *Caller)	{		GameObjectList ol;		GameObject *o;		ol = Game::GetGameObjects("ABSC01"); //Name des zu alarmierenden Fahrzeuges		o = *ol.GetObject(0);		Vehicle v(o);		if (!v.HasCommand(FREEFORALERT))			return false;					return true;	}		bool CheckTarget(GameObject *Caller, Actor *Target, int childID)	{		if (Caller->GetID() == Target->GetID())			return false;					return true;	}		void PushActions(GameObject *Caller, Actor *Target, int childID)	{		GameObjectList ol;		GameObject *o;		ActorList al;		Actor spawnpoint;		Vector spawnpos;		float rot[9];		float childRot[9];		Vector tpos;		PersonList pl;        Person p;            ActorList al;		Actor spawnpoint;		Vector spawnpos;		ol = Game::GetGameObjects("ABSC01");  //Name des zu alarmierenden Fahrzeuges		o = *ol.GetObject(0);		Vehicle v(o);		if (v.IsDestroyed())		{			Mission::PlayHint("A viatura está inoperacional e não está disponível de momento.");			return;		}		if (!v.HasCommand(FREEFORALERT))		{			Mission::PlayHint("Veículo está ocupado numa ocorrência.");			return;		}		else		{			Mission::PlayHint("Saída da ABSC 01!");   //Alarmmeldung die angezeigt werden soll			Audio::PlaySample("mod:Audio/FX/sinos.wav");  //Pfad zum Alarmsound der abspielt werden soll			v.PushActionExecuteCommand(ACTION_NEWLIST, FREEFORALERT_FALSE, &v, 1, true);            al=Game::GetActors("lisbonenses_persons");  //Name des viruelles Objektes wo die EinsatzkrŠfte erstellt werden soll			if(al.GetNumActors() > 0)			{				spawnpoint = *al.GetActor(0);				spawnpos   = spawnpoint.GetPosition();			}			else			{				Mission::PlayHint("Pessoal não foi encontrado!");				return;			}			bool ob_personal = false;			pl = v.GetPassengers();			for(int i=0; i < pl.GetNumPersons(); i++)			{				if (pl.GetPerson(i)->HasCommand("entercar"))				{					ob_personal = true;				}			}			bool vinbase = false;			if(v.HasCommand(INBASE))			{				vinbase = true;			}//Personal Block////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			if (!ob_personal && vinbase)			{				p = Game::CreatePerson("mod:Prototypes/Persons/01 TAS/TAS1.e4p","ABSC01"); //Pfad zum Prototyp der Einsatzkraft & Name der Einsatzkraft (wie Fahrzeug)				p.GetRotation(rot[0], rot[1], rot[2], rot[3], rot[4], rot[5], rot[6], rot[7], rot[8]);				Math::EulerToMatrix(0.f, 0.f, 0.f, childRot);				Math::MultiplyMatrices(childRot, rot);				p.SetRotation(childRot[0], childRot[1], childRot[2], childRot[3], childRot[4], childRot[5], childRot[6], childRot[7], childRot[8]);				GameObject *px(p);				Game::FindFreePosition(px, spawnpos, 100);				p.SetPosition(spawnpos);				p.PushActionExecuteCommand(ACTION_NEWLIST, COMMANDABLE_FALSE, &p, 1, true);				p.PushActionExecuteCommand(ACTION_APPEND, COMMANDABLE_TRUE, &p, 1, true);				p.PushActionExecuteCommand(ACTION_APPEND, "entercar", o, 0, false);			}//Personal Block////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			if (!ob_personal && vinbase)			{				p = Game::CreatePerson("mod:Prototypes/Persons/01 TAS/TAS1.e4p","ABSC01"); //Pfad zum Prototyp der Einsatzkraft & Name der Einsatzkraft (wie Fahrzeug)				p.GetRotation(rot[0], rot[1], rot[2], rot[3], rot[4], rot[5], rot[6], rot[7], rot[8]);				Math::EulerToMatrix(0.f, 0.f, 0.f, childRot);				Math::MultiplyMatrices(childRot, rot);				p.SetRotation(childRot[0], childRot[1], childRot[2], childRot[3], childRot[4], childRot[5], childRot[6], childRot[7], childRot[8]);				GameObject *px(p);				Game::FindFreePosition(px, spawnpos, 100);				p.SetPosition(spawnpos);				p.PushActionExecuteCommand(ACTION_NEWLIST, COMMANDABLE_FALSE, &p, 1, true);				p.PushActionExecuteCommand(ACTION_APPEND, COMMANDABLE_TRUE, &p, 1, true);				p.PushActionExecuteCommand(ACTION_APPEND, "entercar", o, 0, false);			}//FŸr weitere EinsatzkrŠfte einfach neue Blšcke hier hinzufŸgen			bool ready = false;			if (ob_personal)			{				ready= true;			}			if (vinbase)			{				v.PushActionWait(ACTION_APPEND, 8.0); //Zeit bevor Tor aufgeht				v.PushActionExecuteCommand(ACTION_APPEND, "VcmdFlashingLights", o, 0, false);		        v.PushActionWait(ACTION_APPEND, 3.0); //Zeit bis Fahrzeug fŠhrt nachdem das Tor offen ist			}			if (!ready && !vinbase))			{				Mission::PlayHint("Sem pessoal é impossível sair!");			}			v.PushActionExecuteCommand(ACTION_APPEND, COMMANDABLE_TRUE, &v, 1, true);			if(!v.HasCommand("DUMMYHasSiren"))			{				v.PushActionExecuteCommand(ACTION_APPEND, "VCmdSiren", o, 0, false);			}			v.PushActionExecuteCommand(ACTION_APPEND, INBASE_FALSE, &v, 1, true);			if (ready && !vinbase))			{                            if(!v.HasCommand("DUMMYHasSiren"))			    {					v.PushActionExecuteCommand(ACTION_APPEND, "VCmdSiren", o, 0, false);			    }			} 			tpos = Game::GetCommandPos();			v.PushActionMove(ACTION_APPEND, tpos);		}	}};

DISPATCHER SCRIPT:

// DISPATCHERS - GROUP & SCRIPTS		GameObject *ofz;		GameObjectList lfz;		lfz=Game::GetGameObjects("central");        //Dispatcher 1 name		if(lfz.GetNumObjects() > 0)		{			ofz = *lfz.GetObject(0);			ofz->AssignCommand("AlarmABSC01");  //AlarmScript			ofz->AssignCommand("AlarmABSC02");  //AlarmScript			ofz->AssignCommand("AlarmABSC03");  //AlarmScript			ofz->AssignCommand("AlarmABSC04");  //AlarmScript			ofz->AssignCommand("AlarmABSC05");  //AlarmScript			ofz->AssignCommand("AlarmVUCI04");  //AlarmScript                        //Add aditional scripts here			Game::AddToGroup(ofz,0);			System::Log("STARTSCRIPT: Disponenten Platz 1 wurde erfolgreich eingerichtet.");		}		else System::Log("STARTSCRIPT - FEHLER: Disponenten 1 Platz wurde nicht gefunden ! ! ! !");		lfz=Game::GetGameObjects("central_psp");      //Name des 2. Dispo		if(lfz.GetNumObjects() > 0)		{			ofz = *lfz.GetObject(0);			ofz->AssignCommand("rufe_psp1");  //Name des Commands um das 4.Fahrzeuge zu alarmieren			ofz->AssignCommand("rufe_psp2");  //Name des Commands um das 3.Fahrzeuge zu alarmieren                        //Weitere Commands hier einfügen			Game::AddToGroup(ofz,1);			System::Log("STARTSCRIPT: Disponenten Platz 2 wurde erfolgreich eingerichtet.");		}		else System::Log("STARTSCRIPT - FEHLER: Disponenten Platz 2 wurde nicht gefunden ! ! ! !");		lfz=Game::GetGameObjects("disp3");      //Name des 3. Dispo		if(lfz.GetNumObjects() > 0)		{			ofz = *lfz.GetObject(0);			ofz->AssignCommand("rufe_inem1");  //Name des Commands um das 5.Fahrzeuge zu alarmieren			ofz->AssignCommand("rufe_inem2");  //Name des Commands um das 6.Fahrzeuge zu alarmieren			ofz->AssignCommand("rufe_inem3");  //Name des Commands um das 5.Fahrzeuge zu alarmieren			ofz->AssignCommand("rufe_vmer");  //Name des Commands um das 6.Fahrzeuge zu alarmieren                        ofz->AssignCommand("rufe_vmer2");  //Name des Commands um das 5.Fahrzeuge zu alarmieren                        //Weitere Commands hier einfügen			Game::AddToGroup(ofz,2);			System::Log("STARTSCRIPT: Disponenten Platz 3 wurde erfolgreich eingerichtet.");		}		else System::Log("STARTSCRIPT - FEHLER: Disponenten Platz 3 wurde nicht gefunden ! ! ! !");		lfz=Game::GetGameObjects("disp4");      //Name des 4. Dispo		if(lfz.GetNumObjects() > 0)		{			ofz = *lfz.GetObject(0);			ofz->AssignCommand("rufe_absc1");  //Name des Commands um das 7.Fahrzeuge zu alarmieren			ofz->AssignCommand("rufe_absc2");  //Name des Commands um das 8.Fahrzeuge zu alarmieren			//Weitere Commands hier einfügen			Game::AddToGroup(ofz,3);			System::Log("STARTSCRIPT: Disponenten Platz 4 wurde erfolgreich eingerichtet.");		}		else System::Log("STARTSCRIPT - FEHLER: Disponenten Platz 4 wurde nicht gefunden ! ! ! !");

Don't mind the German commentaries, basically it's just some guidelines to add variables like vehicle names, prototypes, other scritps and stuff like that.

 

 

 

Thanks in advance. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...