Jump to content

John Douglas

Member
  • Content Count

    1
  • Joined

  • Last visited

  1. Here's a solution I've been working on just this past week, after only having just discovered the AddAction command is broken! The toggle is based upon your assistance and code above. So thanks to "raymix" above for your persistence. I'm only 5 years late and god knows how many hours I've persisted this week. Easily close to 8+ hrs studying and learning code. Below I've now updated my post which demonstrates three versions of using "addAction" command to toggle your captive state. This includes _StringSelect != _toggle_NotEqualOn ; _StringSelect == _toggle_EqualOn ; Case with switch (_StringSelect) do {} , examples: Initialization code included for player, enjoy! /* ////////////////////////////////////////////////////////////////// // Function/Procedure Script file for ArmA2 // Title: toggle_NotEqual.sqf // by JohnDougls, based on raymix script, // https://epochmod.com/forum/topic/12901-addaction-without-external-script ////////////////////////////////////////////////////////////////// // SQF Script: toggle_NotEqual.sqf // // Edit Unit init: // displayAction_on = player addaction [format[("<t color=""#32CD32"">" + ("On %1") +"</t>"),""],"toggle_NotEqual.sqf","Off",6,true,true]; /////////////////////////////////////////////////////////////////// */ _StringSelect = (_this select 3); _toggle_NotEqualOn = "On"; /////////////////////////////////////// //1. Off! = On (true) //2. On! = On (false) /////////////////////////////////////// if (_StringSelect != _toggle_NotEqualOn) then { /////////////////////////////////////// // Off != On is true // Set AddAction "Off", having selected "displayAction_on" /////////////////////////////////////// displayAction_Off = player addaction [format[("<t color=""#FF7F50"">" + ("Off %1") +"</t>"),""],"toggle_NotEqual.sqf","On",6,true,true]; player setCaptive True; player removeAction displayAction_on; } else { /////////////////////////////////////// // On != On is false // Set AddAction "On", having selected "displayAction_Off" /////////////////////////////////////// displayAction_on = player addaction [format[("<t color=""#32CD32"">" + ("On %1") +"</t>"),""],"toggle_NotEqual.sqf","Off",6,true,true]; player setCaptive False; player removeAction displayAction_Off; }; _Variable1 = _StringSelect; _Variable2 = _StringSelect; _Variable3 = captive player; Sleep 1; hintSilent format ["displayAction: %1\n_StringSelect: %2\n_captive player: %3", _Variable1, _Variable2, _Variable3]; Sleep 5; /* ////////////////////////////////////////////////////////////////// // Function/Procedure Script file for ArmA2 // Title: toggle_Equal.sqf // by JohnDougls, based on raymix script, // https://epochmod.com/forum/topic/12901-addaction-without-external-script ////////////////////////////////////////////////////////////////// // SQF Script: toggle_Equal.sqf // // Edit Unit init: // displayAction_on = player addaction [format[("<t color=""#32CD32"">" + ("On %1") +"</t>"),""],"toggle_Equal.sqf","Off",6,true,true]; /////////////////////////////////////////////////////////////////// */ _StringSelect = (_this select 3); _toggle_EqualOn = "On"; /////////////////////////////////////// //1. On = On (true) //2. Off = On (false) /////////////////////////////////////// if (_StringSelect == _toggle_EqualOn) then { /////////////////////////////////////// // On = On is true // Set AddAction "On", having selected "displayAction_Off" /////////////////////////////////////// displayAction_on = player addaction [format[("<t color=""#32CD32"">" + ("On %1") +"</t>"),""],"toggle_Equal.sqf","Off",6,true,true]; player setCaptive False; player removeAction displayAction_Off; } else { /////////////////////////////////////// // Off = On is false // Set AddAction "Off", having selected "displayAction_on" /////////////////////////////////////// displayAction_Off = player addaction [format[("<t color=""#FF7F50"">" + ("Off %1") +"</t>"),""],"toggle_Equal.sqf","On",6,true,true]; player setCaptive True; player removeAction displayAction_on; }; _Variable1 = _StringSelect; _Variable2 = _StringSelect; _Variable3 = captive player; Sleep 1; hintSilent format ["displayAction: %1\n_StringSelect: %2\n_captive player: %3", _Variable1, _Variable2, _Variable3]; Sleep 5; /* ////////////////////////////////////////////////////////////////// // Function/Procedure Script file for ArmA2 // Title: toggle_Case.sqf // by JohnDougls, based on raymix script, // https://epochmod.com/forum/topic/12901-addaction-without-external-script ////////////////////////////////////////////////////////////////// // SQF Script: toggle_Case.sqf // // Edit Unit init: // displayAction_on = player addaction [format[("<t color=""#32CD32"">" + ("On %1") +"</t>"),""],"toggle_Case.sqf","Off",6,true,true]; /////////////////////////////////////////////////////////////////// */ _StringSelect = (_this select 3); /////////////////////////////////////// // case "On": // case "Off": // case "default": /////////////////////////////////////// switch (_StringSelect) do { case "On": { /////////////////////////////////////// // case "On": // Set AddAction "On", having selected "displayAction_Off" /////////////////////////////////////// displayAction_on = player addaction [format[("<t color=""#32CD32"">" + ("On %1") +"</t>"),""],"toggle_Equal.sqf","Off",6,true,true]; player setCaptive False; player removeAction displayAction_Off; }; case "Off": { /////////////////////////////////////// // case "Off": // Set AddAction "Off", having selected "displayAction_on" /////////////////////////////////////// displayAction_Off = player addaction [format[("<t color=""#FF7F50"">" + ("Off %1") +"</t>"),""],"toggle_Equal.sqf","On",6,true,true]; player setCaptive True; player removeAction displayAction_on; }; default { /////////////////////////////////////// // case "default": // - default block will be executed only if no case matches /////////////////////////////////////// hint "error!" }; }; _Variable1 = _StringSelect; _Variable2 = _StringSelect; _Variable3 = captive player; Sleep 1; hintSilent format ["displayAction: %1\n_StringSelect: %2\n_captive player: %3", _Variable1, _Variable2, _Variable3]; Sleep 5;
×
×
  • Create New...