Jump to content
sbondo1234

Custom Clothing Textures

Recommended Posts

I have a mission file I have been working on and I wanted to add custom textures to the clothing that you spawn in with. I have tried many things and I just can't find something that works. I have tried putting code in the init.sqf and I have also tried putting a line of code into each spawnable character in the mission file. Nothing seems to give the characters the texture I have put in an images folder.

 

I have tried putting this into the init.sqf:

{
  if ((side _x) == West) then {
     _x setObjectTexture [0, "images\red.paa"];
  };
} forEach allUnits;

Although when I spawn in it doesn't seem to work. The command works when I exec it in the debug console, so I'm not sure why that happens. The texture is blue when I exec it with the debug console, I'm not sure if that helps since my texture is red but it happens.

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, sbondo1234 said:

this

 

Hello there sbondo1234 and welcome to BIS Forums !

 

Try :

 

#updated

if (isServer) then {
{	
	if (
	((alive _x))
	&& ((side _x) == west)
	) then {
	[_x,[0,"images\red.paa"]] remoteExec ["setObjectTexture",0,true];
	};
}forEach allUnits;
};

 

  • Like 1

Share this post


Link to post
Share on other sites
Just now, GEORGE FLOROS GR said:

 

Hello there sbondo1234 and welcome to BIS Forums !

 

Try :


if ((side group _x) == west) then {
_x setObjectTextureGlobal [0, "images\red.paa"];
}forEach allUnits;

 

Hey! Thanks for your reply.

I have tried it in-game and it isn't working.

 

 

Share this post


Link to post
Share on other sites

This code is client side so using this (setObjectTextureGlobal) will cause the texture to be set globally, this isn't that useful for init.sqf which executes globally anyway, but doesn't hurt anyone.

As for your problem, my thoughts are that a good way to find your answer is in your question:

Code works, however not in init.sqf.

This means it is probably an initialisation order problem. Meaning this code is running before your units exist.

Try this to test that.
 

sleep 10; 
 
{ 
  
	_x setObjectTextureGlobal [0, "images\red.paa"]; 
 
} forEach (allUnits select {side _x == WEST});



 

Share this post


Link to post
Share on other sites
7 hours ago, MKD3-FHI said:

This code is client side so using this (setObjectTextureGlobal) will cause the texture to be set globally, this isn't that useful for init.sqf which executes globally anyway, but doesn't hurt anyone.

As for your problem, my thoughts are that a good way to find your answer is in your question:

Code works, however not in init.sqf.

This means it is probably an initialisation order problem. Meaning this code is running before your units exist.

Try this to test that.
 


sleep 10; 
 
{ 
  
	_x setObjectTextureGlobal [0, "images\red.paa"]; 
 
} forEach (allUnits select {side _x == WEST});



 

Hey, thanks for this! It kind of works.

 

Is it possible you know how I would make it exec this every x seconds?

 

I'm also having trouble with people not seeing others have the texture on them but they can see themselves with it.

Share this post


Link to post
Share on other sites

Sorry for the error above !

 

if (isServer) then {
{	
	if (
	((alive _x))
	&& ((side _x) == west)
	) then {
	[_x,[0,"images\red.paa"]] remoteExec ["setObjectTexture",0,true];
	};
}forEach allUnits;
};

 

Share this post


Link to post
Share on other sites
	[_x,[0,"images\red.paa"]] remoteExec ["setObjectTexture",0,true];

Why? Use:

https://community.bistudio.com/wiki/setObjectTextureGlobal

No need for remoteExec now.

 

EDIT: Also take into account that texture is gone when uniform is dropped. This can be easily resolved by setting it again inside Take EH. No need for while loop.

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Take

  • Like 1

Share this post


Link to post
Share on other sites
Just now, GEORGE FLOROS GR said:

Sorry for the error above !

 


if (isServer) then {
{	
	if (
	((alive _x))
	&& ((side _x) == west)
	) then {
	[_x,[0,"images\red.paa"]] remoteExec ["setObjectTexture",0,true];
	};
}forEach allUnits;
};

 

 

Just now, HazJ said:

	[_x,[0,"images\red.paa"]] remoteExec ["setObjectTexture",0,true];

