3lockad3 11 Posted August 8, 2014 As the title suggests, I am trying to access the init from a created object from an sqf.. My example example of the object and position. //f-18_1 _pos = [14228.0078125,16305.0800781,0.00465202]; _object = createVehicle ["JS_JC_FA18E", _pos, [], 0, "CAN_COLLIDE"]; _object = _this select 0; _object setDir 144.741; _object setPosATL _pos; Now I would like to add a re-spawn via external script,, Iceman77's advance vehicle re-spawn to be more exact.. _nul = [this, 2, 1, {}] execVM "vehrespawn.sqf"; But I'm at a loss for a solution at this point, as the code normally implemented in the argument, seems to have changed in the last while. setVehicleInit processInitCommands clearVehicleInit So,, that is my question. I would like to access the command remote.. So that leads me to. call BIS_fnc_MP; However, I'm unfamiliar with this method. I just want to access the init field of an object for re-spawn or simple commands to run my missions/projects.. Could someone help elaborate, as I'm sure others would like help with this as well... As you can see I clearly did some research, but I need help or a nudge in the right direction. Share this post Link to post Share on other sites
Larrow 2820 Posted August 8, 2014 Not sure i quite understand 'I would like to access the command remote..' . If you are using his version from Here. Then it does not use the old init commands. If you want some thing to be run on the vehicle every time it is respawned that is what the {} are for. e.g pos = [14228.0078125,16305.0800781,0.00465202]; _object = createVehicle ["JS_JC_FA18E", _pos, [], 0, "CAN_COLLIDE"]; _object = _this select 0; _object setDir 144.741; _object setPosATL _pos; _nul = [this, 2, 1, {_this setVehicleAmmo 0.8;}] execVM "vehrespawn.sqf"; . Header of vehrespawn.sqf Author: Iceman77 Description: Respawn destroyed and abandoned vehicles Parameter(s): _this select 0: vehicle _this select 1: abandoned delay in minute(s) - Required _this select 2: destroyed delay in minute(s) - Required _this select 3: Function to call for the newly spawned vehicle (for custom armaments etc) - Optional How to use - Vehicle Init Line: _nul = [this, 2, 1, {[_this] call TAG_FNC_TankInit}] execVM "vehRespawn.sqf"; << 2 minute abandoned delay, 1 minute destroyed delay, call the function that disables the TI _nul = [this, 2, 1, {}] execVM "vehrespawn.sqf"; << 2 minute abandoned delay, 1 minute destroyed delay, NO function called for the newly respawned vehicle (standard way) ---------------------------------------------------------------------------------------------------- */ Share this post Link to post Share on other sites
Beerkan 71 Posted August 8, 2014 Doh! answer posted by Larrow. Share this post Link to post Share on other sites
3lockad3 11 Posted August 8, 2014 (edited) Not sure i quite understand 'I would like to access the command remote..' . If you are using his version from Here. Then it does not use the old init commands.If you want some thing to be run on the vehicle every time it is respawned that is what the {} are for. e.g pos = [14228.0078125,16305.0800781,0.00465202]; _object = createVehicle ["JS_JC_FA18E", _pos, [], 0, "CAN_COLLIDE"]; _object = _this select 0; _object setDir 144.741; _object setPosATL _pos; _nul = [this, 2, 1, {_this setVehicleAmmo 0.8;}] execVM "vehrespawn.sqf"; . Header of vehrespawn.sqf Author: Iceman77 Description: Respawn destroyed and abandoned vehicles Parameter(s): _this select 0: vehicle _this select 1: abandoned delay in minute(s) - Required _this select 2: destroyed delay in minute(s) - Required _this select 3: Function to call for the newly spawned vehicle (for custom armaments etc) - Optional How to use - Vehicle Init Line: _nul = [this, 2, 1, {[_this] call TAG_FNC_TankInit}] execVM "vehRespawn.sqf"; << 2 minute abandoned delay, 1 minute destroyed delay, call the function that disables the TI _nul = [this, 2, 1, {}] execVM "vehrespawn.sqf"; << 2 minute abandoned delay, 1 minute destroyed delay, NO function called for the newly respawned vehicle (standard way) ---------------------------------------------------------------------------------------------------- */ No,, I know how to run Iceman's script to the T... What I'm asking is, when I create a vehicle through an external sqf, his code doesn't work in the sqf.. There is nothing in the editor, the position and class are defined in the sqf that I posted. However, I do not know how to activate scripts through the sqf,, all generic syntax work,, at least that I can tell. But, _nul = [this, 2, 1, {}] execVM "vehrespawn.sqf"; //this// refers to the object, so how do I define //this// as the object so that it works in the sqf ? Another problem is that because of security issues in MP BIS devs decided to pull these 3 commands out. setVehicleInit processInitCommands clearVehicleInit So now I can't utilize the init of the object directly from the sqf. Which means I can't tie re-spawn scripts,, or others for that matter until I can ether name or somehow get into the init. Does this make sense ? I'm not sure if I'm saying this right. Keep in mind I have tried to just replace the titles as well.. Maybe a bis function ? I have a feeling I'm going to have to learn something new :D Edited August 8, 2014 by 3lockad3 Share this post Link to post Share on other sites
Larrow 2820 Posted August 9, 2014 Sorry i forgot to change the this reference in the code i posted. Should of been _object instead... //create your vehicle pos = [14228.0078125,16305.0800781,0.00465202]; _object = createVehicle ["JS_JC_FA18E", _pos, [], 0, "CAN_COLLIDE"]; _object = _this select 0; _object setDir 144.741; _object setPosATL _pos; //Do something to the vehicle (similar to code being in the init box in the editor) _object setVehicleAmmo 0.8; //Start the respawn script, also passing it code to perform on init, like above _nul = [_object, 2, 1, {_this setVehicleAmmo 0.8;}] execVM "vehrespawn.sqf"; Then when inside Iceman's vehicle script the code section {_this setVehicleAmmo 0.8;} _this refers to _object as it gets called like so .. as an example.. removing all the other code to show whats happening //the passed in vehicle (_object) _veh = _this select 0; //the type of vehicle _vehtype = typeOf _veh; //the vehicle variable name as given in the editor name box (possibly does not matter for your example? see below) _vehName = vehicleVarName _veh; //respawning code (the init code) _vehInit = _this select 3; //The vehciles initial position _pos = getPosATL _veh; //when the vehicle dies it is recreated _veh = createVehicle [_vehtype, _pos, [], 0, "CAN_COLLIDE"]; //Set the global variable to point to the new vehicle, //this is similar to filling in the name box in the editor, although the editor will also do setVehicleVarName <- see WIKI //again your vehicle does not have a varname as it is created in script (possible problem if it does not have one??) missionNamespace setVariable [_vehName, _veh]; //Make sure the Global variable is the same on all computers publicVariable _vehName; //this is were the code for respawning is transferred to the new object _veh call _vehInit; //this is were the code for respawning is transferred to the new object you can think of it as looking like this.... _object call {_this setVehicleAmmo 0.8;} It uses the code you passed to vehrespawn as an inline function passing the newly created vehicle, hence _this being the vehicle. And just to cover all possible problems (read as can not be arsed to start up the editor and check) //again your vehicle does not have a varname as it is created in script (possible problem if it does not have one??) may need attention! Not sure if this may cause you problems but i believe doing varname and missionnamespace on a blank string "" just gets ignored. If the first bit of code still does not work try this instead.. _pos = [14228.0078125,16305.0800781,0.00465202]; _object = createVehicle ["JS_JC_FA18E", _pos, [], 0, "CAN_COLLIDE"]; _object = _this select 0; _object setDir 144.741; _object setPosATL _pos; //Give the created vehicle a varname _varName = "MyRespawningVehicle"; _object setVehicleVarName _varName; missionNamespace setVariable [_varName, _object]; publicVariable _varName; _object setVehicleAmmo 0.8; _nul = [_object, 2, 1, {_this setVehicleAmmo 0.8;}] execVM "vehrespawn.sqf"; Since the removal of the init commands there is no easy way of getting what was originally in the init statement. Although if your spawning your vehicle from script it would have nothing there anyway. The {} in the call to vehRespawn.sqf is what should be thought of as each new vehicles init line you just have to remember to use _this instead of this. Also Icemans script does not take into account applying the code {} to the initial vehicle, so you would need to handle that yourself aswell, like i have tried to show with the //Do something to the vehicle (similar to code being in the init box in the editor) line. Share this post Link to post Share on other sites
3lockad3 11 Posted August 10, 2014 Sorry i forgot to change the this reference in the code i posted. Should of been _object instead... //create your vehicle pos = [14228.0078125,16305.0800781,0.00465202]; _object = createVehicle ["JS_JC_FA18E", _pos, [], 0, "CAN_COLLIDE"]; _object = _this select 0; _object setDir 144.741; _object setPosATL _pos; //Do something to the vehicle (similar to code being in the init box in the editor) _object setVehicleAmmo 0.8; //Start the respawn script, also passing it code to perform on init, like above _nul = [_object, 2, 1, {_this setVehicleAmmo 0.8;}] execVM "vehrespawn.sqf"; Then when inside Iceman's vehicle script the code section {_this setVehicleAmmo 0.8;} _this refers to _object as it gets called like so .. as an example.. removing all the other code to show whats happening //the passed in vehicle (_object) _veh = _this select 0; //the type of vehicle _vehtype = typeOf _veh; //the vehicle variable name as given in the editor name box (possibly does not matter for your example? see below) _vehName = vehicleVarName _veh; //respawning code (the init code) _vehInit = _this select 3; //The vehciles initial position _pos = getPosATL _veh; //when the vehicle dies it is recreated _veh = createVehicle [_vehtype, _pos, [], 0, "CAN_COLLIDE"]; //Set the global variable to point to the new vehicle, //this is similar to filling in the name box in the editor, although the editor will also do setVehicleVarName <- see WIKI //again your vehicle does not have a varname as it is created in script (possible problem if it does not have one??) missionNamespace setVariable [_vehName, _veh]; //Make sure the Global variable is the same on all computers publicVariable _vehName; //this is were the code for respawning is transferred to the new object _veh call _vehInit; //this is were the code for respawning is transferred to the new object you can think of it as looking like this.... _object call {_this setVehicleAmmo 0.8;} It uses the code you passed to vehrespawn as an inline function passing the newly created vehicle, hence _this being the vehicle. And just to cover all possible problems (read as can not be arsed to start up the editor and check) //again your vehicle does not have a varname as it is created in script (possible problem if it does not have one??) may need attention! Not sure if this may cause you problems but i believe doing varname and missionnamespace on a blank string "" just gets ignored. If the first bit of code still does not work try this instead.. _pos = [14228.0078125,16305.0800781,0.00465202]; _object = createVehicle ["JS_JC_FA18E", _pos, [], 0, "CAN_COLLIDE"]; _object = _this select 0; _object setDir 144.741; _object setPosATL _pos; //Give the created vehicle a varname _varName = "MyRespawningVehicle"; _object setVehicleVarName _varName; missionNamespace setVariable [_varName, _object]; publicVariable _varName; _object setVehicleAmmo 0.8; _nul = [_object, 2, 1, {_this setVehicleAmmo 0.8;}] execVM "vehrespawn.sqf"; Since the removal of the init commands there is no easy way of getting what was originally in the init statement. Although if your spawning your vehicle from script it would have nothing there anyway. The {} in the call to vehRespawn.sqf is what should be thought of as each new vehicles init line you just have to remember to use _this instead of this. Also Icemans script does not take into account applying the code {} to the initial vehicle, so you would need to handle that yourself aswell, like i have tried to show with the //Do something to the vehicle (similar to code being in the init box in the editor) line. Thank you! I will try this out in the morning. Share this post Link to post Share on other sites
3lockad3 11 Posted August 10, 2014 Thank you!! It works great! I was trying to use the setName command. I learned a few things here as well. Thank you a million Larrow! Share this post Link to post Share on other sites