onPlayerRespawn.sqf 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //onPlayerRespawn.sqf
  2. private ["_role", "_safeItems"];
  3. restricted = [];
  4. waitUntil { alive player };
  5. _role = player getVariable ["role", "none"];
  6. _safeItems = getArray (missionConfigFile >> "CfgRespawnInventory" >> _role >> "restrictions");
  7. restricted = (allItems - _safeItems);
  8. VAS_pre_weapons = VAS_pre_weapons_original - restricted;
  9. VAS_pre_magazines = VAS_pre_magazines_original - restricted;
  10. VAS_pre_items = VAS_pre_items_original - restricted;
  11. VAS_pre_backpacks = VAS_pre_backpacks_original - restricted;
  12. VAS_pre_glasses = VAS_pre_glasses_original - restricted;
  13. player addEventHandler
  14. [
  15. "Take",
  16. {
  17. private ["_obj", "_tmp"];
  18. _obj = _this select 2;
  19. if (_obj in restricted) then
  20. {
  21. _tmp = false;
  22. while { !_tmp } do
  23. {
  24. _tmp = true;
  25. if (_obj == primaryWeapon player || _obj == secondaryWeapon player) exitWith { player removeWeapon _obj; };
  26. if (_obj == backpack player) exitWith { removeBackpack player; };
  27. if (_obj == uniform player) exitWith { removeUniform player; };
  28. if (_obj == headgear player) exitWith { removeHeadgear player; };
  29. if (_obj in (items player)) exitWith { player removeItem _obj; };
  30. };
  31. hint parseText "<t color='#FF0000' size='2.2'>Restricted<br/>Item</t><br/>--------------------<br/>The class you have selected is not qualified to use that item.<br/><br/>Make sure to play your class!";
  32. };
  33. }
  34. ];