Forum Jump :

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#181912 Posted at 2015-08-13 07:31        
     
Added items, uniforms and other stuffs. And populate only nearest house from players, with these equipments. It saves FPS a lot!
_odd1 = 40;
_odd2 = 30;
_odd3 = 20;
_weapons = [];
_items = [];
_cfgWpnarray = ("isclass _x" configclasses (configfile >> "cfgweapons"));
_types = [1,2,4,131072];
for "_i" from 0 to 3 do {
      {
        _class = _x;
        _className = configname _x;
        _scope = getnumber (_class >> "scope");
        _type = getnumber (_class >> "type");
        _mags = getArray (_class >> "magazines");
          if (_type == _types select _i) then {
        if (_scope == 2 && {gettext (_class >> "model") != ""}) then {
        call {
        if (_type == 131072) exitWith {_items pushback _className};
          _weapons pushback [_className,_mags];
        };
        }};
      } foreach _cfgWpnarray;
};

0 = [_odd1,_odd2,_odd3,_weapons,_items] spawn {
_odd1 = _this select 0;
_odd2 = _this select 1;
_odd3 = _this select 2;
_weapons = _this select 3;
_items = _this select 4;

_buildings = [];
_building_array = [];
while {true} do {
  {_building = nearestBuilding _x; _buildings pushback _building;
  _building_array = _buildings arrayintersect _buildings} forEach allPlayers;
  {
    _building = _x;
    if !(_building getVariable ["treated",false]) then {
      _num1 = random 100;
      if (_num1 < _odd1) then {
        _available_pos = [_building] call BIS_fnc_buildingPositions;
        if (count _available_pos !=0) then {
          for "_i" from 0 to (count _available_pos -1) do {
            _num2 = random 100;
            _num3 = random 100;
            if (_num2 < _odd2) then {
              _pos = _available_pos select _i;
              _random_loot_array = _weapons select (floor random (count _weapons));
              _random_loot_weapon = _random_loot_array select 0;
              _random_loot_mags = _random_loot_array select 1 select (floor random (count (_random_loot_array select 1)));
              _random_loot_item = _items select (floor random (count _items));
              _weaponholder = createVehicle ["groundWeaponHolder", _pos, [], 0, "CAN_COLLIDE"];
              _weaponholder addWeaponCargoGlobal [_random_loot_weapon, 1];
              if (count (_random_loot_array select 1) >0) then {_weaponholder addMagazineCargoGlobal [_random_loot_mags, 1+floor(random(4))]};
            };
            if (_num3 < _odd3) then {
              _pos = _available_pos select _i;
              _random_loot_item = _items select (floor random (count _items));
              _weaponholder = createVehicle ["groundWeaponHolder", _pos, [], 0, "CAN_COLLIDE"];
              _weaponholder addItemCargoGlobal [_random_loot_item,1];
            };
          };
        };
      };
      _building setVariable ["treated", true];
    };
  }foreach _building_array;
sleep 2;
};
};

This post was edited by Pierre MGI (2015-08-13 07:51, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS