Jump to content


Photo

New vehicles and problems with adding sirens [Submod]


  • Please log in to reply
6 replies to this topic

#1 SondreEinarsen

SondreEinarsen

    Lieutenant

  • Members
  • 35 posts

Posted 01 November 2014 - 07:30 PM

Hi there, guys!

 

Recently I've been doing some modification of the submod "Norway Mod 1,02" which is based on the LA mod. What I've been doing is adding some new vehicles, these are about 22 police cruisers and vans which have been re-skinned and re-named to give a more realistic feel while playing. (F.ex. Bravo 0.1 is a police cruiser with the logo B-01 on the roof)

 

Everything has worked flawlessly (almost), I've given them new logos in-game and everything works except, you guessed it, the sirens.

I've given all vehicles the two commands needed according to the tutorial (VmdSirens, VmdAutoSirensOff) and added them to the LAsiren.script, but in-game the siren just refuses to work.

The button goes gray when pressed and no script errors pop up, I thought this would indicate that I had written it correctly, but no sound is played at all. All the old units have no issues with their sirens, they play just as they should.

 

Here is the script if anybody could be so kind to scan for errors! I've also taken the parts I've added in and copied them to a seperate code form in case anyone wants to see which ones I've added.

const char CMD_AUTOSIREN_OFF[]		= "VcmdAutoSirenOff";
const char EACTION_FINDPATH[] 		= "EActionFindPath";
const char EACTION_EXTINGUISH[] 	= "EActionExtinguish";
const char DUMMY_HASSIREN[] 		= "DummyHasSiren";
const char DUMMY_UPDATEPOS[] 		= "DummyUpdatePos";
const char DUMMY_FINDPATH[] 		= "DummyFindPath";
const char DUMMY_HOSESON[] 			= "DummyHosesAreOn";
const char NAME_DUMMYOBJECT[] 		= "HelpingObjekt_Hoppah";
const char DUMMY_GETTIL[] 			= "DummyGetTiller";

const char PROTO_LEV[]	= "mod:Prototypes/Vehicles/02 LA Fire Department/light_equipment_truck.e4p";
const char PROTO_LRA[]	= "mod:Prototypes/Vehicles/01 LA Ambulance/large_rescue_ambulance.e4p";
const char PROTO_ENGINE01[] = "mod:Prototypes/Vehicles/02 LA Fire Department/fire_engine1.e4p";
const char PROTO_ENGINE02[] = "mod:Prototypes/Vehicles/02 LA Fire Department/fire_engine2.e4p";
const char PROTO_WATERTENDER[] = "mod:Prototypes/Vehicles/02 LA Fire Department/water_tender.e4p";
const char PROTO_LADDER[] = "mod:Prototypes/Vehicles/02 LA Fire Department/aerial_ladder.e4p";
const char PROTO_TILLER[] = "mod:Prototypes/Vehicles/02 LA Fire Department/tiller_cabin.e4p";
const char PROTO_HAZMAT[] = "mod:Prototypes/Vehicles/02 LA Fire Department/hazmat_squad.e4p";
const char PROTO_MOTORBOAT[] = "mod:Prototypes/Vehicles/02 LA Fire Department/swr_truck.e4p";
const char PROTO_CRASHTENDER[] = "mod:Prototypes/Vehicles/02 LA Fire Department/crashtender.e4p";
const char PROTO_USAR[] = "mod:Prototypes/Vehicles/02 LA Fire Department/usar_squad.e4p";
const char PROTO_DYKK[] = "mod:Prototypes/Vehicles/02 LA Fire Department/Waterrescue.e4p";
const char PROTO_MCU01[] = "mod:Prototypes/Vehicles/01 LA Ambulance/mass_casualty_unit.e4p";
const char PROTO_BCV[] = "mod:Prototypes/Vehicles/02 LA Fire Department/battalion_chief_vehicle.e4p";
const char PROTO_BCV2[] = "mod:Prototypes/Vehicles/02 LA Fire Department/hummer_KO.e4p";
const char PROTO_HES[] = "mod:Prototypes/Vehicles/02 LA Fire Department/heavy_equipment_squad.e4p";
const char PROTO_BRUSH[] = "mod:Prototypes/Vehicles/02 LA Fire Department/brush_truck.e4p";
const char PROTO_USFS01[] = "mod:Prototypes/Vehicles/02 LA Fire Department/usfs_utility.e4p";
const char PROTO_USFS02[] = "mod:Prototypes/Vehicles/02 LA Fire Department/usfs_engine.e4p";

