Jump to content
Sign in to follow this  
mr_shadow

JiP Setobjecttexture

Recommended Posts

Hey, there are some vehicles in mission which spawns after start.

	vehname = "C_Offroad_01_F";
			_veh = vehname createVehicle (carspawn);
[[[_veh],"Car_colourblk.sqf"],"BIS_fnc_execVM",false,true] spawn BIS_fnc_MP;

Car_colourblk.sqf


_vehicle = _this select 0;
[[_vehicle], "set_texturesblk", nil, false] spawn BIS_fnc_MP;

init.sqf

set_texturesblk= compile preprocessFileLineNumbers "set_texturesblk.sqf";

set_texturesblk.sqf

_vehicle = _this select 0;

_vehicle setObjectTexture [0,"textures\SL_Offroad_Brit2344.jpg"] spawn BIS_fnc_MP;

Problem: JiP player wont see the texture.

Is there any solution for this?

Share this post


Link to post
Share on other sites

Your execVM of the Car_colourblk.sqf file seems redundant, just call the function your using straight away. And your use of BIS_fnc_MP in the set_texturesblk.sqf is incorrect, and you shouldn't need to use BIS_fnc_MP for it if you use setObjectTextureGlobal instead.

Share this post


Link to post
Share on other sites

Setobjecttexture global isn't working for jip, even if it was placed directly to spawning script. Car color.sqf was also used for other targets which were cut.

Share this post


Link to post
Share on other sites
Your execVM of the Car_colourblk.sqf file seems redundant, just call the function your using straight away. And your use of BIS_fnc_MP in the set_texturesblk.sqf is incorrect, and you shouldn't need to use BIS_fnc_MP for it if you use setObjectTextureGlobal instead.

setObjectTextureGlobal last I checked was/is a broken command. It breaks the ability to clear out the vehicle's cargo and also removes all variables attached to the vehicle. If nothing serious/critical is being done with the vehicle then by all means setObjectTextureGlobal is recommended. A way to do it without setObjectTextureGlobal which is the same way I've been doing it forever is to store a variable on the vehicle like so:

_vehicle setVariable["texture","textures\SL_Offroad_Brit2344.jpg",true];

And then detect if the client is JIP which you can easily do with initPlayerLocal.sqf:

if(_this select 1) then {
{
	_texture = _x getVariable["texture",""];
	if(_texture != "") then {
		_x setObjectTexture [0,_texture];
	};
} foreach (allMissionObjects "Car");
};

Another way to do it with BIS_fnc_MP which is where you went wrong..

Car_colourblk.sqf (Take note of true, it tells JIP clients to run it. If you are constantly pushing out vehicles though it is not recommended to use this option and better to use the solution above due to network things)

_vehicle = _this select 0;
[[_vehicle], "set_texturesblk", nil, true] spawn BIS_fnc_MP;

set_texturesblk.sqf is wrong, it should be this:

_vehicle = _this select 0;
_vehicle setObjectTexture [0,"textures\SL_Offroad_Brit2344.jpg"];

Share this post


Link to post
Share on other sites

Hm, I do not understand the part of iniplayerlocal.sqf

Not sure how it's going to place different textures on same class name.

Thanks for the explanation of alernative way.

Edited by mr_shadow

Share this post


Link to post
Share on other sites
Hm, I do not understand the part of iniplayerlocal.sqf

Not sure how it's going to place different textures on same class name.

Thanks for the explanation of alernative way.

The work-around I provided can already do that? When spawning the vehicle in and setting the variable "texture" on it, just store the texture you want.. i.e

Vehicle 1:

_vehicle setVariable["texture","textures\SL_Offroad_Brit2344.jpg",true];  

Vehicle 2:

_vehicle setVariable["texture","textures\Other_texture.jpg",true];  

Share this post


Link to post
Share on other sites

