Home   Help Search Login Register  

Author Topic: Synchronized random weapons at mission start  (Read 3531 times)

0 Members and 1 Guest are viewing this topic.

Offline Clayborne

  • Members
  • *
Synchronized random weapons at mission start
« on: 26 Nov 2012, 23:54:25 »
Hi guys,

I have made a co-op mission at the start of which I would like the players have randomly-selected weapons. I know how to accomplish this but I haven't yet been able to overcome the locality issues.

Originally I had the server call a random weapon function for each player, but that did nothing for the clients and they just kept their original loadouts. I have now moved the random weapon code to a script that is run on all machines. I'm currently not in a position to test this in multiplayer, so could someone take a look and tell me if you think this will work in MP? Here is the basic idea:


Code: [Select]
if (!isNil "Player1" && local Player1) then {

        _player = Player1;

if (someVariableCheck) then {
        removeallweapons _player;
                _weapons = ["AK_47_S", "AK_47_M", "huntingrifle"];
                _mags = ["30Rnd_762x39_AK47", "30Rnd_762x39_AK47", "5x_22_LR_17_HMR" ];
                _rnd = floor random (count _weapons);
                _weapon = _weapons select _rnd;
                _mag = _mags select _rnd;
                _player addmagazine _mag;
                _player addWeapon _weapon;
                _player selectweapon _weapon;

};

};

This block is repeated for each of the three playable units. So in MP I am guessing it will work fine for each individual player, but will other players see the changes? How can I make sure that the effects of the script are global, i.e. a player has an AKM and one mag and everyone else sees it too?