Jump to content
Sign in to follow this  
XmarksTheScot

Remote Execution, passing variable to reskin vehicle for all players

Recommended Posts

Ok so i stumbled across the setobjecttexture command for vehicles and decided reskin all the vehicles in our domination server. so i placed the commands in the vehicles init in editor and also in the re-spawn script. OFC i then realized that its a local command. so i decided to try the remote execution using the MPF. and then i got stuck.

So just to be clear i have made arrays of vehicles types of, which required different surfaces skined so my script checks the array and skins the correct surfaces with the correct skin.

so heres my codes can some one please tell me how i pass the vehicle the script is working on to the remote executed code on the clients machines

just to be clear i am trying to do this in 3 places, the x_vehrespawn2.sqf, x_helirespawn2.sqf, and our own clan vehicle creator script. so i have a few version of teh script to call dependant on where i call it but they all need to pass the vehicle its working on to a script so should all work same way.

init.sqf

//SOG reskining array
surface0array = ["Ka52","Ka52Black","Su25_CDF","Su34","Mi24_D","BMP3","M1A1","M1A2_TUSK_MG","Mi17_Ins","Mi17_CDF","A10","T34","T72_Gue","T90","ZSU_INS","LAV25","2S6M_Tunguska","AAV","BMP2_CDF","BRDM2_ATGM_CDF","BRDM2_CDF","BTR90","HMMWV_Armored","HMMWV_M2","HMMWV_MK19","HMMWV_TOW","Offroad_DSHKM_Gue","Offroad_SPG9_Gue","UAZ_AGS30_INS","UAZ_MG_CDF","Ural_ZU23_CDF","ZSU_INS","MTVR","MtvrReammo","MtvrRefuel","MtvrRepair","HMMWV_Ambulance","Mi17_Civilian","HMMWV","LAV25_HQ"];
surface1array = ["Ka52","Ka52Black","Su25_CDF","Su34","Mi24_D","BMP3","M1A1","M1A2_TUSK_MG","GAZ_Vodnik_HMG","T34","T72_Gue","T90","ZSU_INS","MTVR","MtvrReammo","MtvrRefuel","MtvrRepair"];
surface2array = ["Mi17_Ins","Mi17_CDF","GAZ_Vodnik_HMG","LAV25","T34","T90","2S6M_Tunguska","Mi17_Civilian","LAV25_HQ"];
surface3array = ["M1A2_TUSK_MG","MTVR","MtvrReammo","MtvrRefuel","MtvrRepair"];

respawn / creator script

_plane = _planeName createVehicle (getMarkerPos _place);
[nil, nil, "per", rEXECVM, "SOG\vehskinc.sqf", _plane] call RE;
if (typeOf _plane in surface0array) then {
_plane setObjectTexture [0,"texture\camoclan.paa"];
};
if (typeOf _plane in surface1array) then {
_plane setObjectTexture [1,"texture\camoclan.paa"];
};
if (typeOf _plane in surface2array) then {
_plane setObjectTexture [2,"texture\camoclan.paa"];
};

called script

_veh = _this select 1;

if (typeOf _veh in surface0array) then {
_veh setObjectTexture [0,"texture\camoclan.paa"];
};
if (typeOf _veh in surface1array) then {
_veh setObjectTexture [1,"texture\camoclan.paa"];
};
if (typeOf _veh in surface2array) then {
_veh setObjectTexture [2,"texture\camoclan.paa"];
};

