Haymaker 13 Posted June 30, 2016 Okay so I've been working on a script for cooking drugs... yeah... Meth specifically actually. I'm becoming a little more skilled with scripting but I'm having trouble with one thing I can't quite wrap my head around. The script works mostly correctly, but when I try to stop the script from running in the else statement, I'm not having luck. I'm actually quite confused because it worked a few times, but then when I restarted my game it stopped working. I'm thinking I must have accidentally unsaved it or something. private ["_building","_stove","_chemicals","_chemicalsUsed","_meth","_smoke","_cooking"]; _building = nearestObject [player, "house"]; _stove = nearestObject [player,"CUP_Kitchenstove_Elec"]; _storage = nearestObject [_stove,"Box_NATO_AmmoVeh_F"]; _chemicals = nearestObject [_stove, "Land_MetalBarrel_F"]; _meth = "arifle_Mk20_F"; _cooking = _stove getVariable "_cooking"; //* _smoke = ""; if (_stove distance _building <= 8) then { if (_stove distance _chemicals <= 8) then { if (_cooking < 1) then { //* _smoke createVehicle (position _stove); Hint "Meth is cooking"; _stove setVariable ["_cooking", 1, true]; sleep 60; Hint "Meth has been cooked"; //* deletevehicle nearestObject [_stove, _smoke]; _storage addWeaponcargo [_meth,10]; deleteVehicle _chemicals; _stove setVariable ["_cooking", 0, true]; } else { Hint "Meth is already cooking!" }; } else { Hint "You need to have chemicals and a stove in a building to cook meth!" } }; What I'm confused about is setting up "_cooking" as boolean... I've tried a few methods. Also it's worthy to be noted that I have this in my init.sqf: _stove = nearestObject [player,"CUP_Kitchenstove_Elec"]; _stove setVariable ["_cooking", 0, true]; I don't plan on keeping this as my init.sqf I plan on moving it to an eventhandler init, where I will also give the stoves an addaction to execute this script. I'm pretty confused on how to set _cooking as a default 0 or false and then it would be changed accordingly during the script. Share this post Link to post Share on other sites
kylania 568 Posted June 30, 2016 You probably shouldn't call the variable "_cooking", since that's very easy to confuse with a local variable. You can also set it directly to true/false. /* this setVariable["hay_stoveCooking", false, true]; this addAction["Cook Meth","meth.sqf", [], 0, true, false, "", "(count nearestObjects [_target, ['House'], 8] > 0) && (count nearestObjects [_target, ['Land_MetalBarrel_F'], 8] > 0) && !(_target getVariable 'hay_stoveCooking')"]; */ params["_object", "_caller", "id", "_args"]; _args params[ ["_cooktime", 60], ["_batchsize", 10] ]; _storage = nearestObject [_object,"Box_NATO_AmmoVeh_F"]; _chemicals = nearestObject [_object, "Land_MetalBarrel_F"]; _meth = "arifle_Mk20_F"; _object setVariable ["hay_stoveCooking", true, true]; Hint "Meth is cooking"; sleep _cooktime; hint "Meth has been cooked"; _storage addWeaponcargo [_meth, _batchsize]; deleteVehicle _chemicals; _object setVariable ["hay_stoveCooking", false, true]; Share this post Link to post Share on other sites