SnowmaneYT 5 Posted March 16, 2022 Hello, I'm trying to get the side of AI using "side _this" but i'm only getting an error. On respawn i execVM a file with the expectations of get the side of the AI and then execVM another file depending on side. if (side _this == west) then {_this execVM "unitMoveWest.sqf"}; Why is not working? Thanks! Share this post Link to post Share on other sites
Harzach 2518 Posted March 16, 2022 How are you defining "_this"? Share this post Link to post Share on other sites
SnowmaneYT 5 Posted March 16, 2022 "_this" is supposed to be the current unit, i used to execVM and doMove, etc and works. How i can reffer to the unit AI then? Share this post Link to post Share on other sites
Harzach 2518 Posted March 16, 2022 15 minutes ago, SnowmaneYT said: "_this" is supposed to be But maybe it isn't. So, how are you defining it? Show your code, we can't see your screen from here. Share this post Link to post Share on other sites
SnowmaneYT 5 Posted March 16, 2022 init.sqf {_respawns = _x addMPEventHandler ["MPRespawn", { _moveLoop = _this execVM "unitMove.sqf"; }]; } foreach allUnits; unitMove.sqf (here is caused the "_this" error if (side _this == west) then {_this execVM "unitMoveWest.sqf"}; if (side _this == east) then {_this execVM "unitMoveEast.sqf"}; if (side _this == independent) then {_this execVM "unitMoveIndi.sqf"}; Share this post Link to post Share on other sites
Harzach 2518 Posted March 16, 2022 https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#MPRespawn Default: this addMPEventHandler ["MPRespawn", { params ["_unit", "_corpse"]; }]; We can see that when adding the EH, the new unit would be referred to as _this select 0 or _this#0, or by the built-in param _unit. So let's do! {_respawns = _x addMPEventHandler ["MPRespawn", { params ["_unit", "_corpse"]; _moveLoop = _unit execVM "unitMove.sqf"; }]; } foreach allUnits; Now unitMove.sqf should work, but it's always a good idea to define variables/params at the top: params ["_this"]; if (side _this == west) then {_this execVM "unitMoveWest.sqf"}; if (side _this == east) then {_this execVM "unitMoveEast.sqf"}; if (side _this == independent) then {_this execVM "unitMoveIndi.sqf"}; I would change "_this" to "_unit" for a bit more clarity, but that's personal preference. params ["_unit"]; if (side _unit == west) then {_units execVM "unitMoveWest.sqf"}; if (side _unit == east) then {_unit execVM "unitMoveEast.sqf"}; if (side _unit == independent) then {_unit execVM "unitMoveIndi.sqf"}; 2 1 Share this post Link to post Share on other sites
SnowmaneYT 5 Posted March 16, 2022 Wow, thanks so much 😀👌 Share this post Link to post Share on other sites