Currently when a vehicle respawns / or is created it only shows skin to person creating it or when its a respawn, no1 as its local to server only :(

And before i forget yes i placed a functions module in the editor and its domination 2.61 A2 only. Not that the domi is relevant but ...

Anyway, anyone spot my mistake or am i doin something really stupid or is what im doin impossible or what?

Share this post


Link to post
Share on other sites

setObjectTexture work with Multiplayer Framework, so that's a possibility.

This might work?

[nil,nil,"per",rSETOBJECTTEXTURE,_veh,"0","texture\camoclan.paa"] call RE;

I think? Never really used RE since it's apparently terrible :) but play around with things and you should get it working. Or use CBA like any reasonable person and just use CBA global Events to broadcast the texture change after respawn. Could also use triggers as well but that might get silly for multiple vehicles.

Public Event Handlers might be another option. Have the vehicles set a variable after respawn with what texture they should have.

Share this post


Link to post
Share on other sites

CBA aint an option as we run a public arma 2 free server and have no addons.

ill try your code you quoted and see how it goes mate.

i would ofc have to do it like so ?

_plane = _planeName createVehicle (getMarkerPos _place);
if (typeOf _plane in surface0array) then {
_plane setObjectTexture [0,"texture\camoclan.paa"];
[nil,nil,"per",rSETOBJECTTEXTURE,_veh,"0","texture\camoclan.paa"] call RE;
       };
if (typeOf _plane in surface1array) then {
_plane setObjectTexture [1,"texture\camoclan.paa"];
[nil,nil,"per",rSETOBJECTTEXTURE,_veh,"1","texture\camoclan.paa"] call RE;
       };
if (typeOf _plane in surface2array) then {
_plane setObjectTexture [2,"texture\camoclan.paa"];
[nil,nil,"per",rSETOBJECTTEXTURE,_veh,"2","texture\camoclan.paa"] call RE;
       };

Yeah?

Edited by XmarksTheScot

Share this post


Link to post
Share on other sites

Ok so i tried your suggestion but no luck mate

---------- Post added at 01:27 ---------- Previous post was at 00:03 ----------

ok so i realized that i had used the wrong variable name when i copied your example, but even correcting it didn't work so, i check my rpt file to find this

 Error in expression <;
_texture = _this select 4;


_tObject setObjectTexture [_tIndex, _texture];
>
 Error position: <setObjectTexture [_tIndex, _texture];
>
 Error Type String, expected Number

So i unpbo'd the modules.pbo and loked into the MP folder to find all teh scripts it calls when you use MPF, and looked at teh setobjecttexture.sqf and it contained this

scriptName "MP\data\scriptCommands\setObjectTexture.sqf";
_caller = _this select 0;
_target = _this select 1;
_tObject = _this select 2;
_tIndex = _this select 3;
_texture = _this select 4;

//textLogFormat ["MPF_ %1 setDir %2", _target, _dir];
_tObject setObjectTexture [_tIndex, _texture];

So i realsied that it was simply that you had put " " round the surface index :D

so i placed this into my code

[nil,nil,"per",rSETOBJECTTEXTURE,_plane,0,"texture\camoclan.paa"] call RE;

AND......

I works a treat. so we now have custom skined vehicles on our domination server and best of all it even executes the code on players when they join so skinned vehicles remain skinned for everyone all the time.

So thanks mate your help made me at least rethink it a bit :P

Share this post


Link to post
Share on other sites

There has been rumours that setVehicleInit will be revamped / removed since it's used by many hackers.

Share this post


Link to post
Share on other sites

Yes, because that will totally resolve everything. Unless there is an official confirmation I wouldn't worry about that.

Share this post


Link to post
Share on other sites

Well remote execution is also meant to be used just like that example so I don't really see a problem with it.

Share this post


Link to post
Share on other sites

i had tried the setvehicleinit but it still didnt work, the texture was only shown on the machine local to the script.

And as cuel says, was this not the very reason setobjecttexture command was added to the RE command library?

Share this post


Link to post
Share on other sites

You need to run

processInitCommands;

After setting a vehicles init :).

Share this post


Link to post
Share on other sites

Did you call processInitCommands?

As for the use of RE in this case, it's an overkill. You have a lot of unnecessary overhead, especially if this is the only reason you're using functions module. If you wanted to change the texture somewhere down the line long after the vehicle has spawned then sure, that's exactly when you'd use the RE command. But you're doing it right after you spawn the vehicle, on its initialization. That's exactly the sole occasion the use of setVehicleInit/processInitCommands is valid.

Share this post


Link to post
Share on other sites

yeah but im doin it on a Domination server on all bonus vehicles , all support vehicles and 2 different types of created vehicles.

how would your solution of setvehilceinit / processinitcommands handle JIP players?

Share this post


Link to post
Share on other sites

It does so by default.

_vehicle = _type createVehicle _pos;
_vehicle setVehicleInit format ["this setObjectTexture [0, ""%1""]", _texture];
processInitCommands;

Share this post


Link to post
Share on other sites

As I said before, setVehicleInit has less overhead (there is a lot that goes on in the background of RE to do what it does). If you aren't using the functions module for anything else then I'd suggest changing it, otherwise it doesn't matter much.

Share this post


Link to post
Share on other sites

I hate to bring up an old topic but this is most applicable to my current headache.

The idea:

I am trying to apply a specific texture to the player model based on the player UID. I've got it to run but realized setObjectTexture executed locally, leaving me with a lot of people who could see the changes to themselves but not to others.

I'm wondering how to execute

[nil,nil,"per",rSETOBJECTTEXTURE,player,0,"mytexture.paa"] call RE; 

on a player based on the UID.

Every time I've tried I get an error related to the above script. Simply says missing variable.

Next I tried tying each UID to a .sqf that ran the above line using the following:

_unit = _this select 0;
[nil,nil,"per",rSETOBJECTTEXTURE,_unit,0,"mytexture.paa"] call RE;

With that I had the same issue.

Does anyone have any ideas?

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  

×