Jump to content
Sign in to follow this  
Igor Nikolaev

Set vehicle textures after respawn in MP

Recommended Posts

So, I've been using setObjectTextureGlobal command, wanted to retexture vehicles, especially after their respawn. It worked in SP, but in MP it's not. When the car is dead, new respawns, but without my textures. I've been trying many ways, but nothing. I'm using BIS vehicle respawn module.

 

In the init.sqf I got  this:

 

	Fnc_Set_Textures =
	{
			if (_this iskindof "I_Heli_Light_03_unarmed_F") then {
				_this setObjectTextureGlobal [0, 'Hellcat_Template1.paa'];
				};
			if (_this iskindof "B_MRAP_01_hmg_F") then {
				_this setObjectTextureGlobal [0,'hex1.jpg'];
				};
			if (_this iskindof "O_Quadbike_01_F") then {
				_this setObjectTextureGlobal [0,'hex1.jpg'];
				};
			if (_this "I_Heli_Light_03_unarmed_F") then {
                                _this setObjectTextureGlobal [0, 'Hellcat_Template1.paa'];
                            processInitCommands;
				};
			if (_this iskindof "B_MRAP_01_F") then {
				_this setObjectTextureGlobal [0,'hex1.jpg'];
				};
			if (_this iskindof "B_SDV_01_F") then {
				_this setObjectTextureGlobal [0,'hex1.jpg'];
    };

In the vehicle init line (example): 

this setObjectTexture [0, "Hellcat_Template1.paa"]

In the respawn module expression field: 

(_this select 0) spawn Fnc_Set_Textures;


So what is wrong? 

 

Share this post


Link to post
Share on other sites

Syntax is incorrect on last "if" statement. As well as this, your script can be formatted in a much better way (complying to scripting standards):

 

You need to make sure "Fnc_Set_Textures" is defined as a global variable somewhere in your mission. I recommend defining it in the CfgFunctions class (although it will reformat the name). Simplest way would be to define it in the init.sqf

// init.sqf

Fnc_Set_Textures = {
    // Your code here
};

// ... 

Rewrite your code from this: 

Fnc_Set_Textures = {
  _vehicle = _this param [0,objNull,[objNull]];
  if (isNull _vehicle) exitWith {false}; // returns false if no vehicle given
  private ["_texture","_selection"];
  switch (typeOf _vehicle) do {
    case "I_Heli_Light_03_unarmed_F" : {
      _texture = "Hellcat_Template1.paa";
      _selection = 0;
    };
    case "B_MRAP_01_hmg_F" : {
      _texture = "hex1.jpg";
      _selection = 0;
    };
    case "O_Quadbike_01_F" : {
      _texture = "hex1.jpg";
      _selection = 0;
    };
    case "B_MRAP_01_F" : {
      _texture = "hex1.jpg";
      _selection = 0;
    };
    case "B_SDV_01_F" : {
      _texture = "hex1.jpg";
      _selection = 0;
    };
    default {
      _texture = "#argb(8,8,3)color(1,1,1,1)"; // default white texture
      _selection = 0;
    };
  };
  _vehicle setObjectTextureGlobal [_selection,_texture];
  // return vehicle
  _vehicle;
};

Call using:

[(_this select 0)] call Fnc_Set_Textures;

PLEASE NOTE: Not all vehicles have hiddenSelections (texture maps) that can be changed. I recommend you look through the config viewer before trying to change vehicle textures to make sure you have the right selection. I would also recommend using .paa extension over the .jpg extension. Both should work, but .paa is native to the engine and is better practice.

 

 

Hope this helps,

 

Bull

  • Like 1

Share this post


Link to post
Share on other sites

I know this is an old post, but does anyone know how you would use the above init for a vehicle that has more then 1 hiddenSelection.

Thanks in advance.

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
Sign in to follow this  

×