Jump to content
Sign in to follow this  
ChickenBandit

Question on how to self reference AI in a script that runs in their init

Recommended Posts

So based on some things I saw in another thread I made a quick script that strips all of the gear off of a unit. It goes like this:

removeAllAssignedItems player;
removeAllAssignedItems player;
removeVest player;
removeUniform player;
removeAllWeapons player;
removeBackpack player;

I put it in the init of my character with this:

nul = [this] execVM "NakedTime.sqf";

It worked, but when I tried to put it in the init of my AI squadmates it failed, I'm assuming because the "player" object does not work for AIs. The problem is, replacing "player" with "this" does not work, and it also makes it even stop working on my character. Is there any way to get this script to work universally on any unit whose init I call it from?

Thanks in advance!

Share this post


Link to post
Share on other sites

either call it with:

_nul = this execVM "NakedTime.sqf";

and replace your "player" lines with "_this", or leave your call as-is, and replace your player lines with "(_this select 0)" <though, in that case, it might help at the top to say something like _u = _this select 0; and then just replace instances of "player" with "_u".

[Also, note that i changed "nul" to "_nul", as you want the variable to be discarded and without the _ it becomes a global variable and is kept, but the _ makes it private, and it is immediately discarded since it has no scope in which to exist.]

Share this post


Link to post
Share on other sites
either call it with:

_nul = this execVM "NakedTime.sqf";

and replace your "player" lines with "_this", or leave your call as-is, and replace your player lines with "(_this select 0)" <though, in that case, it might help at the top to say something like _u = _this select 0; and then just replace instances of "player" with "_u".

[Also, note that i changed "nul" to "_nul", as you want the variable to be discarded and without the _ it becomes a global variable and is kept, but the _ makes it private, and it is immediately discarded since it has no scope in which to exist.]

It works! Thank you!

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  

×