Advertisement
Guest User

POC Attachements1

a guest
Jul 8th, 2010
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. private ["_unit", "_attachement", "_actualWeapon", "_evolvingTo", "_type", "_muzzles"];
  2. if ((_this select 0) != (_this select 1)) exitwith {hintsilent "Nice try, dumbass ;)"};
  3. _unit = _this select 0;
  4. _attachement = _this select 3;
  5. _actualWeapon = primaryWeapon _unit;
  6. if (!(_attachement in (weapons _unit))) exitwith {hintsilent format ["You don't have %1 in your inventory", _attachement]};
  7. if (_attachement in (getArray (configFile >> "cfgWeapons" >> _actualWeapon >> "canUseItems"))) then {
  8.     _evolvingTo = getText (configFile >> "cfgWeapons" >> _actualWeapon >> "canAttach" >> _attachement >> "evolvesTo");
  9.     _unit removeWeapon _actualWeapon;
  10.     _unit removeWeapon _attachement;
  11.     _unit addWeapon _evolvingTo;
  12.    
  13.     if ((primaryWeapon _unit) != "") then {
  14.         _type = primaryWeapon _unit;
  15.         _muzzles = getArray(configFile >> "cfgWeapons" >> _type >> "muzzles");
  16.         if (count _muzzles > 1) then {
  17.             _unit selectWeapon (_muzzles select 0);
  18.         } else {
  19.             _unit selectWeapon _type;
  20.         };
  21.     };
  22. } else {
  23.     hintsilent format ["You can't use %1 on your %2", _attachement, _actualWeapon];
  24. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement