deltagamer 612 Posted February 6, 2015 Hey everyone, I've been having a problem with my script and I can't figure out where I'm going wrong so I was hoping someone here could help me out with it. There are 3 addactions that I'm trying to get for the gunner only. How the script works is the gunner selects the Turn In action and the weapon folds away and the soldier is moved to a 4th cargo position which is only for the gunner. The script is working fine however I'm only wanting to make the addactions for the gunner when turned out and for when he is turned in and is sitting at cargo index 3. Any help with this would be great as I can't figure out my problem. Init.sqf: _target = _this select 0; suv_close_action = _target addAction ["<t color='#FF0000'>Turn In</t>","DG_UKBAF\Vehicles\ArmoredSUV\script\TurnIn.sqf",[],1,false,true]; _target lockCargo [3, true]; TurnIn.sqf: _target = _this select 0; _caller = _this select 1; _id = _this select 2; _target removeAction _id; _target lockCargo [3, false]; (gunner _target) action ["moveToCargo", _target,3]; _target lockCargo [3, true]; _target lockturret [[0],true]; _target lockturret [[1],true]; _target lockturret [[2],true]; sleep 0.1; _target animate["HideGun_01",1]; sleep 0.1; _target animate["HideGun_02",1]; sleep 0.1; _target animate["HideGun_03",1]; sleep 0.1; _target animate["HideGun_04",1]; sleep 0.1; _target animate["CloseCover1",1]; sleep 0.2; _target animate["CloseCover2",1]; sleep 0.2; suv_open_action = _target addAction ["<t color='#FF0000'>Turn Out</t>","DG_UKBAF\Vehicles\ArmoredSUV\script\TurnOut.sqf",[],1,false,true, "_target in (gunner _target)"]; TurnOut.sqf: _target = _this select 0; _caller = _this select 1; _id = _this select 2; _target removeAction _id; _target animate["CloseCover2",0]; sleep 0.2; _target animate["CloseCover1",0]; sleep 0.2; _target animate["HideGun_04",0]; sleep 0.1; _target animate["HideGun_03",0]; sleep 0.1; _target animate["HideGun_02",0]; sleep 0.1; _target animate["HideGun_01",0]; sleep 0.1; _target lockturret [[0],false]; _target lockturret [[1],false]; _target lockturret [[2],false]; _target lockCargo [3, false]; player action ["moveToTurret", _target,[0]]; _target lockCargo [3, true]; sleep 0.1; suv_close_action = _target addAction ["<t color='#FF0000'>Turn In</t>","DG_UKBAF\Vehicles\ArmoredSUV\script\TurnIn.sqf",[],1,false,true, "_target in (gunner _target)"]; Share this post Link to post Share on other sites
jshock 512 Posted February 6, 2015 You could use get/set variable on the unit and add a condition check on that variable in the action code: _unit setVariable ["isTurnedOutOfVehicle",true]; //action condition _target getVariable ["isTurnedOutOfVehicle",false];//will default to "false" if the variable doesn't exist on the unit Share this post Link to post Share on other sites
deltagamer 612 Posted February 6, 2015 Thanks for the response but the problem is Car_F doesn't allow Turning in/out making your solution non usable. I've created the above script to compensate for my problem. I only need it to have the addaction for the gunner when turned out and then the cargo 3 index when turned in as that's what the position of the gunner moves to when turning in. This is what it looks like Share this post Link to post Share on other sites
jshock 512 Posted February 7, 2015 (edited) Well it attaches an object variable to the unit (I made the variable name up), so in each of your scripts you would set that variable as either true (meaning he is turned out) or false (meaning he is turned in), and the if you add the "_target getVariable ..." to the action condition for each of the actions (Turn In/Turn Out) it should only ever give you one of the actions (which should be opposite of the unit's current state, in or out). Basically with this method you wouldn't have to remove the actions, as the conditions would make the actions dynamic (in a sense). Edited February 7, 2015 by JShock Share this post Link to post Share on other sites
deltagamer 612 Posted February 7, 2015 Ok I think I get where your coming from, but wouldn't that mean that if I was to turn in and then exit the vehicle and then another player entered the gunner position they wouldn't get the action or would it still work for them? Share this post Link to post Share on other sites
jshock 512 Posted February 7, 2015 Depending on which object you assign the variable to (player or car) will decide that. I would recommend the car (for obvious reasons) so when any player gets into the gunner seat it will display the necessary action (in or out) depending on the state of the assigned variable on the car. So if your conditionals are setup properly the action on the vehicle should only show if the player is in the gunner seat and the turret is either already turned in (gives action to turn out) or is already turned out (gives action to turn in). But I would be sure when using setVariable to set the "public" parameter to true, so that all players are updated on the state of the vehicle turret so when someone leaves and someone else jumps in, it says the correct turret state. Share this post Link to post Share on other sites
deltagamer 612 Posted February 7, 2015 Thanks again for the response, I'm not too sure how I would implement that to my script though. I hope its not too much to ask for some help with it? I really wouldn't know where to start with implementing your advice with my script. Share this post Link to post Share on other sites
jshock 512 Posted February 7, 2015 Try this out: //init.sqf (using your setup) _target = _this select 0; suv_close_action = _target addAction [ "<t color='#FF0000'>Turn In</t>", "DG_UKBAF\Vehicles\ArmoredSUV\script\TurnIn.sqf", [], 1, false, true, "", "(gunner _this) isEqualTo player && {_this getVariable ["isTurnedOutOfVehicle",false]}" ]; suv_open_action = _target addAction [ "<t color='#FF0000'>Turn Out</t>", "DG_UKBAF\Vehicles\ArmoredSUV\script\TurnOut.sqf", [], 1, false, true, "", "(gunner _this) isEqualTo player && {!(_this getVariable ["isTurnedOutOfVehicle",false])}" ]; _target lockCargo [3, true]; _target setVariable ["isTurnedOutOfVehicle",false,true];//first option will be to turn out of vehicle, switch the false to true to do the opposite //TurnIn.sqf _target = _this select 0; _target lockCargo [3, false]; (gunner _target) action ["moveToCargo", _target,3]; _target lockCargo [3, true]; _target lockturret [[0],true]; _target lockturret [[1],true]; _target lockturret [[2],true]; sleep 0.1; _target animate["HideGun_01",1]; sleep 0.1; _target animate["HideGun_02",1]; sleep 0.1; _target animate["HideGun_03",1]; sleep 0.1; _target animate["HideGun_04",1]; sleep 0.1; _target animate["CloseCover1",1]; sleep 0.2; _target animate["CloseCover2",1]; _target setVariable ["isTurnedOutOfVehicle",false,true]; //TurnOut.sqf _target = _this select 0; _target animate["CloseCover2",0]; sleep 0.2; _target animate["CloseCover1",0]; sleep 0.2; _target animate["HideGun_04",0]; sleep 0.1; _target animate["HideGun_03",0]; sleep 0.1; _target animate["HideGun_02",0]; sleep 0.1; _target animate["HideGun_01",0]; sleep 0.1; _target lockturret [[0],false]; _target lockturret [[1],false]; _target lockturret [[2],false]; _target lockCargo [3, false]; player action ["moveToTurret", _target,[0]]; _target lockCargo [3, true]; _target setVariable ["isTurnedOutOfVehicle",true,true]; Share this post Link to post Share on other sites
deltagamer 612 Posted February 7, 2015 It doesn't seem to work, I think there is something missing in the script. Here's my error message. Any ideas why its not working? Share this post Link to post Share on other sites
jshock 512 Posted February 7, 2015 Derp, my fault, change the quotes around "isTurnedOutOfVehicle" from double quotes to single quotes (' ') in both of the action conditions. Share this post Link to post Share on other sites
deltagamer 612 Posted February 7, 2015 Right that's fixed my problem and the script seems to work fine however its still attaching the addaction to the vehicle and not the gunner seat. Any ideas why it's not just staying for the gunner position? Share this post Link to post Share on other sites
jshock 512 Posted February 7, 2015 Hmm, I think I may have mixed up my special var in the condition on the gunner position try: (gunner _target) isEqualTo player && {!(_this getVariable ["isTurnedOutOfVehicle",false])}//turn in condition (gunner _target) isEqualTo player && {!(_this getVariable ["isTurnedOutOfVehicle",true])}//turn out condition Share this post Link to post Share on other sites
deltagamer 612 Posted February 7, 2015 Ok its almost fully working now, all I need is for the turn out option to be for the cargo index 3 and not for the gunner since the gunner is moved to a cargo index when turning in. Is it possible to do this or would it be better for me to set up a second gunner proxy instead of using the cargo position and move the gunner to that slot possibly making the addaction visible when turned in as well. Share this post Link to post Share on other sites
jshock 512 Posted February 8, 2015 ((_target getCargoIndex _this) isEqualTo 3) && {!(_this getVariable ["isTurnedOutOfVehicle",false])}//turn in condition ((_target getCargoIndex _this) isEqualTo 3) && {!(_this getVariable ["isTurnedOutOfVehicle",true])}//turn out condition Share this post Link to post Share on other sites
deltagamer 612 Posted February 8, 2015 (edited) That's it working now. Thanks for taking the time to help me out mate :) Edited February 8, 2015 by deltagamer Share this post Link to post Share on other sites