Jump to content
Sign in to follow this  
Freddan962

Why don't this work? (gives a this undefined expression error)

Recommended Posts

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

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

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

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
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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×