cervantes 330 Posted April 7, 2011 hi here :) i have any problem when i want make my infection script for a farmland zombie mod. a script is launched by: INFECTED =compile preprocessFileLineNumbers "\antidote\infected.sqf"; [_target] call INFECTED; a infected script: _unit = _this select 0; if (_unit hasweapon "antidote") then { _inject = _unit addaction ["Inject Antidote", "\Antidote\Antidote.sqs"]; } else { _unit removeaction _inject; hint "removed"; }; if ((_unit getvariable "ANTIDOTE") and !(_unit getvariable "INFECTED")) exitwith { _unit removeaction _inject; _unit setVariable ["ANTIDOTE",false]; hint "exit"; }; a script working but removeaction conditions not working and action has d'ont removed. i d'ont see my hints executed when conditions are executed any idea for fix this? Share this post Link to post Share on other sites
blakeace 11 Posted April 10, 2011 Ok I won't pretend to be in any way knowledgable about action menus. The only think I could think of though is looking at the scope of _inject From the example you have given it is first defined within the if control structure, which probably means it is still undefined outside of that, unless there is more code before this in which it is defined. You could try adding private ["_inject"]; at the start of your script, that will make the scope of the local variable defined throughout this script. Have a look at the below link at the scope section. http://community.bistudio.com/wiki/Variables Hope that helps. If not that then :confused: Share this post Link to post Share on other sites
cervantes 330 Posted April 10, 2011 (edited) hi mate thx for your answer :) I managed to fix the problem when the script is read, check it once if (_unit hasweapon "antidote") or not and if ((_unit getVariable "ANTIDOTE") and! (_unit getVariable "INFECTED")) and exit . script is read by a single faith execution loop that check if the weapon is in inventory and if the 2 variables are true or false and therefore necesite a loop on the execution of script. I opted for a script in SQS. _unit = _this select 0; #main ?(_unit hasweapon "antidote"):_inject=_unit addaction ["Inject Antidote", "\Antidote\Antidote.sqs"];_unit setvariable ["INJECT",true]; #check ?(_unit hasweapon "antidote") and !(_unit getvariable "INJECT"):goto "main" ?!(_unit hasweapon "antidote"):_unit removeaction _inject;_unit setvariable ["INJECT",false]; ?(_unit getvariable "ANTIDOTE") and !(_unit getvariable "INFECTED"):_unit removeaction _inject;exit goto "check" check this script loop conditions and the desired action is enabled or disabled in real time. problem solved thx ;) Edited April 10, 2011 by CERVANTES Share this post Link to post Share on other sites