Jump to content
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
  • Announcements

    • randomperson139

      Signatures   03/04/2016

      Hi everyone. It appears that the update to the new forum has affected the format of the majority of signatures (adding extra spaces, changing sizes etc.). Due to this, could everyone please check their own signature, ensuring that it complies with the site rules. See the http://www.emergency-planet.com/tos.html/ or http://www.emergency-planet.com/topic/16848-acceptable-signature-sizes/ for more information.  We'll give it a few weeks to give enough time to edit signatures, after that the unnecessarily large signatures will simply be removed. Thanks for your cooperation. Regards, EMP Staff.
BxPanxi

How to add Police Barricade tool to other mod cars?

Recommended Posts

Hi, I am trying to get the Police Barricade tool into a mod called Northview South County. It has the script, but the script points to some .e4p files, how do I make a e4p for a Vehicle? I thought I needed to add the tool name in the unit.xml but I don't know the tool name either. Please help!

 

i am also aware this is a very old game and I probably won't get a response. 

Share this post


Link to post
Share on other sites

Units xml has nothing to do with any of the custom equipment found in mods.

You need to edit the script files. They contain the list of units that have the barricades. The scripts for ballistic shields, guns, and traffic cones also operate on the same logic.

Untitled.png

  • Upvote 1

Share this post


Link to post
Share on other sites

Let me see how you edited the script. You most likely commited a syntax error.

Share this post


Link to post
Share on other sites

@itchboySorry I don't respond for a while, I don't expect to get a response immediately.

 

Here's a link to a GIF which shows what section I changed. If you just want the code, it is below; https://gyazo.com/675636db75500ccda8f627721769ff1d

 

Spoiler

            if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/hummerh2_lasd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck01_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapp.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol1.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol2.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol4.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol6.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_armoured_vehicle.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_truck.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 US Army/hmmwv.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/05 US Army/us_army_truck.e4p") == 0)
                return true;

            return false;
        }
    }

    void PushActions(GameObject *Caller, Actor *Target, int childID)
    {
        Vector TargetPos = Target->GetTargetPoint(Caller, TARGET_EQUIPMENTDOOR);

        Caller->PushActionMove(ACTION_NEWLIST, TargetPos);
        Caller->PushActionTurnTo(ACTION_APPEND, Target);
        Caller->PushActionGetEquipment(ACTION_APPEND, Target, EQUIP_NONE);
        Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_BARRICADE, Target, 1, false);
    }
};

object PcmdBarricadeRemove : CommandScript
{
    
    PcmdBarricadeRemove()
    {
            SetIcon("policebarricaderemove");
            SetCursor("policebarricaderemove");
        SetValidTargets(ACTOR_VEHICLE | ACTOR_OBJECT);
        SetRestrictions(RESTRICT_NOTDESTROYED | RESTRICT_NOTBURNING | RESTRICT_HASROADBLOCK);
        SetPossibleCallers(ACTOR_PERSON);
        SetNeedsCarWithFlagSet(OF_HAS_ROADBLOCK);
    }

    /*bool CheckPossible(GameObject *Caller)
    {
        if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
            return false;
        Person p(Caller);
        if (p.IsCarryingPerson()||p.IsLinkedWithPerson()|| p.GetFirehoseID()!=0 || p.IsPulling())
            return false;
        if (!Game::ExistsNormalObjectWithFlagSet(OF_HAS_ROADBLOCK))
            return false;
        return true;
    }*/

    bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
    {
        if(!Caller->IsValid() || !Target || !Target->IsValid() || Target->GetType()!=ACTOR_VEHICLE)
            return false;
        
        if(Caller->GetObjectType()==TYPE_PERSON)
        {
            Person p(Caller);
            Vehicle v(Target);

            if (v.IsDestroyed())
                return false;

            if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1)) 
                return false;

            Vehicle v(Target);

            if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/hummerh2_lasd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck01_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_armoured_vehicle.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/swat_truck.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/05 US Army/hmmwv.e4p") == 0 ||
            StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/05 US Army/us_army_truck.e4p") == 0)
                return true;

