Jump to content
Yankee43

Help fixing error

Recommended Posts

Can anyone help me fix this error? I am fixing up LA Mod for my own purposes and I have run into this error message:

(_LASirena1651): Error G__getvariable: expression

This occurs whenever I try to use the siren for the following vehicles:

LAX Crash Truck

All Fire Engines at the main station

Old Rescue

Heavy Rescue Crane

Once the error pops up none of the listed vehicles have sirens, other vehicles work fine.

 

Link to comment
Share on other sites

51 minutes ago, itchboy said:

Can we see the siren script you set up? It is possible you missed a parenthesis, or made a mistake in one of the logic gate (|| and &&) lines.

Here it is, I have not made any changed to the fire section. I only added police cars. 

Spoiler

#Version 2.7#                                        
//                                                
//         Includes: All Sirens Commands                                
//                                                
//    - VcmdSiren                                        
//    - DummyUpdatePos                                    
//    - DummyDisableSiren                                    
//    - DummyFindPath                                    
//    - DummyHasSiren                                    
//                                                
//         Script by Bass-Ti    
//        Modified by Hoppah                                                                        
//                                                
//******************************************************************************************

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_LAPD_IMPALA[]    = "mod:Prototypes/Vehicles/03 LA Police/lapd_impala.e4p";
const char PROTO_LAPD_TAURUS[]    = "mod:Prototypes/Vehicles/03 LA Police/lapd_taurus.e4p";
const char PROTO_CAMARO_CHP[]    = "mod:Prototypes/Vehicles/03 LA Police/camaro_chp.e4p";
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_BPAT_DC[]    = "mod:Prototypes/Vehicles/03 LA Police/bpat_dodge_charger.e4p";
const char PROTO_BPAT_TAHOE[]    = "mod:Prototypes/Vehicles/03 LA Police/bpat_tahoe.e4p";
const char PROTO_CV_BP[]     = "mod:Prototypes/Vehicles/03 LA Police/cv_bp.e4p";
const char PROTO_CV_BP2[]     = "mod:Prototypes/Vehicles/03 LA Police/cv_bp2.e4p";
const char PROTO_ATF_CV[]    = "mod:Prototypes/Vehicles/03 LA Police/ATF_cv.e4p";
const char PROTO_ATF_NRU[]    = "mod:Prototypes/Vehicles/03 LA Police/atf_nru.e4p";
const char PROTO_ATF_MCP[]    = "mod:Prototypes/Vehicles/03 LA Police/atf_mcp.e4p";
const char PROTO_SWAT_SUV[]    = "mod:Prototypes/Vehicles/03 LA Police/swat_suv.e4p";
const char PROTO_chpcommand[]    = "mod:Prototypes/Vehicles/09 Government/atf_mcp.e4p";
const char PROTO_charger[]    = "mod:Prototypes/Vehicles/03 LA Police/Charger weis.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_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_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/ambulance04.e4p";
const char PROTO_DOGTRUCK[] = "mod:Prototypes/Vehicles/01 LA Ambulance/suv_rescue_dog.e4p";
const char PROTO_MOTORCYCLE[] = "mod:Prototypes/Vehicles/03 LA Police/motorcycle_lapd.e4p";
const char PROTO_CV_LAPD1[] = "mod:Prototypes/Vehicles/03 LA Police/cv_lapd1.e4p";
const char PROTO_CV_LAPD_K9[] = "mod:Prototypes/Vehicles/03 LA Police/cv_lapdk9.e4p";
const char PROTO_CV_LAPD_ST[] = "mod:Prototypes/Vehicles/03 LA Police/cv_lapd_slicktop.e4p";
const char PROTO_CV_LAAP[] = "mod:Prototypes/Vehicles/03 LA Police/cv_laap.e4p";
const char PROTO_CV_LAPP[] = "mod:Prototypes/Vehicles/03 LA Police/cv_lapp.e4p";
const char PROTO_CV_UMPC[] = "mod:Prototypes/Vehicles/03 LA Police/cv_umpc.e4p";
const char PROTO_CV_CHP[] = "mod:Prototypes/Vehicles/03 LA Police/cv_chp.e4p";
const char PROTO_CV_LASD[] = "mod:Prototypes/Vehicles/03 LA Police/cv_lasd.e4p";
const char PROTO_LASD_VAN[] = "mod:Prototypes/Vehicles/03 LA Police/lasd_van.e4p";
const char PROTO_CHARGER_CHP[] = "mod:Prototypes/Vehicles/03 LA Police/dodge_charger_chp.e4p";
const char PROTO_CHARGER_LAPD[] = "mod:Prototypes/Vehicles/03 LA Police/dodge_charger_lapd.e4p";
const char PROTO_SUV_LAPD[] = "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p";
const char PROTO_SUV_LAPD2[] = "mod:Prototypes/Vehicles/03 LA Police/suv_lapd2.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_HUMMERH2_LASD[] = "mod:Prototypes/Vehicles/03 LA Police/hummerh2_lasd.e4p";
const char PROTO_BOMB_SQUAD[] = "mod:Prototypes/Vehicles/03 LA Police/suv_bomb_squad.e4p";
const char PROTO_SUV_BOMB_SQUAD2[] = "mod:Prototypes/Vehicles/03 LA Police/suv_bomb_squad2.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_HEAVY_RESCUE[] = "mod:Prototypes/Vehicles/02 LA Fire Department/heavy_rescue_crane.e4p";
const char PROTO_MCAMB[] = "mod:Prototypes/Vehicles/01 LA Ambulance/mcamb.e4p";
const char PROTO_smart[] = "mod:Prototypes/Vehicles/03 LA Police/for2 schwarz.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_chpcommand) == 0 ||
            StrCompare(v.GetPrototypeFileName(), PROTO_MCU01) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_USFS02) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_SWAT_TRUCK) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_HEAVY_RESCUE) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_FBI_COMMAND) == 0)
            StrCompare(v.GetPrototypeFileName(), PROTO_SUV_BOMB_SQUAD2) == 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_DOGTRUCK) == 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_ATF_NRU) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_ATF_MCP) == 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_LAPD1) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_smart) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_charger) == 0 ||
            StrCompare(v.GetPrototypeFileName(), PROTO_LAPD_TAURUS) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPD_ST) == 0 ||
            StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPD_K9) == 0 ||
            StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAAP) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPP) == 0 ||
              StrCompare(v.GetPrototypeFileName(), PROTO_CV_UMPC) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_CV_CHP) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_CV_LASD) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_CHARGER_LAPD) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_CHARGER_CHP) == 0 ||
            StrCompare(v.GetPrototypeFileName(), PROTO_CAMARO_CHP) == 0 ||
            StrCompare(v.GetPrototypeFileName(), PROTO_BPAT_DC) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_BPAT_TAHOE) == 0 ||
            StrCompare(v.GetPrototypeFileName(), PROTO_ATF_CV) == 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_SUV_LAPD) == 0 ||
                StrCompare(v.GetPrototypeFileName(), PROTO_LAPD_IMPALA) == 0 ||
             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_SUV_LAPD2) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_CV_BP) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_CV_BP2) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_HUMMERH2_LASD) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_BOMB_SQUAD) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_LASD_VAN) == 0 ||
             StrCompare(v.GetPrototypeFileName(), PROTO_FBI_SUV) == 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_MCAMB) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_MCAMB) == 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);
                }
             }

            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)
    {
    }
};
 

 

