Jump to content
Sign in to follow this  
Double Doppler

SetObjectTexture for respawn?

Recommended Posts

I messed around in the mission editor, and found I could set custom textures to objects using "setObjectTexture", which I entered in the units init field. But when the character I am playing gets killed, the texture gets reset back to normal on respawn :mad:. Is there a way to predefine re-textures in the Description.ext or a config?

Share this post


Link to post
Share on other sites

Trigger

Activated repeatedly

Condition: alive player

On act: player setVehicleInit "this setObjectTexture [0,'texture.paa']";processInitCommands

That's the simplest way anyhow. setVehicleInit is used to make the texture change visible to other players.

Share this post


Link to post
Share on other sites

Repeatable doesn't mean it will activate every 0.5s while it is true. The condition have to be false again, before it can be reactivated. But you're right; a respawn event handler mig be more appropriate.

Alternatively MPF framework can be used if you don't want to handle adding the EH to JIP's.:

[nil, nil, "per", rSpawn, player, {_this setObjectTexture [0,'texture.paa'];}] call RE;

Share this post


Link to post
Share on other sites

I tried the first method that Celery suggested, and put "IsKindof ""players'model"" " into the condition and it did just what I wanted. Though I suppose it will cause alot of lag when the players join the mission. What I want it to do is to retexture specific units when they die, so they keep the texture all round, preferably defined by the unit's name. Maybe an event handler could do the trick.

Edited by Double Doppler

Share this post


Link to post
Share on other sites

I tried this with a friend in a mission later on and it seems it only affects the players model so the player will see his unit retextured but his friends remain untextured but they see themselves as re-textured :confused:

Share this post


Link to post
Share on other sites

I have 2 solutions for this:

1. Just tell all clients, when a player respawns, to retexture all units from array:

waitUntil {(isDedicated) || !(isNull player)};

if (!isDedicated) then {

_RespawnEH = player addMPEventHandler ["MPRespawn", {
	SetPlayerTexture = true; publicVariable "SetPlayerTexture";
}];

SetPlayerTexture = false;
_RetexturePlayers = [[color="RoyalBlue"]Unitname[/color],[color="RoyalBlue"]Unitname1[/color]];

while {true} do {
	waitUntil {SetPlayerTexture};
	{_x setObjectTexture [0,"xyz.paa"]} forEach _RetexturePlayers;
	sleep 2;
	SetPlayerTexture = false; publicVariable "SetPlayerTexture";
};

};

2. EventHandler:

waitUntil {(isDedicated) || !(isNull player)};

if (!isDedicated) then {

"SetPlayerTexture" addPublicVariableEventHandler {
	_Player = _this select 0;
	_Player setObjectTexture [0,"xyz.paa"];
};

_RespawnEH = player addMPEventHandler ["MPRespawn", {
	SetPlayerTexture = [_this]; publicVariable "SetPlayerTexture";
}];

};

Share this post


Link to post
Share on other sites

No, my codes will work in all environments. :)

Note the ! in front of the isDedicated's. :)

Share this post


Link to post
Share on other sites

What would I put if I wanted my player and my AI squad memebers to all respawn with the retextures I made? My problem is I retextured some units to make them look like C.I.A. Special Activitys Division Operators, and all works good but when I am online playing missions i made with them once the AI or me die we dont respawn retxtured anymore! And I dont understand the code above or how to use it?

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  

×