Jump to content
MasterPuffin

[Release] Spawn a vehicle with a custom texture

Recommended Posts

This script will spawn a vehicle on a marker and sets a custom vehicle skin. This scripts also works in MP.

 

********************************

First create a folder called skins and put all your skins in it.

Create a folder called scripts. Inside this folder create a file called VehicleSpawner.sqf and put the following code into it:

_dest = (_this select 3) select 0;
_type = (_this select 3) select 1;
_spawn = 0;

if (_type == "Sport") then
	{
	_spawn = "C_Hatchback_01_sport_F";
	};

if (_type == "SUV") then
	{
	_spawn = "C_SUV_01_F";
	};
	
if (_type == "Jeep") then
	{
	_spawn = "C_Offroad_02_unarmed_F";
	};

if (_type == "Offroad") then
	{
	_spawn = "C_Offroad_01_F";
	};

if (_type == "Hellcat") then
	{
	_spawn = "I_Heli_light_03_unarmed_F";
	};
	
if (_type == "Hummingbird") then
	{
	_spawn = "B_Heli_Light_01_F";
	};	
	
if (_type == "Ghosthawk") then
	{
	_spawn = "B_Heli_Transport_01_F";
	};
	
if (_type == "Neophron") then
	{
	_spawn = "O_Plane_CAS_02_F";
	};

if (_type == "Hunter") then
	{
	_spawn = "B_MRAP_01_F";
	};

if (_type == "Ifrit") then
	{
	_spawn = "O_MRAP_02_F";
	};
	
if (_type == "Marshall") then
	{
	_spawn = "B_APC_Wheeled_01_cannon_F";
	};
	
if (_type == "Kuma") then
	{
	_spawn = "I_MBT_03_cannon_F";
	};	

_target = getMarkerPos _dest;
_spwnveh = _spawn createVehicle (_target);

if (_type == "Sport") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\Limo.jpg"];
	};

if (_type == "SUV") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\SUV.jpg"];
	};

if (_type == "Jeep") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\MB4WD.jpg"];
	};
	
if (_type == "Offroad") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\Offroad.jpg"];
	};
	
if (_type == "Hellcat") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\Hellcat.jpg"];
	};
	
if (_type == "Hummingbird") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\Hummingbird.jpg"];
	};	
	
if (_type == "Ghosthawk") then
	{
	_spwnveh setObjectTextureGlobal [0,"skins\Ghosthawk_0.jpg"];
	_spwnveh setObjectTextureGlobal [1,"skins\Ghosthawk_1.jpg"];
	};
	
if (_type == "Neophron") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\Neo1.jpg"];
	_spwnveh setObjectTextureGlobal [1, "skins\Neo2.jpg"];
	};

if (_type == "Hunter") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\Hunter1.jpg"];
	_spwnveh setObjectTextureGlobal [1, "skins\Hunter2.jpg"];
	};

if (_type == "Ifrit") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\Ifrit1.jpg"];
	_spwnveh setObjectTextureGlobal [1, "skins\Ifrit2.jpg"];
	};

if (_type == "Marshall") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\Marshall0.jpg"];
	_spwnveh setObjectTextureGlobal [1, "skins\Marshall1.jpg"];
	_spwnveh setObjectTextureGlobal [2, "skins\Marshall2.jpg"];
	};

if (_type == "Kuma") then
	{
	_spwnveh setObjectTextureGlobal [0, "skins\kuma_0.jpg"];
	_spwnveh setObjectTextureGlobal [1, "skins\kuma_1.jpg"];
	_spwnveh setObjectTextureGlobal [2, "skins\kuma_2.jpg"];
	};

