Jump to content
Sign in to follow this  
ChickenBandit

Scripts work for myself and for AIs, but not for other players

Recommended Posts

Hello everyone. I've been running into an issue with my missions where everything seems to work perfectly when I run it by myself or with AIs, but has major issues in multiplayer. As an example, look at my init.sqf:

if(isServer) then{{_x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; _x removeItemFromPrimaryWeapon "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight";} forEach allUnits};

AIs get their NVGs removed, but human players (other than myself) do not. If I stick those exact same commands into each squadmember's unit's init, it works even in multiplayer.

Another example is this script I have for completely stripping someone of gear, which I call using _nul = this execVM "stripAllGearWeaponsEtc.sqf"; in the unit's init:

removeAllAssignedItems _this;
removeAllAssignedItems _this;
removeVest _this;
removeUniform _this;
removeAllWeapons _this;
removeBackpack _this;

Once again this one works on myself and on AIs, but not on human players.

I'm pretty new to Arma scripting, is there just some fundamental aspect of how scripting works for multiplayer that I'm not aware of?

EDIT: Also, if anyone could point me to a basic guide on how variables and scope work in Arma scripting, that would be a huge help

Edited by ChickenBandit

Share this post


Link to post
Share on other sites

Welcome to ArmA's Locality. There is a useful (not overly in-depth) perspective on it HERE.

The server is not the sole-arbiter and many (most) commands will only work on a unit when run on the system that unit is 'local' to.

Your script also would not work on AI under the remote player's control because these too are local to that player's PC.

I'm a bit rusty on MP scripting but I expect your script would work if you got rid of the isServer so it runs on all clients and instead test for locality in the loop.

{
if (local _x) then {
	_x unassignItem "NVGoggles";
	_x removeItem "NVGoggles";
	_x removeItemFromPrimaryWeapon "acc_pointer_IR";
	_x addPrimaryWeaponItem "acc_flashlight";
};
} forEach allUnits;

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  

×