const char PROTO_EMS[] = "mod:Prototypes/Vehicles/01 LA Ambulance/cv_ems.e4p";
const char PROTO_AMBULANCE01[] = "mod:Prototypes/Vehicles/01 LA Ambulance/ambulance01.e4p";
const char PROTO_AMBULANCE02[] = "mod:Prototypes/Vehicles/01 LA Ambulance/ambulance02.e4p";
const char PROTO_AMBULANCE03[] = "mod:Prototypes/Vehicles/01 LA Ambulance/ambulance03.e4p";
const char PROTO_AMBULANCE04[] = "mod:Prototypes/Vehicles/01 LA Ambulance/VWAmb1.e4p";
const char PROTO_AMBULANCE05[] = "mod:Prototypes/Vehicles/01 LA Ambulance/sprinter 21.e4p";
const char PROTO_AMBULANCE06[] = "mod:Prototypes/Vehicles/01 LA Ambulance/ambulance07.e4p";
const char PROTO_DOGTRUCK[] = "mod:Prototypes/Vehicles/01 LA Ambulance/suv_rescue_dog.e4p";
const char PROTO_LEGKOM[] = "mod:Prototypes/Vehicles/01 LA Ambulance/legkom.e4p";
const char PROTO_HUMAMB[]	= "mod:Prototypes/Vehicles/01 LA Ambulance/hummerh2_rc.e4p";

