Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- span class="re5"> params ["_priceClass"];
- // Prices set for specific weapons
- private _specificWeaponPrices = [
- "arifle_MX_F",100,
- "arifle_MX_GL_F",200,
- "arifle_MX_SW_F",300,
- "launch_B_Titan_short_F",400,
- "launch_NLAW_F",500
- ];
- private _price = 0;
- // Prices set for general groups of weapons, in case the weapon that we try to find does not have specific price set
- private _genericWeaponPrices = [
- 150, // type = 1, RIFLE
- 50, //type = 2, HANDGUN
- 350 //type = 4, LAUNCHER
- ];
- // We check the specific prices array to see if a price was set for our weapon
- private _index = _specificWeaponPrices find _priceClass;
- // The index will return the position weapon's class name if it was defined in the _specificWeaponPrices array, if not it will return -1
- if (_index == -1) then {
- // 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
- private _type = (getNumber(configFile >> "cfgWeapons" >> _priceClass >> "type"));
- switch (_type) do {
- case 1: { _price = _genericWeaponPrices select 0 }; // Price set to generic rifle price
- case 2: { _price = _genericWeaponPrices select 1 }; // Price set to generic handgun price
- case 4: { _price = _genericWeaponPrices select 2 }; // Price set to generic launcher price
- };
- } else {
- // 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
- _price = _specificWeaponPrices select (_index + 1);
- };
- _price;
Advertisement
Add Comment
Please, Sign In to add comment