Jump to content
sovietpolarbear

Custom textures are gone after a unit respawns.

Recommended Posts

I am currently making a mission that uses custom textures set to the uniform of the player. This mission is a multiplayer PVP mission that will be played on a dedicated server. 

 

I am using 

this setObjectTextureglobal [0,"textures\texturefilename.paa"];

in the individual init of each placed unit to call the texture and it works fine. The units get their texture. My issue is that after they respawn, they lose their texture and revert back to their vanilla uniforms. 

 

I am using onPlayerkilled.sqf which contains 

player setVariable ["Saved_Loadout",getUnitLoadout player];

 

and onPlayerRespawn.sqf which contains 

player setUnitLoadout (player getVariable ["Saved_Loadout",[]]);

 

The respawn works and the players, once they die, receive their gear I gave them through a gearscript. 

 

 

Share this post


Link to post
Share on other sites

Put this in the onPlayerRespawn.sqf:

player setObjectTextureglobal [0,"textures\texturefilename.paa"];

You can also make use of the getObjectTextures command if you need to. The getUnitLoadout command only saves containers and items but not textures.

Share this post


Link to post
Share on other sites
On 7/14/2017 at 0:01 PM, 7erra said:

Put this in the onPlayerRespawn.sqf:


player setObjectTextureglobal [0,"textures\texturefilename.paa"];

You can also make use of the getObjectTextures command if you need to. The getUnitLoadout command only saves containers and items but not textures.

 

Thank you it works! In my mission two different sides are using two different textures that I have given them. 

player setObjectTextureglobal [0,"textures\texturefilename.paa"];

Adding this code respawns a team with their original texture but not the other. What code would I put into onPlayerRespawn.sqf: which would allow for two teams(West & East) to respawn with their original textures that are different from each other? 

Share this post


Link to post
Share on other sites

Make a switch:

params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];
_texture = switch (side _newUnit) do {
	case east: {"textures\texturefilenameEAST.paa"};
	case west: {"textures\texturefilenameWEST.paa"};
	/*
	case independent:{"textures\texturefilenameIND.paa"};
	case civilian:{"textures\texturefilenameCIV.paa"};
	*/
	default {"textures\texturefilenameEAST.paa"};
};
_newUnit setObjectTextureglobal [0,_texture];

//---OR---//
if (side _newUnit == west) then {
	_newUnit setObjectTextureglobal [0,"myTextureWEST.paa"];
} else {
	_newUnit setObjectTextureglobal [0,"myTextureEAST.paa"];
};

Only use one of the options. The second one is faster but the first is more flexibile. In your case there are only two options I guess, so the second one is sufficient.

Share this post


Link to post
Share on other sites
22 hours ago, 7erra said:

Make a switch:


params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];
_texture = switch (side _newUnit) do {
	case east: {"textures\texturefilenameEAST.paa"};
	case west: {"textures\texturefilenameWEST.paa"};
	/*
	case independent:{"textures\texturefilenameIND.paa"};
	case civilian:{"textures\texturefilenameCIV.paa"};
	*/
	default {"textures\texturefilenameEAST.paa"};
};
_newUnit setObjectTextureglobal [0,_texture];

//---OR---//
if (side _newUnit == west) then {
	_newUnit setObjectTextureglobal [0,"myTextureWEST.paa"];
} else {
	_newUnit setObjectTextureglobal [0,"myTextureEAST.paa"];
};

Only use one of the options. The second one is faster but the first is more flexibile. In your case there are only two options I guess, so the second one is sufficient.

 

Oddly enough it didn't work

 

This is what's in my onPlayerRespawn.sqf

 

player setUnitLoadout(player getVariable["Saved_Loadout",[]]);

params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];
_texture = switch (side _newUnit) do {
	case east: {"textures\vietnam_vc_goon.paa"};
	case west: {"textures\vietnam_marines_goon.paa"};
	/*
	case independent:{"textures\vietnam_vc_goon.paa"};
	case civilian:{"textures\vietnam_vc_goon.paa"};
	*/
	default {"textures\vietnam_vc_goon.paa"};
};
_newUnit setObjectTextureglobal [0,_texture];

 

Share this post


Link to post
Share on other sites

Try this on your units:

getObjectTextures unitName;

If it returns [] you can't retexture the object. I tested it with the civillian journalist ([], no texture changed) and the BLUFOR ammobearer (worked).

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

×