HaggisRoll 1 Posted August 31, 2017 Hi. Wonder could someone maybe help me out with 2 things if there straight forward enough. I have a script that runs on mission start where an ammo box will spawn on 1 of 3 random markers. _spawnposition = selectRandom ["mkr1","mkr2","mkr3"]; //select a random spawnposition from 3 marker names _target = [getmarkerpos _spawnposition, 0, "Box_FIA_Wps_F", EAST] call bis_fnc_spawnvehicle; //spawn the object on the random position. _box = _target; The script seems to run fine, But i would like to make it have a variable name so when it gets destroyed, a trigger fires and a task is completed. Q1. How would i give it a variable name within the script. Q2. How could i make the ammo box move to random building pos that the marker is on. Cheers for any help in advance. Share this post Link to post Share on other sites
davidoss 552 Posted August 31, 2017 _spawnposition = selectRandom ["mkr1","mkr2","mkr3"]; //select a random spawnposition from 3 marker names _target = [getmarkerpos _spawnposition, 0, "Box_FIA_Wps_F", EAST] call bis_fnc_spawnvehicle; //spawn the object on the random position. mybox = _target select 0; publicVariable "mybox"; or if you want global vehicle name _spawnposition = selectRandom ["mkr1","mkr2","mkr3"]; //select a random spawnposition from 3 marker names _target = [getmarkerpos _spawnposition, 0, "Box_FIA_Wps_F", EAST] call bis_fnc_spawnvehicle; //spawn the object on the random position. _box = _target select 0; null = [_box, "mybox"] remoteExec ["setVehicleVarName", [0,-2] select isDedicated, _box]; 1 Share this post Link to post Share on other sites
pierremgi 4900 Posted August 31, 2017 Just refer to a global variable: box1 = _target select 0; If you spawn the crate in a remote (client) PC and your trigger is on server, so you'll need to publicVariable it. Add: publicVariable "box1"; // not needed if box1 and trigger are on server/ same PC 1 Share this post Link to post Share on other sites
davidoss 552 Posted August 31, 2017 private _spawnposition = selectRandom ["mkr1","mkr2","mkr3"]; //select a random spawnposition from 3 marker names private _target = [getmarkerpos _spawnposition, 0, "Box_FIA_Wps_F", EAST] call bis_fnc_spawnvehicle; //spawn the object on the random position. private _box = _target select 0; //select object from bis_fnc_spawnvehicle returned array mybox = _box; // create global variable for later usage for.ex with triggers publicVariable "mybox"; //public variable //function to find enterable buildings in area private _fnc_findbuildings = { // find enterable buildings in area // by DaVidoSS params ["_center","_radius"]; private ["_buildings", "_enterable"]; _buildings = nearestObjects [_center, ["house"], _radius]; _enterable = []; { if ([_x, 3] call BIS_fnc_isBuildingEnterable) then { //this both buildings are not enterable but pickedup by BIS_fnc_isBuildingEnterable if (typeof _x == "Land_HouseV2_03" || typeof _x == "Land_Nasypka") exitWith {}; _enterable pushback _x; }; } foreach _buildings; _enterable; }; private _houses = [getpos _box, 50] call _fnc_findbuildings; // call function with box position and radius for search buildings private _house = selectRandom _houses; //pickup one building from returned array private _nhouse_inpos = [_house] call BIS_fnc_buildingPositions; //find building inside positions private _random_inpos = floor (random (count _nhouse_inpos)); //select one building position _box allowDamage false; // set damage false to box // set box on selected building position _box setPos [ (_house buildingPos _random_inpos) select 0, (_house buildingPos _random_inpos) select 1, ((_house buildingPos _random_inpos) select 2) +0.6 ]; _box allowDamage true; // set box in hazard again Share this post Link to post Share on other sites
HaggisRoll 1 Posted August 31, 2017 34 minutes ago, davidoss said: _spawnposition = selectRandom ["mkr1","mkr2","mkr3"]; //select a random spawnposition from 3 marker names _target = [getmarkerpos _spawnposition, 0, "Box_FIA_Wps_F", EAST] call bis_fnc_spawnvehicle; //spawn the object on the random position. mybox = _target select 0; publicVariable "mybox"; or _spawnposition = selectRandom ["mkr1","mkr2","mkr3"]; //select a random spawnposition from 3 marker names _target = [getmarkerpos _spawnposition, 0, "Box_FIA_Wps_F", EAST] call bis_fnc_spawnvehicle; //spawn the object on the random position. _box = _target select 0; null = [_box, "mybox"] remoteExec ["setVehicleVarName", [0,-2] select isDedicated, _box]; Nice work. Works a treat. So i take it for testing purposes on my own pc, use the top one and if on dedicated server use the bottom one. What does the "Select 0" do? Share this post Link to post Share on other sites
davidoss 552 Posted August 31, 2017 Above you have already complete code for Q1 and Q2 with full description. MP/SP tested. Quote What does the "Select 0" do? array = [1,5,7,8] arayindex 0 1 2 3 select 0 = 1 select 1 = 5 select 2 = 7 select 9 = empty 1 Share this post Link to post Share on other sites
HaggisRoll 1 Posted September 1, 2017 The box spawn works perfectly now. I'll add the second one you gave me today and see how i get on. Thanks Again. Appreciate you taking the time to help. Share this post Link to post Share on other sites