Hey, I've got the same problem and couldn't get it to work. Tried a similar workaround as Tonic suggested but still no luck. The server-player sees all objects textured correctly while the client only sees the stock textures. And it's not even JIP, both players have been there from mission start. Here's my example setup:

IP_fnc_setObjectTexture

private ["_obj", "_params"];
_obj = [_this, 0, ObjNull, [ObjNull]] call BIS_fnc_param;
_params = [_this, 1, [], [[]], 2] call BIS_fnc_param;

_obj setObjectTexture _params;

Call on mission start:

[[_unit, [0, _txt]], "IP_fnc_setObjectTexture", nil, true] call BIS_fnc_MP;

setObjectTextureGlobal doesn't seem to work at all. oO

---------- Post added at 12:35 AM ---------- Previous post was at 12:28 AM ----------

Addition: setObjectTextureGlobal run from an object's init line seems to work but in a script that gets executed in a function called from the init.sqf it doesn't - weird.

Share this post


Link to post
Share on other sites

Confirmed. Tested 2 ways. Both doesn't work.

However if I'll put the setobjecttexture global in init, it will stay for JiP players, BUT there is a big chance that it will spawn with stock texture.

Share this post


Link to post
Share on other sites

Odd, I could swear it worked before the helo DLC patch...

Share this post


Link to post
Share on other sites
Hmm ... setObjectTextureGlobal works fine for me in MP, no issues at all. Is there a relevant feedback ticket?

Do you run it from init line or in a script somwhere later? First thing works for me the latter doesn't. Even if I run it from the debug console the texture on the server's side gets changed back to the stock one.

Share this post


Link to post
Share on other sites
Do you run it from init line or in a script somwhere later? First thing works for me the latter doesn't. Even if I run it from the debug console the texture on the server's side gets changed back to the stock one.

How is it getting changed back? On re-JIP or in front of your eyes?

Share this post


Link to post
Share on other sites

No, if it was set correctly (on server side) and I try to apply it again during an MP session using the debug console. It's just flickering shortly on client side but stays stock, and changes back to stock on server side. Observed this while testing COOP with a friend.

Share this post


Link to post
Share on other sites

IndeedPete if you will use fnc like in my example that will solve your problem, but my is still here...

Share this post


Link to post
Share on other sites
[[[_veh],"Car_colourblk.sqf"],"BIS_fnc_execVM",false,true] spawn BIS_fnc_MP;  

Share this post


Link to post
Share on other sites

But in the end, you're just applying setObjectTexture on each client which I've tried as well to no avail.

Share this post


Link to post
Share on other sites
But in the end, you're just applying setObjectTexture on each client which I've tried as well to no avail.

private ["_obj", "_params"];
_obj = [_this, 0, ObjNull, [ObjNull]] call BIS_fnc_param;
_params = [_this, 1, [], [[]], 2] call BIS_fnc_param;

_obj setObjectTexture[color="#008000"]Global[/color] _params;

I think you're going about this in a manner more difficult than necessary.

setObjectTextureGlobal does not need to be remote exec via BIS_fnc_MP. The command has global effect and holds for JIP.

All you should have to do is call that function on the server, does not need remote execution.

I am assuming the texture and selections are fine and that there is nothing dodgy about the vehicles scripts.

Also, the function is slightly unnecessary.

As of a few updates ago, simply do this, instead of calling the function above:

[[_obj,[_params]],"setObjectTextureGlobal",TRUE,FALSE] spawn BIS_fnc_MP;

Edited by MDCCLXXVI

Share this post


Link to post
Share on other sites

setObjectTextureGlobal doesn't seem to work at all. oO

---------- Post added at 12:35 AM ---------- Previous post was at 12:28 AM ----------

Addition: setObjectTextureGlobal run from an object's init line seems to work but in a script that gets executed in a function called from the init.sqf it doesn't - weird.

As said, the global version does not work for me when called during the mission. Works fine from init though.

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  

×