Blitzer134 1 Posted May 9, 2013 whats the new setVehicleInit - processInitCommands and how to use them to fix this code found compilefinal no idea what it does }; // Set all the things common to the spawned unit _spawnUnit setDir _unitDir; _spawnUnit setSkill _unitSkill; _spawnUnit setUnitRank _unitRank; if (_spawntype == "once" OR _spawntype == "repeated") then { _spawnUnit setVehicleVarName _unitName; if (vehiclevarname _spawnUnit != "") then { _spawnUnit setVehicleInit format["%1=this;",_unitName]; processInitCommands; }; }; } forEach _unitArray; } forEach _waypointsArray; // Setting the leaders init and the groups body removal time (vehicle (leader _newGroup)) setVehicleInit _initString; processInitCommands; // Run the cleanup function for this group [_newGroup, _bodyRemove] spawn _fnc_cleanGroup; // Have to return the new group _newGroup; }; Thanks Share this post Link to post Share on other sites
neokika 62 Posted May 9, 2013 Hi, Both setVehicleInit and it's related processInitCommands have been removed completely from Arma 3 and there are no new ones. These have been removed because they were created (a long time ago) for never released functionality and were always discouraged to be used, at all. That is why it is never used internally (official content). For a long time (since before Arma 2 I think) there are more secure and robust ways to deal with multiplayer locality. The new compileFinal probably is not what you are looking for in this particular case, basically, it allows you to define functions/code to a final variable, that does not allow further modifications to it. Within the first piece of code you posted you simply store a created object to a variable, that can be accessed from any computer within the network and could be changed to: TAG_myGlobalVariable = _spawnUnit; publicVariable "TAG_myGlobalVariable"; So, both the server and clients now can access _spawnUnit object that is stored within TAG_myGlobalVariable. Something to keep in mind about multiplayer scripting is knowing what needs to be executed where. Most of the commands documented on the wiki have their locality defined. When inside a scripting function page, you can check what's it's locality. - Arguments need to be local - Arguments do not need to be local - Effects happen locally, where the command is issued only - Effects are global and happen on every computer connected Share this post Link to post Share on other sites
Blitzer134 1 Posted May 9, 2013 Thanks for explaining Share this post Link to post Share on other sites
Lala14 135 Posted July 8, 2013 whats the new setVehicleInit - processInitCommands and how to use them to fix this codefound compilefinal no idea what it does }; // Set all the things common to the spawned unit _spawnUnit setDir _unitDir; _spawnUnit setSkill _unitSkill; _spawnUnit setUnitRank _unitRank; if (_spawntype == "once" OR _spawntype == "repeated") then { _spawnUnit setVehicleVarName _unitName; if (vehiclevarname _spawnUnit != "") then { _spawnUnit setVehicleInit format["%1=this;",_unitName]; processInitCommands; }; }; } forEach _unitArray; } forEach _waypointsArray; // Setting the leaders init and the groups body removal time (vehicle (leader _newGroup)) setVehicleInit _initString; processInitCommands; // Run the cleanup function for this group [_newGroup, _bodyRemove] spawn _fnc_cleanGroup; // Have to return the new group _newGroup; }; Thanks so um ... what is ur fix the the original code? Share this post Link to post Share on other sites
hellstorm77 2 Posted July 8, 2013 i would like to know this too :) Share this post Link to post Share on other sites
giallustio 770 Posted July 8, 2013 Using PV as he wrote Share this post Link to post Share on other sites
kylania 568 Posted July 8, 2013 (edited) Think they are asking what's the best new method for getting _unitname to be the global variable name. }; // Set all the things common to the spawned unit _spawnUnit setDir _unitDir; _spawnUnit setSkill _unitSkill; _spawnUnit setUnitRank _unitRank; if (_spawntype == "once" OR _spawntype == "repeated") then { [color="#FF0000"] Call compile format [' %1 = _spawnUnit; publicVariable "%1";', _unitname]; [/color] }; } forEach _unitArray; There's how to do it. :) Edited July 9, 2013 by kylania Remembered! Share this post Link to post Share on other sites
moricky 211 Posted July 9, 2013 [color="#FF0000"] Call compile format [' %1 = _spawnUnit; publicVariable "%1";', _unitname]; [/color] Using call compile is really expensive operation, I suggest to use the following code for assigning dynamic variables: missionNamespace setVariable [_unitName,_spawnUnit]; publicVariable _unitName; Share this post Link to post Share on other sites
Rough Knight 9 Posted July 9, 2013 I can't get Morickys method to set a units vehicleVarName. Also I should no better than to query Kylania...but isnt the code supposed to be as follows: Call compile format ["%1 = _spawnUnit; publicVariable '%1';", _unitname]; rather than Call compile format [' %1 = _spawnUnit; publicVariable "%1";', _unitname]; I am trying to spawn a dog and I used to have this code: _bitzer = _group createUnit ["Pastor", _cs1, [], 0, "FORM"]; _bitzer setVehicleInit "bitzer = this; this allowDamage false;"; sleep 0.1; processInitCommands; */ If anyone could shed some light on how I can set the dogs vehicleVarName to "Bitzer" I would be very appreciative? Thanks heaps Rough Knight Share this post Link to post Share on other sites
giallustio 770 Posted July 9, 2013 TAG_bitzer = _group createUnit ["Pastor", _cs1, [], 0, "FORM"];publicVariable "TAG_bitzer"; Share this post Link to post Share on other sites
kylania 568 Posted July 9, 2013 Also I should no better than to query Kylania...but isnt the code supposed to be as follows Either will work since the quotes (' vs ") are basically interchangeable when it comes to strings. Share this post Link to post Share on other sites
Ghost 40 Posted July 9, 2013 Using call compile is really expensive operation, I suggest to use the following code for assigning dynamic variables: missionNamespace setVariable [_unitName,_spawnUnit]; publicVariable _unitName; So would i Do something like this? Or is SetVehicleVarname not needed? _leader setVehicleVarName _VarName; missionNamespace setVariable [_VarName,_leader]; publicVariable _VarName; Share this post Link to post Share on other sites
kylania 568 Posted July 9, 2013 Trigger A onAct: 0 = ["bob", "B_Soldier_F"] execVM "mns.sqf"; Trigger B onAct: bob setDamage 1; mns.sqf: _name = _this select 0; _class = _this select 1; _unit = createvehicle [_class, position player, [], 0, "NONE"]; missionNameSpace setVariable [_name, _unit]; publicVariable _name; Run trigger A and Bob appears in all his glory. Run trigger B and poor Bob dies, even though object bob wasn't created anywhere till the script ran and never hard coded. Share this post Link to post Share on other sites
clydefrog 3 Posted July 9, 2013 (edited) Trigger A onAct: 0 = ["bob", "B_Soldier_F"] execVM "mns.sqf"; Trigger B onAct: bob setDamage 1; mns.sqf: _name = _this select 0; _class = _this select 1; _unit = createvehicle [_class, position player, [], 0, "NONE"]; missionNameSpace setVariable [_name, _unit]; publicVariable _name; Run trigger A and Bob appears in all his glory. Run trigger B and poor Bob dies, even though object bob wasn't created anywhere till the script ran and never hard coded. And how would you do that to name a group of spawned units rather than an individual unit? I am currently using the call compile format way to assign a group name to the group leader call compile format ["%1 = group _VehL;",_mygrpname]; but if there is a better way to do the same thing I'd rather do that. Also what is wrong with call compile format? By "expensive" I take it he means heavy on resources but surely not for just using it once or twice in a script? Edited July 9, 2013 by clydefrog Share this post Link to post Share on other sites
kylania 568 Posted July 9, 2013 Same way actually. :) _name = _this select 0; _class = _this select 1; _group = createGroup blufor; _unit = _class createUnit [position player, _group]; missionNameSpace setVariable [_name, _group]; publicVariable _name; Then [player] join bob; would join the player to that unit's group. Share this post Link to post Share on other sites
clydefrog 3 Posted July 9, 2013 (edited) Same way actually. :) _name = _this select 0; _class = _this select 1; _group = createGroup blufor; _unit = _class createUnit [position player, _group]; missionNameSpace setVariable [_name, _group]; publicVariable _name; Then [player] join bob; would join the player to that unit's group. Thanks. Edited July 9, 2013 by clydefrog Share this post Link to post Share on other sites
hellstorm77 2 Posted July 13, 2013 Im having the same problem not sure what to do if (_shout) then {_unit setVehicleInit "this say3d ""allahu""";processInitCommands}; Share this post Link to post Share on other sites
kylania 568 Posted July 14, 2013 You'd use a function and BIS_fnc_MP. init.sqf: TAG_fnc_mpSay = { (_this select 0) say [(_this select 1), (_this select 2)]; }; Then to use it: [[_unit, "allahu", 5], "TAG_fnc_mpSay"] spawn BIS_fnc_MP; Also you'd use say and not say3D since say3D is just to get 3D sound in cutscenes. say is 3D when a player is present already. Share this post Link to post Share on other sites