Guest User

Untitled

a guest
Oct 15th, 2018
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.59 KB | None | 0 0
  1. span class="re5"> params ["_priceClass"];
  2.  
  3. // Prices set for specific weapons
  4. private _specificWeaponPrices = [
  5.     "arifle_MX_F",100,
  6.     "arifle_MX_GL_F",200,
  7.     "arifle_MX_SW_F",300,
  8.     "launch_B_Titan_short_F",400,
  9.     "launch_NLAW_F",500
  10. ];
  11.  
  12. private _price = 0;
  13.  
  14. // Prices set for general groups of weapons, in case the weapon that we try to find does not have specific price set
  15. private _genericWeaponPrices = [
  16.     150, // type = 1, RIFLE
  17.     50, //type = 2, HANDGUN
  18.     350  //type = 4, LAUNCHER
  19. ];
  20.  
  21. // We check the specific prices array to see if a price was set for our weapon
  22. private _index = _specificWeaponPrices find _priceClass;
  23.  
  24. // The index will return the position weapon's class name if it was defined in the _specificWeaponPrices array, if not it will return -1
  25. if (_index == -1) then {
  26.     // Things got complicated and the weapon has no specific price set. In this case we need to check what type the weapon is and then use a value from our generic prices array
  27.     private _type = (getNumber(configFile >> "cfgWeapons" >> _priceClass >> "type"));
  28.     switch (_type) do {
  29.         case 1: { _price = _genericWeaponPrices select 0 }; // Price set to generic rifle price
  30.         case 2: { _price = _genericWeaponPrices select 1 }; // Price set to generic handgun price
  31.         case 4: { _price = _genericWeaponPrices select 2 }; // Price set to generic launcher price
  32.     };
  33. } else {
  34.     // Specific price found, we now set the price to the value was set by pointing the script to the position next to the class name that returned the hit, thats where is the price for our weapon
  35.     _price = _specificWeaponPrices select (_index + 1);
  36. };
  37. _price;
Advertisement
Add Comment
Please, Sign In to add comment