const char PROTO_MOTORCYCLE[] = "mod:Prototypes/Vehicles/03 LA Police/motorcycle_lapd.e4p";
const char PROTO_CV_LAPD[] = "mod:Prototypes/Vehicles/03 LA Police/cv_lapd.e4p";
const char PROTO_CV_LAPD_K9[] = "mod:Prototypes/Vehicles/03 LA Police/cv_lapdk9.e4p";
const char PROTO_RESCUE01[] = "mod:Prototypes/Vehicles/03 LA Police/rescue_truck01_lapd.e4p";
const char PROTO_RESCUE02[] = "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p";
const char PROTO_SWAT_TRUCK[] = "mod:Prototypes/Vehicles/03 LA Police/swat_truck.e4p";
const char PROTO_WATERCANNON[] = "mod:Prototypes/Vehicles/03 LA Police/swat_armoured_vehicle.e4p";
const char PROTO_BOMB_SQUAD[] = "mod:Prototypes/Vehicles/03 LA Police/suv_bomb_squad.e4p";
const char PROTO_FBI_SUV[] = "mod:Prototypes/Vehicles/09 Government/fbi_suv.e4p";
const char PROTO_FBI_COMMAND[] = "mod:Prototypes/Vehicles/09 Government/fbi_command.e4p";
const char PROTO_POLDELTAMB[] = "mod:Prototypes/Vehicles/03 LA Police/Politi P003.e4p";
const char PROTO_POLVITO[] = "mod:Prototypes/Vehicles/03 LA Police/swat_MB.e4p";
const char PROTO_DELBLU[] = "mod:Prototypes/Vehicles/03 LA Police/DeltaBlack.e4p";
const char PROTO_SWAT_SUV[]	= "mod:Prototypes/Vehicles/03 LA Police/swat_suv.e4p";
const char PROTO_FEC[] = "mod:Prototypes/Vehicles/03 LA Police/fec_swat.e4p";
const char PROTO_FECUM[] = "mod:Prototypes/Vehicles/03 LA Police/FECUM_black.e4p";
const char PROTO_ARMYMP[] = "mod:Prototypes/Vehicles/05 US Army/Passat mp.e4p";
const char PROTO_CHAUNMK[] = "mod:Prototypes/Vehicles/03 LA Police/dodge_charger_umpc.e4p";
const char PROTO_B1[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo01.e4p";
const char PROTO_B2[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo02.e4p";
const char PROTO_B3[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo03.e4p";
const char PROTO_B4[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo04.e4p";
const char PROTO_B5[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo05.e4p";
const char PROTO_B6[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo06.e4p";
const char PROTO_B7[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo07.e4p";
const char PROTO_B8[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo08.e4p";
const char PROTO_B9[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo09.e4p";
const char PROTO_C1[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie01.e4p";
const char PROTO_C2[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie02.e4p";
const char PROTO_C3[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie03.e4p";
const char PROTO_C4[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie04.e4p";
const char PROTO_C5[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie05.e4p";
const char PROTO_T1[]= "mod:Prototypes/Vehicles/03 LA Police/Tango01.e4p";
const char PROTO_T2[]= "mod:Prototypes/Vehicles/03 LA Police/Tango02.e4p";
const char PROTO_T11[]= "mod:Prototypes/Vehicles/03 LA Police/Tango11.e4p";
const char PROTO_T12[]= "mod:Prototypes/Vehicles/03 LA Police/Tango12.e4p";
const char PROTO_T13[]= "mod:Prototypes/Vehicles/03 LA Police/Tango13.e4p";
const char PROTO_V1[]= "mod:Prototypes/Vehicles/03 LA Police/Victor01.e4p";
const char PROTO_V2[]= "mod:Prototypes/Vehicles/03 LA Police/Victor02.e4p";
const char PROTO_U1[]= "mod:Prototypes/Vehicles/03 LA Police/Uniform01.e4p";

int DummyGroup = 23;

object VcmdSiren : CommandScript
{
	VcmdSiren()
	{
		SetIcon("sirenson");
		SetCursor("sirens");
		SetRestrictions(RESTRICT_SELFEXECUTE);
		SetPossibleCallers(ACTOR_VEHICLE);
 		SetGroupID(DummyGroup);
 		SetGroupLeader(true);
	}

	bool CheckPossible(GameObject *Caller)
	{
		if (!Caller->IsValid())
			return false;

		if (Caller->HasCommand(DUMMY_HASSIREN))
			SetIcon("sirensoff");
		else
			SetIcon("sirenson");

		if(Caller->HasCommand(DUMMY_HOSESON))
			return false;	

		return true;
	}

	bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
	{
		if (!Target->IsValid() || Target->GetID() != Caller->GetID())
			return false;

		return true;
	}

	void PushActions(GameObject *Caller, Actor *Target, int childID)
	{
		Vehicle v(Caller);
		if (!v.HasCommand(DUMMY_HASSIREN))
		{
			if (!v.IsBlueLightEnabled())
			{
				v.EnableBlueLights(true);
			}

			int soundID;
			Vector CarPos = v.GetPosition();
 			if (StrCompare(v.GetPrototypeFileName(), PROTO_ENGINE01) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_ENGINE02) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_WATERTENDER) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_LADDER) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_TILLER) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_HAZMAT) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_MOTORBOAT) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_CRASHTENDER) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_USAR) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_MCU01) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_USFS02) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_SWAT_TRUCK) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_FBI_COMMAND) == 0)
 			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren01.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren02.wav", CarPos, true);
				}
 			}
 			else if (StrCompare(v.GetPrototypeFileName(), PROTO_BCV) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_HES) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_BRUSH) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_USFS01) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_EMS) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_AMBULANCE01) == 0 ||
  			StrCompare(v.GetPrototypeFileName(), PROTO_AMBULANCE02) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_AMBULANCE03) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_AMBULANCE04) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_LRA) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_LEV) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_BCV2) == 0)
 			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren03.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren04.wav", CarPos, true);
				}

			}
			else if (StrCompare(v.GetPrototypeFileName(), PROTO_DYKK) == 0)
			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren01.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren02.wav", CarPos, true);
				}			
												
						
			}
			else if (StrCompare(v.GetPrototypeFileName(), PROTO_ARMYMP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_AMBULANCE05) == 0 || 
			StrCompare(v.GetPrototypeFileName(), PROTO_AMBULANCE06) == 0 || 
			StrCompare(v.GetPrototypeFileName(), PROTO_CHAUNMK) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_HUMAMB) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_LEGKOM) == 0)

			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren03.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren04.wav", CarPos, true);
				}
			
			}
 			else if (StrCompare(v.GetPrototypeFileName(), PROTO_MOTORCYCLE) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPD_K9) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_DELBLU) == 0)
 			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren05.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren06.wav", CarPos, true);
				}
 			}
 			else if (StrCompare(v.GetPrototypeFileName(), PROTO_RESCUE01) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_RESCUE02) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_SWAT_SUV) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_WATERCANNON) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_BOMB_SQUAD) == 0 ||
 			StrCompare(v.GetPrototypeFileName(), PROTO_FBI_SUV) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_POLVITO) == 0 || 
			StrCompare(v.GetPrototypeFileName(), PROTO_POLDELTAMB) == 0)
 			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren05.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren06.wav", CarPos, true);
				}

			}
			else if (StrCompare(v.GetPrototypeFileName(), PROTO_B1) == 0 ||
			StrCompare(v.GetPrototypeFilename(), PROTO_B2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B3) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B4) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B5) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B6) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B7) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B8) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B9) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C3) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C4) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C5) == 0)v
			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren05.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren06.wav", CarPos, true);
				}
			
			}
			else if (StrCompare(v.GetPrototypeFileName(), PROTO_V1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_V2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_U1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T11) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T12) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T13) == 0)
			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren05.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren06.wav", CarPos, true);
				}
 			

			}
			int CarID = v.GetID();
			GameObject mDummy =  Game::CreateObject("mod:Prototypes/Objects/Misc/empty.e4p", NAME_DUMMYOBJECT);
			v.AssignCommand(DUMMY_HASSIREN);
			v.SetUserData(soundID);
			mDummy.Hide();
			//mDummy.SetUserData(v.GetID());
			mDummy.SetUserData(soundID);
			mDummy.AttachSound(soundID);
			mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, &v, 0, false);
			return;
		}

		if (v.HasCommand(DUMMY_HASSIREN))
		{
			System::Log("Stop sample via VcmdSiren");
			if (childID == 1)
			{
				v.EnableBlueLights(false);
			}
			int CarID = v.GetUserData();
			int ref = v.GetUserData();
			v.UnattachSound(ref);
			Audio::StopSample(ref);
			int mSirTest;
			GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
			for(int i=0; i<list.GetNumObjects(); i++)
			{
				GameObject *obj = list.GetObject(i);
				if (obj->GetUserData() == CarID)
				{
					mSirTest = i;
				}
			}

			GameObject *obj = list.GetObject(mSirTest);
			obj->PushActionDeleteOwner(ACTION_NEWLIST);

			if (v.HasCommand(DUMMY_HASSIREN))
				v.RemoveCommand(DUMMY_HASSIREN);

			return;
		}
	}
};

