Jump to content
Sign in to follow this  
giorox

setObjectTexture after vehicle respawn

Recommended Posts

So recently, i've been using the setObjectTexture command to retexture some vehicles, and they work fine with JIPs and MP, though my current problem is that i cant make it so after the vehicle is destroyed and it respawns, so that it has the same texture, and that it broadcasts globally.

I am currently using Simple Vehicle Respawn v1.7 by Tophe of Östgöta Ops [OOPS]

Which goes like this:

if (!isServer) exitWith {};

// Define variables
_unit = _this select 0;
_delay = if (count _this > 1) then {_this select 1} else {30};
_deserted = if (count _this > 2) then {_this select 2} else {120};
_respawns = if (count _this > 3) then {_this select 3} else {0};
_explode = if (count _this > 4) then {_this select 4} else {false};
_dynamic = if (count _this > 5) then {_this select 5} else {false};
_unitinit = if (count _this > 6) then {_this select 6} else {};
_haveinit = if (count _this > 6) then {true} else {false};

_hasname = false;
_unitname = vehicleVarName _unit;
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
_noend = true;
_run = true;
_rounds = 0;

if (_delay < 0) then {_delay = 0};
if (_deserted < 0) then {_deserted = 0};
if (_respawns <= 0) then {_respawns= 0; _noend = true;};
if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;
_position = getPosASL _unit;
_type = typeOf _unit;
_dead = false;
_nodelay = false;


// Start monitoring the vehicle
while {_run} do 
{	
sleep (2 + random 10);
     if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

// Check if the vehicle is deserted.
if (_deserted > 0) then
{
	if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then 
	{
		_timeout = time + _deserted;
		sleep 0.1;
	 	waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
		if ({alive _x} count crew _unit > 0) then {_dead = false}; 
		if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true}; 
		if !(alive _unit) then {_dead = true; _nodelay = false}; 
	};
};

// Respawn vehicle
     if (_dead) then 
{	
	if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
	if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
	if (_explode) then {_effect = "M_TOW_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};
	sleep 0.1;

	deleteVehicle _unit;
	sleep 2;
	_unit = _type createVehicle _position;
	_unit setPosASL _position;
	_unit setDir _dir;

	if (_haveinit) then 
				{_unit setVehicleInit format ["%1;", _unitinit];
				processInitCommands;};
	if (_hasname) then 
				{_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
				processInitCommands;};

	_dead = false;

	// Check respawn amount
	if !(_noend) then {_rounds = _rounds + 1};
	if ((_rounds == _respawns) and !(_noend)) then {_run = false;};
};
};

Now i understand that i could put setobjecttexture after it creates the vehicle, though the problem i've ran into is that it only executes setObjectTexture locally, is there anyway to have it broadcast globally?

Share this post


Link to post
Share on other sites

Try adding setObjectTexture into the parameters when calling the respawn script, so that its added to the vehicles init on respawn.

Edited by Foxy

Share this post


Link to post
Share on other sites

I have and the problem is, it only broadcasts locally.

Share this post


Link to post
Share on other sites

setVehicleInit is supposed to have global effects?

---------- Post added at 18:41 ---------- Previous post was at 18:06 ----------

Sorry I don't know what the problem is... it worked fine for me on my tests (dedi server). Didn't get a chance to test JIP, but the texture is showing on vehicle respawn.

Edited by Foxy

Share this post


Link to post
Share on other sites

The test i ran was, the other player would be on the server when the mission started (but JIPs also worked) and he would see all the textures perfectly, we then went and destroyed one of the vehicles, and then awaited respawn, when it respawned it showed me the texture but not the other person.

But would you mind telling me what you did?

EDIT: Would it work if i added this after it creates the vehicle (in the script):

_unit setVehicleInit "this setObjectTexture [0, "images\texture.paa"]"; processInitCommands

EDIT2: Didn't work, nevermind... When that is added the vehicle wont even respawn.

Edited by Giorox

Share this post


Link to post
Share on other sites

maybe you need to double string ""images\texture.paa"" ? Not sure though :p

Share this post


Link to post
Share on other sites

What do you mean double? I know that my vehicle has 2 hidden selections, but i was testing for only 1 to see if it worked with setVehicleInit, except it didn't even respawn said vehicle.

Share this post


Link to post
Share on other sites

As iceman says above, you need to define the command that is placed within vehicleinit

Such as

***
if (_car isKindOf "SUV_PMC") then {
   _car setVehicleInit "this setObjectTexture [0, ""server\textures\camo10.paa""]";
   processInitCommands;
};

Share this post


Link to post
Share on other sites

Well, that isn't as complicated as i was trying to make it out to be...

Seems like it was just what i suspected, i had to double the quotation marks...Well, that goes to show that you should try everything you can to fix it :P

Thanks marker, foxy and iceman, it seems to be working fine. (:

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  

×