Darren-NYPD Posted March 1, 2017 Report Share Posted March 1, 2017 Hi, I was using the NYCsiren for my personal mod, I separated some types of vehicles such as NEF from the other ones in it category ez: ITW etc so units assigned as NEF have different siren sound. I did this to the RW, MTW and STW. It is working fine but sometimes when I click on a unit to move somewhere the siren start and keeps on going even when the unit stops moving and there is now way I can turn it off except to send the unit home. Any Idea What might be wrong? This is the script: const char CMD_AUTOSIREN_OFF[] = "VcmdAutoSirenOff"; const char EACTION_FINDPATH[] = "EActionFindPath"; const char EACTION_EXTINGUISH[] = "EActionExtinguish"; const char OBJ_INVIS[] = "mod:Prototypes/Objects/01 Equipment/invisible.e4p"; const char DUMMY_HASSIREN[] = "DummyHasSiren"; const char DUMMY_UPDATEPOS[] = "DummyUpdatePos"; const char DUMMY_FINDPATH[] = "DummyFindPath"; const char DUMMY_HOSESON[] = "DummyHosesAreOn"; const char DUMMY_RANDOMSPAWN[] = "DummyRandomSpawn"; const char DUMMY_RANDOMGOHOME[] = "DummyRandomGoHome"; const char NAME_DUMMYOBJECT[] = "HelpingObjekt_Hoppah"; const char PROTO_ENGINE01[] = "mod:Prototypes/Vehicles/02 Fire Department/engine01.e4p"; const char PROTO_ENGINE02[] = "mod:Prototypes/Vehicles/02 Fire Department/engine02.e4p"; const char PROTO_SQUAD01[] = "mod:Prototypes/Vehicles/02 Fire Department/squad61.e4p"; const char PROTO_LADDER01[] = "mod:Prototypes/Vehicles/02 Fire Department/ladder01.e4p"; const char PROTO_LADDER02[] = "mod:Prototypes/Vehicles/02 Fire Department/ladder02.e4p"; const char PROTO_HAZMAT01[] = "mod:Prototypes/Vehicles/02 Fire Department/hazmat01.e4p"; const char PROTO_HAZMAT02[] = "mod:Prototypes/Vehicles/02 Fire Department/hazmat02.e4p"; const char PROTO_RESCUE01[] = "mod:Prototypes/Vehicles/02 Fire Department/Rescue1.e4p"; const char PROTO_ESU01[] = "mod:Prototypes/Vehicles/02 Fire Department/i20.e4p"; const char PROTO_ESU02[] = "mod:Prototypes/Vehicles/02 Fire Department/cpdr.e4p"; const char PROTO_SUPT02[] = "mod:Prototypes/Vehicles/03 Police/supt2_body.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 (Game::IsFreeplay() && Caller->HasCommand(DUMMY_RANDOMSPAWN)) 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 (Game::IsFreeplay() && v.HasCommand(DUMMY_RANDOMSPAWN)) return; if (Input::LShiftPressed() || Input::RShiftPressed()) // Play airhorn sound (and make it clear people away) { Vector CarPos = v.GetPosition(); if (StrCompare(v.GetPrototypeFileName(), PROTO_ENGINE01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_ENGINE02) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_SQUAD01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_HAZMAT01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_HAZMAT02) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_LADDER01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_LADDER02) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_RESCUE01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_ESU01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_ESU02) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_SUPT02) == 0) Audio::PlaySample3D("mod:Audio/Fx/sirens/supt.wav", CarPos); else Audio::PlaySample3D("mod:Audio/FX/Sirens/supt.wav", CarPos); float r[9]; v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]); GameObject deleteDummy = Game::CreateObject(OBJ_INVIS, "HornDummy"); GameObject halt = Game::CreateObject(OBJ_INVIS, "HornDummy_Halt"); if (halt.IsValid()) { halt.SetSelectable(false); halt.SetPosition(CarPos); halt.SetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]); halt.UpdatePlacement(); halt.PushActionHalt(ACTION_NEWLIST, 500, HALT_PERSONS); if (deleteDummy.IsValid()) { deleteDummy.PushActionWait(ACTION_NEWLIST, 2.0f); deleteDummy.PushActionExecuteCommand(ACTION_APPEND, "DummyHorn", &halt, 0, false); } } return; } 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_SQUAD01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_HAZMAT01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_HAZMAT02) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_RESCUE01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_LADDER01) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_LADDER02) == 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 (v.GetVehicleType() == VT_AMBULANCE_RTW || v.GetVehicleType() == VT_AMBULANCE_ITW) { int random = Math::rand()%2; if (random == 0) soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/ambulance_01.wav", CarPos, true); } else if (v.GetVehicleType() == VT_AMBULANCE_NEF) { int random = Math::rand()%2; if (random == 0) soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/fire.wav", CarPos, true); } else if (v.GetVehicleType() == VT_POLICE_SW || v.GetVehicleType() == VT_POLICE_WAW || v.GetVehicleType() == VT_POLICE_GTW) { int random = Math::rand()%2; if (random == 0) soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/police_02.wav", CarPos, true); } else if (v.GetVehicleType() == VT_POLICE_MTW) { int random = Math::rand()%2; if (random == 0) soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/police_01.wav", CarPos, true); } else if (v.GetVehicleType() == VT_POLICE_STW) { int random = Math::rand()%2; if (random == 0) soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/supt.wav", CarPos, true); } else if (v.GetVehicleType() == VT_FIREFIGHTERS_DLK || v.GetVehicleType() == VT_FIREFIGHTERS_GTF || v.GetVehicleType() == VT_FIREFIGHTERS_TLF || v.GetVehicleType() == VT_FIREFIGHTERS_DEKONP || v.GetVehicleType() == VT_FIREFIGHTERS_LPF || v.GetVehicleType() == VT_FIREFIGHTERS_TFMB) { int random = Math::rand()%2; if (random == 0) soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Siren01.wav", CarPos, true); } else if (v.GetVehicleType() == VT_FIREFIGHTERS_RW) { int random = Math::rand()%2; if (random == 0) soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/fire.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(soundID); mDummy.AttachSound(soundID); mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, &v, 0, false); return; } if (v.HasCommand(DUMMY_HASSIREN)) { if (childID == 1) { v.EnableBlueLights(false); } //int CarID = v.GetID(); 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.HasCommand("VcmdFollow") && v.HasCommand("DummyFollow")) { v.Destroy(); return; } 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.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++) { 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); } } } }; 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) { } }; object DummyHorn : CommandScript { DummyHorn() { } bool CheckPossible(GameObject *Caller) { } void PushActions(GameObject *Caller, Actor *Target, int childID) { GameObject t(Target); t.PushActionDeleteOwner(ACTION_NEWLIST); Caller->PushActionDeleteOwner(ACTION_NEWLIST); } }; Quote Link to comment Share on other sites More sharing options...
itchboy Posted March 1, 2017 Report Share Posted March 1, 2017 Please dont post the Em4 code like this. Its unreadable and takes a lot of scrolling. Try using the 'code' function of the forum. My theory on it is that 'dummyUpdatePos' isnt going through. Also be sure to remove the 'DummyFollow' section that makes the vehicle explode. 1 Quote Link to comment Share on other sites More sharing options...
Darren-NYPD Posted March 4, 2017 Author Report Share Posted March 4, 2017 Hi, sorry for the long post hehe.. well I tried using the LA mod Siren instead but then some units does not have sirens available.. example: in the case of ambulances I have everything named like the la mod. ambulance01.e4p etc... the only difference is that my folder is 01 Ambulance not 01 La Ambulance so all I needed to modify was the location of folder (removing LA). but after this ambulances are still without sirens. I also renamed the names of the sirens from the script to those in my mod. . Quote Link to comment Share on other sites More sharing options...
itchboy Posted March 7, 2017 Report Share Posted March 7, 2017 So the sirens play or not? That is a whole separate issue from them not staying with the vehicle. Quote Link to comment Share on other sites More sharing options...
Darren-NYPD Posted March 7, 2017 Author Report Share Posted March 7, 2017 Well first they were stuck and keeps going. Now im using lasiren script which is working fine but some units are not playing the siren sound while others do Quote Link to comment Share on other sites More sharing options...
itchboy Posted March 7, 2017 Report Share Posted March 7, 2017 Try checking if you have a syntax error of some kind. Also check if the prototype names you put in there are correct. Add/remove entries as necessary. Quote Link to comment Share on other sites More sharing options...
Darren-NYPD Posted March 9, 2017 Author Report Share Posted March 9, 2017 Well I checked multiple times, most times leading to game crash. I did it bit by bit and testing all the time.. seems to be working fine now. using the LAsiren script. Thanks for aiding me and giving me options to solve this matter. Quote Link to comment Share on other sites More sharing options...