object DummyUpdatePos : CommandScript
{
	DummyUpdatePos()
	{
		SetGroupID(DummyGroup);
	}

	bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
	{
	}

  	void PushActions(GameObject *Caller, Actor *Target, int childID)
	{
		Vehicle v(Target);
		GameObject mDummy(Caller);

		if (v.IsDestroyed() || !v.IsValid())
		{
			int ref = mDummy.GetUserData();
			mDummy.UnattachSound(ref);
			Audio::StopSample(ref);

			if (v.HasCommand(DUMMY_HASSIREN))
				v.RemoveCommand(DUMMY_HASSIREN);

			mDummy.PushActionDeleteOwner(ACTION_NEWLIST);
		} else
		  {
			if (v.IsCurrentAction(EACTION_FINDPATH))
			{
				if (!v.HasCommand(DUMMY_FINDPATH))
				{
					v.AssignCommand(DUMMY_FINDPATH);
				}
			}
			Vector vPos = v.GetPosition();
			mDummy.SetPosition(vPos);
			mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, Target, childID, false);
		  }

		if (v.HasCommand(DUMMY_FINDPATH))
		{
			if (!v.IsCurrentAction(EACTION_FINDPATH) && v.HasCommand(CMD_AUTOSIREN_OFF) && (v.GetNumActions() == 0 || v.IsCurrentAction(EACTION_EXTINGUISH)))
			{
				if (v.HasCommand(DUMMY_HASSIREN))
					v.RemoveCommand(DUMMY_HASSIREN);

				if (v.HasCommand(DUMMY_FINDPATH))
					v.RemoveCommand(DUMMY_FINDPATH);

				int CarID = v.GetUserData();
				int ref = v.GetUserData();
				v.UnattachSound(ref);
				Audio::StopSample(ref);

				GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
				for(int i = 0; i < list.GetNumObjects(); i++)
				{
					int mSirTest;
					GameObject *obj = list.GetObject(i);
					if (obj->GetUserData() == CarID)
					{
						mSirTest = i;
						GameObject *obj = list.GetObject(mSirTest);
						obj->PushActionDeleteOwner(ACTION_NEWLIST);
						if (v.HasCommand(DUMMY_HASSIREN))
							v.RemoveCommand(DUMMY_HASSIREN);
						if (v.HasCommand(DUMMY_FINDPATH))
							v.RemoveCommand(DUMMY_FINDPATH);
					}
				}
			}
		}
	}
};

object DummyDisableSiren : CommandScript
{
	DummyDisableSiren()
	{
		SetGroupID(DummyGroup);
	}

	bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
	{
	}

  	void PushActions(GameObject *Caller, Actor *Target, int childID)
	{
		Vehicle v(Caller);
		if (childID == 1)
		{
			v.EnableBlueLights(false);
		}

		//int CarID = v.GetID();
		int CarID = v.GetUserData();
		int ref = v.GetUserData();
		v.UnattachSound(ref);
		Audio::StopSample(ref);

		GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
		for(int i = 0; i < list.GetNumObjects(); i++)
		{
			GameObject *obj = list.GetObject(i);
			if (obj->GetUserData() == CarID)
			{
				int mSirTest = i;

				GameObject *obj = list.GetObject(mSirTest);
				obj->PushActionDeleteOwner(ACTION_NEWLIST);

				if (v.HasCommand(DUMMY_HASSIREN))
					v.RemoveCommand(DUMMY_HASSIREN);
				if (v.HasCommand(DUMMY_FINDPATH))
					v.RemoveCommand(DUMMY_FINDPATH);
				if (v.HasCommand(DUMMY_GETTIL))
					v.SetUserData(v.GetID());
			}
		}
	}
};

object DummyFindPath : CommandScript
{
	DummyFindPath()
	{
		SetGroupID(DummyGroup);
	}

	bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
	{
		return false;
	}

  	void PushActions(GameObject *Caller, Actor *Target, int childID)
	{
	}
};

object DummyHasSiren : CommandScript
{
	DummyHasSiren()
	{
		SetGroupID(DummyGroup);
	}

	bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
	{
		return false;
	}

  	void PushActions(GameObject *Caller, Actor *Target, int childID)
	{
	}
};

const char PROTO_B1[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo01.e4p";
const char PROTO_B2[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo02.e4p";
const char PROTO_B3[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo03.e4p";
const char PROTO_B4[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo04.e4p";
const char PROTO_B5[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo05.e4p";
const char PROTO_B6[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo06.e4p";
const char PROTO_B7[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo07.e4p";
const char PROTO_B8[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo08.e4p";
const char PROTO_B9[]= "mod:Prototypes/Vehicles/03 LA Police/Bravo09.e4p";
const char PROTO_C1[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie01.e4p";
const char PROTO_C2[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie02.e4p";
const char PROTO_C3[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie03.e4p";
const char PROTO_C4[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie04.e4p";
const char PROTO_C5[]= "mod:Prototypes/Vehicles/03 LA Police/Charlie05.e4p";
const char PROTO_T1[]= "mod:Prototypes/Vehicles/03 LA Police/Tango01.e4p";
const char PROTO_T2[]= "mod:Prototypes/Vehicles/03 LA Police/Tango02.e4p";
const char PROTO_T11[]= "mod:Prototypes/Vehicles/03 LA Police/Tango11.e4p";
const char PROTO_T12[]= "mod:Prototypes/Vehicles/03 LA Police/Tango12.e4p";
const char PROTO_T13[]= "mod:Prototypes/Vehicles/03 LA Police/Tango13.e4p";
const char PROTO_V1[]= "mod:Prototypes/Vehicles/03 LA Police/Victor01.e4p";
const char PROTO_V2[]= "mod:Prototypes/Vehicles/03 LA Police/Victor02.e4p";
const char PROTO_U1[]= "mod:Prototypes/Vehicles/03 LA Police/Uniform01.e4p"; 
			}
			else if (StrCompare(v.GetPrototypeFileName(), PROTO_B1) == 0 ||
			StrCompare(v.GetPrototypeFilename(), PROTO_B2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B3) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B4) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B5) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B6) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B7) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B8) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_B9) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C3) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C4) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_C5) == 0)v
			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren05.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren06.wav", CarPos, true);
				}
			
			}
			else if (StrCompare(v.GetPrototypeFileName(), PROTO_V1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_V2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_U1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T11) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T12) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_T13) == 0)
			{
				int random = Math::rand()%2;
				if (random == 0)
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren05.wav", CarPos, true);
				} else
				{
  					soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren06.wav", CarPos, true);
				}
 			

			} 

Thanks for any and all help I recieve!



#2 EmC-Unit

EmC-Unit

    District Chief

  • SLUM Modding Team
  • 1,332 posts
  • Gender:Male
  • Location:Ukraine

Posted 01 November 2014 - 07:47 PM

From what i see the "v" should not be there (in two palces)

Example wrong:

}
else if (StrCompare(v.GetPrototypeFileName(), PROTO_B1) == 0 ||
StrCompare(v.GetPrototypeFilename(), PROTO_B2) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B3) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B4) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B5) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B6) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B7) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B8) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B9) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C1) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C2) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C3) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C4) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C5) == 0)v
{

Example right

}
else if (StrCompare(v.GetPrototypeFileName(), PROTO_B1) == 0 ||
StrCompare(v.GetPrototypeFilename(), PROTO_B2) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B3) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B4) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B5) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B6) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B7) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B8) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_B9) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C1) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C2) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C3) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C4) == 0 ||
StrCompare(v.GetPrototypeFileName(), PROTO_C5) == 0)
{

6yo.gif
 

•_•) My topics: ( •_•)>⌐■-■  USSR Mod || Miami mod (⌐■_■)


#3 SondreEinarsen

SondreEinarsen

    Lieutenant

  • Members
  • 35 posts

Posted 01 November 2014 - 07:51 PM

 

From what i see the "v" should not be there (in two palces)

 

 

 

Oh my god, how on earth did I NOT notice that!

Thank you, I've removed it and will run a test right now!



#4 SondreEinarsen

SondreEinarsen

    Lieutenant

  • Members
  • 35 posts

Posted 01 November 2014 - 08:24 PM

And after removing that v, I now get the following script error:

 

(_LASirena5499): Error: Can't call Vehicle::GetPrototypeFilename() in current scope

I have close to null coding experience, everytime I edit a script I usually just look at what is already there and add what seems to be correct. So I can't for the life of me figure out what this error is supposed to mean..



#5 The Loot

The Loot

    Battalion Chief

  • Members
  • 725 posts
  • Gender:Male

Posted 02 November 2014 - 01:05 AM

What line was the error on?

 

Go ahead and throw your script file in a zip and attach it, also.



#6 SondreEinarsen

SondreEinarsen

    Lieutenant

  • Members
  • 35 posts

Posted 02 November 2014 - 05:35 AM

What line was the error on?

 

Go ahead and throw your script file in a zip and attach it, also.

 

Hi,

 

Thanks for the reply!

Unfortunately, I'm not quite sure, not really sure how to figure out how to read what line it is from the error. If I did I probably would have had an easier time figuring it out myself, haha!

 

Here's the file and thanks for any and all help you can give!

https://www.dropbox....ASiren.zip?dl=0



#7 The Loot

The Loot

    Battalion Chief

  • Members
  • 725 posts
  • Gender:Male

Posted 02 November 2014 - 07:28 AM

If you keep pressing "retry" on the error popup, it will print a line to the log along with other info.