Advertisement
Guest User

Untitled

a guest
May 14th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 4.14 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3.     File: fn_vehicleShopLBChange.sqf
  4.     Author: Bryan "Tonic" Boardwine
  5.     Modified : NiiRoZz
  6.  
  7.     Description:
  8.     Called when a new selection is made in the list box and
  9.     displays various bits of information about the vehicle.
  10. */
  11. disableSerialization;
  12. private ["_className","_classNameLife","_initalPrice","_buyMultiplier","_rentMultiplier","_vehicleInfo","_colorArray","_ctrl","_trunkSpace","_maxspeed","_horsepower","_passengerseats","_fuel","_armor"];
  13.  
  14. //Fetch some information.
  15. _className = (_this select 0) lbData (_this select 1);
  16. _classNameLife = _className;
  17. _vIndex = (_this select 0) lbValue (_this select 1);
  18.  
  19. _initalPrice = M_CONFIG(getNumber,"LifeCfgVehicles",_classNameLife,"price");
  20.  
  21. switch (playerSide) do {
  22.     case civilian: {
  23.         _buyMultiplier = LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_CIVILIAN");
  24.         _rentMultiplier = LIFE_SETTINGS(getNumber,"vehicle_rental_multiplier_CIVILIAN");
  25.     };
  26.     case west: {
  27.         _buyMultiplier = LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_COP");
  28.         _rentMultiplier = LIFE_SETTINGS(getNumber,"vehicle_rental_multiplier_COP");
  29.     };
  30.     case independent: {
  31.         _buyMultiplier = LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_MEDIC");
  32.         _rentMultiplier = LIFE_SETTINGS(getNumber,"vehicle_rental_multiplier_MEDIC");
  33.     };
  34.     case east: {
  35.         _buyMultiplier = LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_OPFOR");
  36.         _rentMultiplier = LIFE_SETTINGS(getNumber,"vehicle_rental_multiplier_OPFOR");
  37.     };
  38. };
  39.  
  40. _vehicleInfo = [_className] call life_fnc_fetchVehInfo;
  41. _trunkSpace = [_className] call life_fnc_vehicleWeightCfg;
  42. _maxspeed = (_vehicleInfo select 8);
  43. _horsepower = (_vehicleInfo select 11);
  44. _passengerseats = (_vehicleInfo select 10);
  45. _fuel = (_vehicleInfo select 12);
  46. _armor = (_vehicleInfo select 9);
  47. [_className] call life_fnc_vehicleShop3DPreview;
  48.  
  49. ctrlShow [2330,true];
  50. (CONTROL(2300,2303)) ctrlSetStructuredText parseText format [
  51.     (localize "STR_Shop_Veh_UI_Rental")+ " <t color='#8cff9b'>$%1</t><br/>" +
  52.     (localize "STR_Shop_Veh_UI_Ownership")+ " <t color='#8cff9b'>$%2</t><br/>" +
  53.     (localize "STR_Shop_Veh_UI_MaxSpeed")+ " %3 km/h<br/>" +
  54.     "Type d'essence : %9<br/>" +
  55.     (localize "STR_Shop_Veh_UI_HPower")+ " %4<br/>" +
  56.     (localize "STR_Shop_Veh_UI_PSeats")+ " %5<br/>" +
  57.     (localize "STR_Shop_Veh_UI_Trunk")+ " %6<br/>" +
  58.     (localize "STR_Shop_Veh_UI_Fuel")+ " %7<br/>" +
  59.     (localize "STR_Shop_Veh_UI_Armor")+ " %8",
  60.     [round(_initalPrice * _rentMultiplier)] call life_fnc_numberText,
  61.     [round(_initalPrice * _buyMultiplier)] call life_fnc_numberText,
  62.     _maxspeed,
  63.     _horsepower,
  64.     _passengerseats,
  65.     if (_trunkSpace isEqualTo -1) then {"None"} else {_trunkSpace},
  66.     _fuel,
  67.     _armor,
  68.     [_classNameLife] call max_fuelstations_fnc_getFuelType
  69. ];
  70.  
  71. _ctrl = CONTROL(2300,2304);
  72. lbClear _ctrl;
  73.  
  74. if (!isClass (missionConfigFile >> "LifeCfgVehicles" >> _classNameLife)) then {
  75.     _classNameLife = "Default"; //Use Default class if it doesn't exist
  76.     diag_log format ["%1: LifeCfgVehicles class doesn't exist",_className];
  77. };
  78. _colorArray = M_CONFIG(getArray,"LifeCfgVehicles",_classNameLife,"textures");
  79.  
  80. {
  81.     _flag = (_x select 1);
  82.     _textureName = (_x select 0);
  83.     if ((life_veh_shop select 2) isEqualTo _flag) then {
  84.         _x params ["_texture"];
  85.         private _toShow = [_x] call life_fnc_levelCheck;
  86.         if (_toShow) then {
  87.             _ctrl lbAdd _textureName;
  88.             _ctrl lbSetValue [(lbSize _ctrl)-1,_forEachIndex];
  89.         };
  90.     };
  91. } forEach _colorArray;
  92.  
  93. _numberindexcolorarray = [];
  94. for "_i" from 0 to (count(_colorArray) - 1) do {
  95.     _numberindexcolorarray pushBack _i;
  96. };
  97. _indexrandom = _numberindexcolorarray call BIS_fnc_selectRandom;
  98. _ctrl lbSetCurSel _indexrandom;
  99.  
  100. if (_className in (LIFE_SETTINGS(getArray,"vehicleShop_rentalOnly"))) then {
  101.     ctrlEnable [2309,false];
  102. } else {
  103.     if (!(life_veh_shop select 3)) then {
  104.         ctrlEnable [2309,true];
  105.     };
  106. };
  107.  
  108. if !((lbSize _ctrl)-1 isEqualTo -1) then {
  109.     ctrlShow[2304,true];
  110. } else {
  111.     ctrlShow[2304,false];
  112. };
  113.  
  114. true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement