Jump to content
Sign in to follow this  
Evilhardt

Display Custom Texture only to certain teams

Recommended Posts

Hey,

I want some of my custom textures to only display to OPFOR and some to only display to BLUFOR. Those textures visually mark the border of safezones for the teams, that the other team may not enter. The textures look like this:

http://i.imgur.com/SzwohwT.jpg

But obviously I don't want the team to see the textures which' safezone they designate.

I wonder if that's possible and how to do it. Does anybody have an idea?

Share this post


Link to post
Share on other sites

What are they EvilHardt just 1/10m user textures, if so could you not just use the objects init box to not set the texture for which ever side.

e.g

if (side player == east) then {this setobjecttexture [0, "mytexture"];

or from script somewhere

myEastZoneObjects = [obj1, obj2, obj3];
myWestZoneObjects = [obj4, obj5, obj6];

if (!(isServer)) then {
waitUntil{!(isNull player)};
if (side player == east) then {
	{
		 _x setobjecttexture [0, ""];
	}forEach myEastZoneObjects;
};
if (side player == west) then {
	{
		_x setobjecttexture [0, ""];
	}forEach myWestZoneObjects;
};
};

Edited by Larrow

Share this post


Link to post
Share on other sites

Thank you, there is an issue though. I tried the first solution. It works in the editor but not in MP. I also tried the second solution, but did not know how to call the script. I made a gamelogic object and put into its init line:

_handle = player execVM "savezones.sqf"; 

But apparently that's wrong.

I also called it with a trigger. At least I got no error there. But it does no work either, as the texture does not appear.

I made a BLUFOR-trigger for the east-savezone-textures and put in its ON ACT field:

_handle = player execVM "savezones.sqf"; 

I named the one texture carrier I was testing the script with "obj1".

I modified your script as follows, as I want the textures to be visible to the respective opposing team:

myEastZoneObjects = [obj1, obj2];
myWestZoneObjects = [obj3, obj4];

if (!(isServer)) then {
   waitUntil{!(isNull player)};
   if (side player == west) then {
       {
            _x setobjecttexture [0, "sich2.paa"];
       }forEach myEastZoneObjects;
   };
   if (side player == east) then {
       {
           _x setobjecttexture [0, "sich2.paa"];
       }forEach myWestZoneObjects;
   };
};  

Actually, once the trigger is fired by the BLUFOR-player, the script should be executed and the texture appear on the carrier.

Edit2: Uhm... what is the "!" doing there in "!(isServer)" ?? As I deleted it, it suddenly worked... which kind of makes sense... Unfortunately it also only works in the Editor. In MP it works... partly I can't quite figure out when and when not. For exampel it works, when I span in as BLUFOR. But when I span in as OPFOR and then switch team to BLUFOR it no longer does...

Edited by Evilhardt

Share this post


Link to post
Share on other sites

Do these textures change during the game? If so why are you using a trigger, just set them at gamestart in the init.sqf or even in the init fields of the items.

Share this post


Link to post
Share on other sites

But I want them to be visible only to certain teams. Texture of obj1 and obj2 to Team A, texture of obj3 and obj4 to team B... that is the whole point.

Share this post


Link to post
Share on other sites

Yeah, but the teams and textures aren't gonna change during the game right? So just set then via script rather than getting a trigger involved. Same code, just different place for it.

Share this post


Link to post
Share on other sites

Ok, but how would that be different from putting

if (side player == east) then {this setobjecttexture [0, "mytexture"];

in the init line of the carrier object?

Share this post


Link to post
Share on other sites

As kaylania says i was thinking along the lines of initialising this from the init.sqf

From your picture i was presuming that these are like spawning safe zones, so if your an East side player you would not want to see your own texture round your spawn point but a Blufor player would (notifying them to stay out).

These textured objects in the map would have their textures set in their inits 'this setObjectTexture [0, "textureName"];' .

Then in the init.sqf as setObjectTexture is a local command each client would want to run their own script that disables their own sides textures.

init.sqf

//Array of east safezone objects
myEastZoneObjects = [obj1, obj2, obj3];
//Array of west safezone objects
myWestZoneObjects = [obj4, obj5, obj6];

//Only need to disable stuff local on clients
if (!(isDedicated)) then {
   //Wait until you are initialised
   waitUntil{!(isNull player)};
   //Set your own sides textures to nothing
   if (side player == east) then {
       {
            _x setobjecttexture [0, ""];
       }forEach myEastZoneObjects;
   };
   if (side player == west) then {
       {
           _x setobjecttexture [0, ""];
       }forEach myWestZoneObjects;
   };
};  

I changed the !isServer to !isDedicated, i realise !isServer is gonna cause problems if your a Host server.

That was my thinking behind this way of doing it, although that is all dependant on my presumtion of what this mechanic is actually for.

_____________________________________

Ok, but how would that be different from putting

if (side player == east) then {this setobjecttexture [0, "mytexture"];

in the init line of the carrier object?

Not sure it wouldnt be , but setting all default textures on the object then getting each client to decide what needs to be done seems a safer bet especially with the command being local. but all down to testing i guess Edited by Larrow

Share this post


Link to post
Share on other sites

Hmm...

I did two things. The one thing was to further modify your original script and work with my trigger method, which lead to the result I wanted:

myEastZoneObjects = [obj1, obj2];
myWestZoneObjects = [obj3, obj4];


waitUntil{!(isNull player)};
 if (side player == west) then {
     {
          _x setobjecttexture [0, "safezone.paa"];
     }forEach myEastZoneObjects;
 };
 if (side player == east) then {
     {
         _x setobjecttexture [0, "safezone.paa"];
     }forEach myWestZoneObjects;
};

Then, as you say it would be the safer one, I tried your method:

I put this in the init.sqf:

["obj1", "obj2", "obj3", "obj4"] execVM "safezones.sqf";

and put your code into the safezones.sqf (and put the texture files name in the " ")s.

I also wrote

this setobjecttexture [0, "safezones.paa"];

in the init line of each texture carrier object.

But the result is, that I again can see all the textures no matter the side I am playing as.

What did I do wrong this time?

Edited by Evilhardt

Share this post


Link to post
Share on other sites
I put this in the init.sqf:
["obj1", "obj2", "obj3", "obj4"] execVM "safezones.sqf";

If youve used my code exactly, then you do not need to send the script any params (the ["obj1", "obj2", "obj3", "obj4"] ) < and as strings these would not make any sense to relate to your objects.Just use

_handle = [] execVM "safezones.sqf;

I also wrote
this setobjecttexture [0, "safezones.paa"];

in the init line of each texture carrier object.

Thats correct, this initialises each texture object with a texture.
and put your code into the safezones.sqf (and put the texture files name in the " ")s.
In what ""'s ? In these _x setobjecttexture [0, ""]; ?. If so thats your problem. Its meant to be an empty string so as to unset the texture initialised by the object itself.

The only bit of the code i posted that you would need to change is the arrays to make sure they have the names of your objects in them, like from your trigger version e.g

myEastZoneObjects = [obj1, obj2];
myWestZoneObjects = [obj3, obj4];

Share this post


Link to post
Share on other sites

Ah okay, I thought in "_x setobjecttexture [0, ""]" "0" would mean false. Like "texture with name 'xxx' false".

Share this post


Link to post
Share on other sites

No , when you create a model you can setup different selections.

Take a car for example you could make 1 = the body, 2 = the doors, 3 = all the chrome work. Then you can set different texture per selection. e.g myCar setObjectTexture [ 2, "mytexture.paa"]; Would set the texture for the doors.

See the setObjectTexture command description

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  

×