You can add or remove vehicles you (don't) need, it's pretty self explanatory. And don't forget to change the paths to your skins.

 

Now create an empty marker called spawn_1. You can create multiple markers for different spawn locations.

Then place an item in the editor (for example a sign) and add the following code to the init line:

this addAction ["Spawn Jeep","scripts\VehicleSpawner.sqf",["spawn_1","Jeep"]];  

this addAction ["Spawn Jeep","scripts\VehicleSpawner.sqf",["spawn_1","Jeep"]];  --> spawn_1 is the marker where you want to spawn your vehicle. Change if you want to spawn it eg. on spawn_2. Jeep is the vehicle you want to spawn (You have a line like _type == "Jeep" for every type of vehicle you want to spawn)

Repeat this process for every vehicle you want to spawn on that sign.

 

I have made a texture which you can use for your sign. You can download it here

Hello,

I searched a long time for a working restraining script, which works in MP. Long story short, I didn't found one, so I wrote one myself. Yes it's not perfect, so feel free to improve it, but it works.

 

********************************

Create a file called onPlayerRespawn.sqf (or use your existing one) and put the following code into it:

restrain=false;
restcaller=false;

 

Create a folder called scripts. Inside this folder create a file called restrain.sqf and put the following code into it:

restcaller = false;
if (restrain=false;) then {
	if (player distance cursortarget < 2) then {
		restcaller = true;
		[[[],"scripts\restrainTarget.sqf"],"BIS_fnc_execVM",cursortarget,false,false] call BIS_fnc_MP;
	};
};

player distance cursortarget < 2 --> the number is the max. distance in meters to restrain someone. Change it to whatever you want.

 

Inside the folder scripts create a file called restrainTarget.sqf and put the following code into it:

if (restcaller isEqualto false) then {
	if (restrain isEqualto false) then {
		restrain=true;
		player setVariable ["restrain", true, true];
		while { player getVariable ["restrain", false] }  do { 
			player playMove "AmovPercMstpSnonWnonDnon_EaseIn"; //Animation in
			if (((!alive player) || (player getVariable["onkill",FALSE]))) then {
			player setVariable ["restrain", false, true];
			};
		};
		player playMoveNow "AmovPercMstpSnonWnonDnon_EaseOut"; //Animation out
	}
	else
	{
		restrain=false;
		player setVariable ["restrain", false, true]; //Set surrender to true
		player playMoveNow "AmovPercMstpSnonWnonDnon_EaseOut"; //Animation out
	};
};
restcaller = false;

 

Using the script: You can either use addaction or a keyhandler to execute the script. When you execute the script the player pointed at by the cursor will be restrained (as long as he's in your configured range). Executing the script again will set the player free.

 

If you have any questions or need help with your mission feel free to ask!

Cheers

Puffin

  • Like 1

Share this post


Link to post
Share on other sites

I see you released quite a few scripts today..all great stuff...thanks for sharing these!

 

 

Diesel

  • Like 1

Share this post


Link to post
Share on other sites

Hi Puffin. First off, thanks for releasing this script - the vehicle script has been a great addition to my mission. 

 

Regarding the arrest script, is it possible to have this work on spawned in AI? I'm specifically looking at AI in BMR Insurgency - both civilian and insurgents. 

 

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

@Bosh Sorry for the late reply! This should work:

if (restcaller isEqualto false) then {
	if (restrain isEqualto false) then {
		restrain=true;
		_this setVariable ["restrain", true, true];
		while { _this getVariable ["restrain", false] }  do { 
			_this playMove "AmovPercMstpSnonWnonDnon_EaseIn"; //Animation in
			if (((!alive _this) || (_this getVariable["onkill",FALSE]))) then {
			_this setVariable ["restrain", false, true];
			};
		};
		_this playMoveNow "AmovPercMstpSnonWnonDnon_EaseOut"; //Animation out
	}
	else
	{
		restrain=false;
		_this setVariable ["restrain", false, true]; //Set surrender to true
		_this playMoveNow "AmovPercMstpSnonWnonDnon_EaseOut"; //Animation out
	};
};
restcaller = false;

and in the init of the AI you put

restcaller = false;
restrain = false;

 

Share this post


Link to post
Share on other sites

Hi Puffin thanks for the response!

 

I’ve set up 2 sqf files, restrain and restrainTarget and given the civilian unit an addaction that calls restrain.sqf. 

 

Im having a problem adding ‘restcaller = false;  restrain = false’ because the units are called by script and ‘_unit restcaller = false’ isn’t working. 

 

Any help would be great :)

Share this post


Link to post
Share on other sites
On 10.12.2017 at 2:53 PM, Bosh__ said:

Im having a problem adding ‘restcaller = false;  restrain = false’ because the units are called by script and ‘_unit restcaller = false’ isn’t working. 

You could insert the parameters in the script you are using to call your units.

Share this post


Link to post
Share on other sites

How would I add the restcaller = false and restrain = false to the scripted in units? I'm having trouble finding out how to.

Share this post


Link to post
Share on other sites
On 6.1.2018 at 7:51 PM, Bosh said:

How would I add the restcaller = false and restrain = false to the scripted in units? I'm having trouble finding out how to.

 

If you use a script to spawn the unit, place this line inside your script. May I ask which script are you using?

Share this post


Link to post
Share on other sites

Add

_unit setVariable ["restcaller ", false];
_unit setVariable ["restrain ", false];

at the end of the script before the line that says

} forEach (units _grp);

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×