            return false;
        }
    }

 

Share this post


Link to post
Share on other sites

You inputted too many vehicles, it looks like. Those conditions only allow for maybe 8 or 9 conditions in the "if" section. You will have to split up the vehicles, or do a different setup like this.

Untitled.png

Share this post


Link to post
Share on other sites

I found that the simplest way to do it was to make dummy commands and assign them to any applicable vehicle, which the equipment script would then check for.

object FlagHasBarricade : CommandScript
{
	FlagHasBarricade()
	{
		SetGroupID(20);
	}
	bool CheckGroupVisibility(GameObject *Caller)
	{
		return false;
	}

	bool CheckPossible(GameObject *Caller)
	{
		return false;
	}

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

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

And then in the script CheckTarget section, just add this:

if (!Target->HasCommand("FlagHasBarricade")) 
            return false;

It makes it very simple to add new vehicles later: just add the dummy command and they're all set.
 

Share this post


Link to post
Share on other sites

Alright so I'm having a few troubles. I tried to do it again and now it says theres an error with the parenthesis. 

I don't know what's wrong here? 

@itchboy

And, @The LootI'm not really the best at this stuff so I didn't get what you meant by that script at all, sorry!

 

			if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapp.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol1.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol2.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol4.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol6.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0
				return true;

			return false;
		}
	}

	void PushActions(GameObject *Caller, Actor *Target, int childID)
	{
		Vector TargetPos = Target->GetTargetPoint(Caller, TARGET_EQUIPMENTDOOR);

		Caller->PushActionMove(ACTION_NEWLIST, TargetPos);
		Caller->PushActionTurnTo(ACTION_APPEND, Target);
		Caller->PushActionGetEquipment(ACTION_APPEND, Target, EQUIP_NONE);
		Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_BARRICADE, Target, 1, false);
	}
};

object PcmdBarricadeRemove : CommandScript
{
	
	PcmdBarricadeRemove()
	{
    		SetIcon("policebarricaderemove");
    		SetCursor("policebarricaderemove");
		SetValidTargets(ACTOR_VEHICLE | ACTOR_OBJECT);
		SetRestrictions(RESTRICT_NOTDESTROYED | RESTRICT_NOTBURNING | RESTRICT_HASROADBLOCK);
		SetPossibleCallers(ACTOR_PERSON);
		SetNeedsCarWithFlagSet(OF_HAS_ROADBLOCK);
	}

	/*bool CheckPossible(GameObject *Caller)
	{
		if(!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
			return false;
		Person p(Caller);
		if (p.IsCarryingPerson()||p.IsLinkedWithPerson()|| p.GetFirehoseID()!=0 || p.IsPulling())
			return false;
		if (!Game::ExistsNormalObjectWithFlagSet(OF_HAS_ROADBLOCK))
			return false;
		return true;
	}*/

	bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
	{
		if(!Caller->IsValid() || !Target || !Target->IsValid() || Target->GetType()!=ACTOR_VEHICLE)
			return false;
		
		if(Caller->GetObjectType()==TYPE_PERSON)
		{
			Person p(Caller);
			Vehicle v(Target);

			if (v.IsDestroyed())
				return false;

			if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1)) 
				return false;

			Vehicle v(Target);

			if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapp.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol1.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol2.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol4.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol6.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0 
				return true;

			return false;
		}
	}

 

Share this post


Link to post
Share on other sites

Alright seems what I did didn't work. What happened here..?  @itchboy

 

			if (v.IsValid() && !v.IsDestroyed() && StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/suv_lapd.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_lapp.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol1.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol2.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol4.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/cv_patrol6.e4p") == 0 ||
			StrCompare(v.GetPrototypeFileName(), "mod:Prototypes/Vehicles/03 LA Police/rescue_truck02_lapd.e4p") == 0) 
				return true;
			return false;
			}
		}
	}

 

Share this post


Link to post
Share on other sites

There seems to be nothing wrong with it. Can you upload the rest of the script?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×