Freddan962 1 Posted March 22, 2014 clearWeaponCargoGlobal this; ClearMagazineCargoGlobal this; Trying to call it in a seperate sqf file. Gives me this error: Error undefined variable in expression: this Share this post Link to post Share on other sites
ProfTournesol 956 Posted March 22, 2014 "This" is undefined, unless you put it in an eventhandler or init line of a unit. replace "this" by the name of the unit, for example. https://community.bistudio.com/wiki/this Share this post Link to post Share on other sites
saetheer 9 Posted March 22, 2014 In the .sqf you can do something aligned with this: _something = createVehicle ["#Ammobox#", getmarkerpos "markername", [], 0, "NONE"]; clearWeaponCargoGlobal _something; edit #Ammobox# with the actual classname Share this post Link to post Share on other sites
Freddan962 1 Posted March 22, 2014 So lets say I have 100 ammo boxes, do I need 100 different names for each one of those to execute this script? Share this post Link to post Share on other sites
ProfTournesol 956 Posted March 22, 2014 Nope. You can pass an argument into the script : if you write : null = [this] execVM "whatever.sqf"; in the init line of the unit, then into the sqf you'll write : _unit = _this select 0; clearWeaponCargoGlobal _unit; Share this post Link to post Share on other sites
Freddan962 1 Posted March 22, 2014 Nope. You can pass an argument into the script :if you write : null = [this] execVM "whatever.sqf"; in the init line of the unit, then into the sqf you'll write : _unit = _this select 0; clearWeaponCargoGlobal _unit; Thank you a lot! :) Share this post Link to post Share on other sites