Why? Use:

https://community.bistudio.com/wiki/setObjectTextureGlobal

No need for remoteExec now.

Thanks for your guy's responses.

I have a script which makes sure that the player is wearing what they are supposed to, so whenever it runs it changes the texture back to default. Is there any way around this? 

Share this post


Link to post
Share on other sites

Sure but I don't recommend doing it like that. Ditch all you have and start over. Set uniform and texture first. Then use EHs to set it again  where required.

Take EH

Respawn EH

Share this post


Link to post
Share on other sites
Just now, HazJ said:

Sure but I don't recommend doing it like that. Ditch all you have and start over. Set uniform and texture first. Then use EHs to set it again  where required.

Take EH

Respawn EH

so would this set their texture every time they die?

this addEventHandler ["Killed", {
      setObjectTextureGlobal [0, "images\red.paa"];  
}

Is it possible to change their texture every time their clothes are changed? 

 

Maybe if I set it to every time their animation changes it will change their texture so no one will ever notice it is happening.

 

This doesn't work am I doing the eventhandler wrongly?

Share this post


Link to post
Share on other sites

When they respawn and when uniform is taken. Read what I say to you and link...

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Take

Quote

Triggers when a unit takes an item from a container.

this addEventHandler ["Take", { params ["_unit", "_container", "_item"]; }];

unit: Object - Unit to which the event handler is assigned

container: Object - The container from which the item was taken (vehicle, box, etc.)

item: String - The class name of the taken item

 

 

Share this post


Link to post
Share on other sites
Just now, HazJ said:

When they respawn and when uniform is taken. Read what I say to you and link...

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Take

 

What would this look like when in the init? I'm not sure how to make it change the texture whenever the player 'takes' or when animation changes (AnimChanged).

I am currently trying to make this work, but it doesn't:

this addEventHandler ["AnimChanged", {
      setObjectTextureGlobal [0, "images\red.paa"];  
}

 

Share this post


Link to post
Share on other sites

I didn't say AnimChanged. Anim is for animation...

// initPlayerLocal.sqf

player forceAddUniform "UniformClassnameGoesHere";
player setObjectTextureGlobal [0, "images\red.paa"];

player addEventHandler ["Respawn",
{
	params ["_unit", "_corpse"];
	_unit forceAddUniform "UniformClassnameGoesHere";
	_unit setObjectTextureGlobal [0, "images\red.paa"];
}];

player addEventHandler ["Take",
{
	params ["_unit", "_container", "_item"];
	if (_item isEqualTo "UniformClassnameGoesHere") then
	{
		_unit setObjectTextureGlobal [0, "images\red.paa"];
	};
}];

You may want to make it into a function with some switch block if you plan to add multiple uniforms with different textures. Not tested!

Share this post


Link to post
Share on other sites
Just now, HazJ said:

I didn't say AnimChanged. Anim is for animation...


// initPlayerLocal.sqf

player forceAddUniform "UniformClassnameGoesHere";
player setObjectTextureGlobal [0, "images\red.paa"];

player addEventHandler ["Respawn",
{
	params ["_unit", "_corpse"];
	_unit forceAddUniform "UniformClassnameGoesHere";
	_unit setObjectTextureGlobal [0, "images\red.paa"];
}];

player addEventHandler ["Take",
{
	params ["_unit", "_container", "_item"];
	if (_item isEqualTo "UniformClassnameGoesHere") then
	{
		_unit setObjectTextureGlobal [0, "images\red.paa"];
	};
}];

You may want to make it into a function with some switch block if you plan to add multiple uniforms with different textures. Not tested!

This isn't working. The uniform is textured up until it is refreshed. 

Share this post


Link to post
Share on other sites

?

It should texture on start, when you drop it and take it back as well as upon respawn. Saying it isn't working isn't very useful. I did say it wasn't tested but you could provide more useful info. Else I won't bother. I have already done most of it for you.

 

EDIT: Tested and it works fine. Example:

https://hazjohnson.com/ArmA/textureTest.VR.zip

I switched the PAA texture for red colour as didn't have your red.paa file.

... setObjectTextureGlobal [0, "#(rgb,8,8,3)color(1,0,0,1)"];

 

Share this post


Link to post
Share on other sites
Just now, HazJ said:

?

It should texture on start, when you drop it and take it back as well as upon respawn. Saying it isn't working isn't very useful. I did say it wasn't tested but you could provide more useful info. Else I won't bother. I have already done most of it for you.

 

EDIT: Tested and it works fine. Example:

https://hazjohnson.com/ArmA/textureTest.VR.zip

I switched the PAA texture for red colour as didn't have your red.paa file.


... setObjectTextureGlobal [0, "#(rgb,8,8,3)color(1,0,0,1)"];

 

Hey! Sorry if I am a bit frustrating to handle, I'm pretty new to mission editing I'm learning as we go really.

 

I solved the problem, the script I mentioned before which kept overwriting the texture I edited with this and it works now.

 

Thanks for everyone for all the help! @GEORGE FLOROS GR  @HazJ @MKD3-FHI You have been a great help, thank you!

  • Like 2

Share this post


Link to post
Share on other sites

The problem isn't that you are new, the problem is that you do not read. You appear to have a very careless attitude. If you are willing to learn, you need to put more effort in. The fact that I had to explain something more than twice then go on to make an example mission says it all really. I am not having a go at you, I'm just saying. Do as you wish of course but people may not be inclined to help you like I did if you don't help yourself. There was no problem, at least with the code I gave you. It worked, the only thing different in the example mission is that I used the RGB colour code. I cannot guess what you had already done and it makes no sense to keep it when I gave you working code. Glad you got it sorted.

Share this post


Link to post
Share on other sites
Just now, HazJ said:

The problem isn't that you are new, the problem is that you do not read. You appear to have a very careless attitude. If you are willing to learn, you need to put more effort in. The fact that I had to explain something more than twice then go on to make an example mission says it all really. I am not having a go at you, I'm just saying. Do as you wish of course but people may not be inclined to help you like I did if you don't help yourself. There was no problem, at least with the code I gave you. It worked, the only thing different in the example mission is that I used the RGB colour code. I cannot guess what you had already done and it makes no sense to keep it when I gave you working code. Glad you got it sorted.

I am reading this stuff. Your code does work and it has each time, but the part that didn't work was when the script, which I had mentioned before (the one that gives you the gear to double check you have the right thing) ran and gave new clothes. Trust me man I am trying, 2 hours ago I didn't know what an 'EH' was so I googled 'arma eh' and I found event handlers page.

Share this post


Link to post
Share on other sites

Maybe @HazJ needs to relax a little. When a person doesnt understand the way arma functions and events happen, I wouldnt expect them to understand what a switch block or event a basic eventhandler do. Im pretty experienced with Arma but I wouldn't have got through this sort of thing without help from an actual programmer and hours of reading and asking seemingly stupid questions. Good luck @sbondo1234

EDIT: Not saying that hazJ hasnt been helpful, just saying a patience is a virtue :f:

  • Like 1

Share this post


Link to post
Share on other sites

@MKD3-FHI - I was relaxed. People just don't want to read or try themselves. EHs are very easy if you read the Wiki (which btw I linked) so maybe you aren't as experienced as you think. Further more, if you read my posts above you would of saw the example mission that I provided. There was no switch block, what I said was if you have multiple clothing and textures you may want to look into that method. The reason for this is simple:

On 11/20/2018 at 11:53 AM, HazJ said:

The problem isn't that you are new, the problem is that you do not read. You appear to have a very careless attitude. If you are willing to learn, you need to put more effort in. The fact that I had to explain something more than twice then go on to make an example mission says it all really. I am not having a go at you, I'm just saying. Do as you wish of course but people may not be inclined to help you like I did if you don't help yourself. There was no problem, at least with the code I gave you. It worked, the only thing different in the example mission is that I used the RGB colour code. I cannot guess what you had already done and it makes no sense to keep it when I gave you working code. Glad you got it sorted.

People don't read what is right in front of them. Or people come back and say it "doesn't work". How is that helpful for people who are trying to help? It also comes across as a CBA (can't be arsed) attitude.

 

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

×