Link to comment
Share on other sites

One thing I can see that's wrong in the script is the number of vehicles for each section.

Another thing that went wrong is the extra parenthesis in FBI_COMMAND. That part should be a || and not a )

Em4 is limited to 10 or so StrCompare lines for each "if" statement. The script as you can see is divided into "if" and "else if".

Here's a corrected version of the "PushActions" section.

Spoiler



	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_HEAVY_RESCUE) == 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_SUV_BOMB_SQUAD2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_chpcommand) == 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_DOGTRUCK) == 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_ATF_NRU) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_ATF_MCP) == 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_LAPD1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_smart) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_charger) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_LAPD_TAURUS) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPD_ST) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPD_K9) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAAP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_UMPC) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_CHP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LASD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CHARGER_LAPD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CHARGER_CHP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CAMARO_CHP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_BPAT_DC) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_BPAT_TAHOE) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_ATF_CV) == 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_SUV_LAPD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_LAPD_IMPALA) == 0 ||
			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_SUV_LAPD2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_BP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_BP2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_HUMMERH2_LASD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_BOMB_SQUAD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_LASD_VAN) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_FBI_SUV) == 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_MCAMB) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_MCAMB) == 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);
				}
			}

            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;
        }
    }


 

 

Link to comment
Share on other sites

9 hours ago, itchboy said:

One thing I can see that's wrong in the script is the number of vehicles for each section.

Another thing that went wrong is the extra parenthesis in FBI_COMMAND. That part should be a || and not a )

Em4 is limited to 10 or so StrCompare lines for each "if" statement. The script as you can see is divided into "if" and "else if".

Here's a corrected version of the "PushActions" section.

  Hide contents

 



	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_HEAVY_RESCUE) == 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_SUV_BOMB_SQUAD2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_chpcommand) == 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_DOGTRUCK) == 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_ATF_NRU) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_ATF_MCP) == 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_LAPD1) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_smart) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_charger) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_LAPD_TAURUS) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPD_ST) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPD_K9) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAAP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LAPP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_UMPC) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_CHP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_LASD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CHARGER_LAPD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CHARGER_CHP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CAMARO_CHP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_BPAT_DC) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_BPAT_TAHOE) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_ATF_CV) == 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_SUV_LAPD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_LAPD_IMPALA) == 0 ||
			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_SUV_LAPD2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_BP) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_CV_BP2) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_HUMMERH2_LASD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_BOMB_SQUAD) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_LASD_VAN) == 0 ||
			StrCompare(v.GetPrototypeFileName(), PROTO_FBI_SUV) == 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_MCAMB) == 0 || StrCompare(v.GetPrototypeFileName(), PROTO_MCAMB) == 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);
				}
			}

            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;
        }
    }

 

 

 

 

Thank you so much! I will try it out and let you know.

 

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...