aeroson

Untitled

Jul 18th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. playerLoadTawLoadout = {
  2.  
  3. private _target = player;
  4.  
  5. private _virtualArsenalLoadouts = profilenamespace getvariable ["bis_fnc_saveInventory_data", nil];
  6.  
  7. if (!isNil {_virtualArsenalLoadouts}) then {
  8.  
  9. private _targetTypeName = toLower getText(configfile >> "cfgVehicles" >> typeof _target >> "DisplayName");
  10.  
  11. private _targetTags = ["taw", "wood"];
  12. _targetTags append (_targetTypeName splitString " ");
  13.  
  14. if(_targetTypeName == "squad leader") then {
  15. _targetTags append ["sl", "pl"];
  16. };
  17. if(_targetTypeName == "team leader") then {
  18. _targetTags append ["fl"];
  19. };
  20. if(_targetTypeName == "combat life saver") then {
  21. _targetTags append ["medic"];
  22. };
  23. if(_targetTypeName == "marksman") then {
  24. _targetTags append ["sniper"];
  25. };
  26. if(_targetTypeName == "engineer") then {
  27. _targetTags append ["repair"];
  28. };
  29.  
  30.  
  31. systemChat format["Looking for loadout with tags: %1", _targetTags];
  32.  
  33. private _foundLoadoutName = "";
  34. private _foundLoadoutTagsMatched = 0;
  35.  
  36. for "_i" from 0 to (count _virtualArsenalLoadouts) - 1 step 2 do {
  37.  
  38. private _loadoutName = _virtualArsenalLoadouts select _i;
  39. private _loadoutNameParts = _loadoutName splitString "-.,=/ ";
  40. private _tagsMatched = 0;
  41.  
  42. {
  43. if((toLower _x) in _targetTags) then {
  44. _tagsMatched = _tagsMatched + 1;
  45. };
  46. } forEach _loadoutNameParts;
  47.  
  48. if(_tagsMatched > _foundLoadoutTagsMatched) then {
  49. _foundLoadoutTagsMatched = _tagsMatched;
  50. _foundLoadoutName = _loadoutName;
  51. };
  52.  
  53. systemChat format["loadout '%1' matches %2 tags", _loadoutName, _tagsMatched];
  54.  
  55. };
  56.  
  57. if(_foundLoadoutName != "") then {
  58. systemChat format["Found loadout '%1' matches %2 tags", _foundLoadoutName, _foundLoadoutTagsMatched];
  59. [player, [profilenamespace, _foundLoadoutName]] call BIS_fnc_loadInventory;
  60. } else {
  61. systemChat "No loadout found";
  62. };
  63.  
  64. };
  65.  
  66. };
Advertisement
Add Comment
Please, Sign In to add comment