Burbonizer 0 Posted September 28, 2018 Hi Guys, I am running a hearts and minds server with some friends and I need some help with a little bit of code. I have placed this code on the init of some vehicles and all works fine. this addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; this addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]; When the vehicle gets destroyed however and respawns back at base, these options are no longer available on the vehicle. How do I make them respawn with the vehicle. I know it is some server side script of some sort but I am not sure how to write it. Thanks Share this post Link to post Share on other sites
pierremgi 4905 Posted September 28, 2018 You need to rewrite this code in the expression field of the respawn vehicle module, in this way: (_this select 0) addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; this addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]; 1 Share this post Link to post Share on other sites
Burbonizer 0 Posted September 28, 2018 8 minutes ago, pierremgi said: You need to rewrite this code in the expression field of the respawn vehicle module, in this way: (_this select 0) addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; this addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]; Ok tried that on the respawn module and it still didn't work. I am running out of ideas here. Share this post Link to post Share on other sites
Harzach 2518 Posted September 28, 2018 23 minutes ago, pierremgi said: You need to rewrite this code in the expression field of the respawn vehicle module, in this way: (_this select 0) addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; this addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]; No, just use the original code. Has always worked for me, and worked just now. In vehicle respawn expression field: this addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; this addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]; 1 Share this post Link to post Share on other sites
pierremgi 4905 Posted September 28, 2018 Try to spawn the code: (_this select 0) spawn { _this addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; _this addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]}; If no more result: second script. You need to wait a few seconds before destroying a vehicle with some addAction in its init field. In my script, use some explosive for test instead of setDamage 1 (to trigger EH damage) Share this post Link to post Share on other sites
Harzach 2518 Posted September 28, 2018 OK, so I just tested again, and now it doesn't work. I swear on my father's grave that it did just a few minutes ago. Share this post Link to post Share on other sites
Burbonizer 0 Posted September 28, 2018 4 minutes ago, Harzach said: OK, so I just tested again, and now it doesn't work. I swear on my father's grave that it did just a few minutes ago. lol Its been annoying for me too. Share this post Link to post Share on other sites
Harzach 2518 Posted September 28, 2018 This has never not worked for me until now, and now that I look at it, it never should have worked in the first place. And it definitely worked when I tested OP's code. My world has been turned upside-down! Pierre's original code does work, though he forgot to switch the this in the second expression to (_this select 0). (_this select 0) addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; (_this select 0) addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]; Share this post Link to post Share on other sites
Burbonizer 0 Posted September 28, 2018 1 hour ago, Harzach said: This has never not worked for me until now, and now that I look at it, it never should have worked in the first place. And it definitely worked when I tested OP's code. My world has been turned upside-down! Pierre's original code does work, though he forgot to switch the this in the second expression to (_this select 0). (_this select 0) addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; (_this select 0) addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]; Ok it does work, just takes a while after the vehicle has respawned for the add action items to appear in the menu. But.....now when I use the teleport option on my flagpole to teleport back to the medivac it puts me in the corner of the map. Its doesn't do this if the vehicle has never been destroyed and had to respawn. Here is my teleport script, can you see anything wrong with it? //this addAction ["Teleport -destinationName","teleport.sqf",[objectName]]; // Get the destination. _dest = (_this select 3) select 0; // Get a random direction _dir = random 359; // Move the person a few meters away from the destination (in the direction of _dir) player SetPos [(getPos _dest select 0)-10*sin(_dir),(getPos _dest select 1)-10*cos(_dir)]; Share this post Link to post Share on other sites
pierremgi 4905 Posted September 29, 2018 destinationName? objectName? Share this post Link to post Share on other sites
Harzach 2518 Posted September 29, 2018 Yeah, vehicle variable name hardcoded? A more dynamic solution is needed here. Share this post Link to post Share on other sites
Harzach 2518 Posted September 29, 2018 @davidoss and @Larrow providing a nice solution here: Share this post Link to post Share on other sites
Burbonizer 0 Posted September 29, 2018 ok so the code on the pole is (pole name is btc_gear_object) this addAction ["Teleport to Medivac Vehicle","teleport.sqf",[btc_veh_38]]; the code on the medivac respawn module is (medivac vehicle is btc_veh_38) (_this select 0) addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; (_this select 0) addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]; Teleport script called in above code: //this addAction ["Teleport -destinationName","teleport.sqf",[objectName]]; // Get the destination. _dest = (_this select 3) select 0; // Get a random direction _dir = random 359; // Move the person a few meters away from the destination (in the direction of _dir) player SetPos [(getPos _dest select 0)-10*sin(_dir),(getPos _dest select 1)-10*cos(_dir)]; neither seem to work after the vehicle respawns but works fine when the server is first started. Share this post Link to post Share on other sites
zagor64bz 1225 Posted September 29, 2018 12 hours ago, pierremgi said: You need to rewrite this code in the expression field of the respawn vehicle module, in this way: (_this select 0) addAction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; this addAction ["Teleport to Main Area","teleport.sqf",[btc_gear_object]]; works for me.....in SP anyway.... Share this post Link to post Share on other sites
Burbonizer 0 Posted September 29, 2018 ok so I have managed to get everything working now trying a different way of teleport. But now I have another issue. I am trying to add the addaction to the vehicle and only a specific range of vehicles. Can some one point out what I am missing with this code as it just errors. I know it is a syntax issue but I am not sure where. if (type of vehicle == ["rhsusf_m113d_usarmy_medical", "RHS_CH_47F_10", "RHS_UH60M_MEV2_d"]) then { vehicle addaction ["Teleport to Main Area","teleportbase.sqf", "telepoint"]; vehicle addaction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; }; Share this post Link to post Share on other sites
davidoss 552 Posted September 29, 2018 params [["_newVeh",objNull,[objNull]],["_oldVeh",objNull,[objNull]]]; if (typeOf _newVeh in ["rhsusf_m113d_usarmy_medical", "RHS_CH_47F_10", "RHS_UH60M_MEV2_d"]) then { _newVeh addaction ["Teleport to Main Area","teleportbase.sqf", "telepoint"]; _newVeh addaction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; }; 2 Share this post Link to post Share on other sites
pierremgi 4905 Posted September 29, 2018 Furthermore, vehicle is a command by itself. Never user vehicle (or other command) as your own variable. 1 Share this post Link to post Share on other sites
Burbonizer 0 Posted September 30, 2018 Thanks davidoss, unfortunately the add action is still not showing in the menu. So I have this in the init of the vehicles that I want the add action to appear on: this = execVM "vehiclerespawn.sqf"; then in the vehiclerespawn.sqf I now have: while {true} do { sleep 1; { if ((typeOf _x) in ["rhsusf_m113d_usarmy_medical", "RHS_CH_47F_10", "RHS_UH60M_MEV2_d"]) then { if (!(_x getVariable ["isSetup", false])) then { _x setVariable ["isSetup", true]; //here's where you put your code: _x addaction ["Teleport to Main Area","teleportbase.sqf", "telepoint"]; _x addaction ["<t color='#ff1111'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal}]; }; }; } forEach vehicles; }; This works but still when the vehicle is destroyed and respawns the addactions are gone. I thought this would of worked considering I am not trying to get the name given but rather the vehicle type. Still nothing though. It is though it is only running when the mission starts. Am I not putting things in the rights places? Share this post Link to post Share on other sites
davidoss 552 Posted September 30, 2018 sorry i do not understand what you are doing with. If its goes about to set addaction on vehicle after respawn using vehicle respawn module in MP i would do this like this if (isServer) then { params [["_newVeh",objNull,[objNull]],["_oldVeh",objNull,[objNull]]]; if (typeOf _newVeh in ["rhsusf_m113d_usarmy_medical", "RHS_CH_47F_10", "RHS_UH60M_MEV2_d"]) then { 0 = [_newVeh, [ "<t color='#0B610B'>Teleport to Main Area</t> <img size='2' image='\a3\ui_f\data\IGUI\Cfg\HoldActions\holdAction_unbind_ca'/>", "teleportbase.sqf", "telepoint", 1.5, false, true, "", "true", 5, false, "", "" ] ] remoteExec ["addAction", [0,-2] select isDedicated,_newVeh]; 0 = ["AmmoboxInit",[_newVeh,true,{(_target distance _this) < 5}]] remoteExec ["BIS_fnc_arsenal", [0,-2] select isDedicated,_newVeh]; }; }; Share this post Link to post Share on other sites
Burbonizer 0 Posted September 30, 2018 Thanks davidoss but still when the vehicle respawns the menu action is not there. I have created a little test here. If you can take a look and see if you can get it to work. The campfire will teleport you to the quad and the quad back to the campfire. Destroy the quad and the addaction menu goes from the quad. I have tried everything now and I cannot get this working. https://drive.google.com/open?id=1CfloiuV1bpSpXDgY0w4cuyFUSScpOsZg Share this post Link to post Share on other sites
Burbonizer 0 Posted September 30, 2018 Ok guys thank you so much for you help but I have finally cracked it. Seems I was putting the code that I needed in the init field. It works if you put it in the expression field of the vehicle. Thanks again for your help. Share this post Link to post Share on other sites
Burbonizer 0 Posted September 30, 2018 yeah I saw the expression field and thought hang on....read all of the above post and thought "oh dear, I have been a complete n00b" Sorry for wasting all your time going through it over and over again. I will learn from my mistakes (I hope) Share this post Link to post Share on other sites