friquentin

Untitled

Oct 26th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 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","_itembuy","_itemprice","_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. //Début modification Aldar Ducken :: Achat de véhicules avec vitems.
  21. _itembuy = M_CONFIG(getNumber,"LifeCfgVehicles",_classNameLife,"itembuy");
  22. if (_itembuy isEqualTo 1) then {_itembuy = true;} else {_itembuy = false;};
  23. _itemprice = M_CONFIG(getText,"LifeCfgVehicles",_classNameLife,"itemprice");
  24. _itemtext = localize (getText (missionConfigFile >> "VirtualItems" >> _itemprice >> "displayName"));
  25. //Fin de modifications Aldar Ducken
  26. switch (playerSide) do {
  27. case civilian: {
  28. _buyMultiplier = LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_CIVILIAN");
  29. _rentMultiplier = LIFE_SETTINGS(getNumber,"vehicle_rental_multiplier_CIVILIAN");
  30. };
  31. case west: {
  32. _buyMultiplier = LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_COP");
  33. _rentMultiplier = LIFE_SETTINGS(getNumber,"vehicle_rental_multiplier_COP");
  34. };
  35. case independent: {
  36. _buyMultiplier = LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_MEDIC");
  37. _rentMultiplier = LIFE_SETTINGS(getNumber,"vehicle_rental_multiplier_MEDIC");
  38. };
  39. case east: {
  40. _buyMultiplier = LIFE_SETTINGS(getNumber,"vehicle_purchase_multiplier_OPFOR");
  41. _rentMultiplier = LIFE_SETTINGS(getNumber,"vehicle_rental_multiplier_OPFOR");
  42. };
  43. };
  44.  
  45. _vehicleInfo = [_className] call life_fnc_fetchVehInfo;
  46. _trunkSpace = [_className] call life_fnc_vehicleWeightCfg;
  47. _maxspeed = (_vehicleInfo select 8);
  48. _horsepower = (_vehicleInfo select 11);
  49. _passengerseats = (_vehicleInfo select 10);
  50. _fuel = (_vehicleInfo select 12);
  51. _armor = (_vehicleInfo select 9);
  52. [_className] call life_fnc_vehicleShop3DPreview;
  53.  
  54. ctrlShow [2330,true];
  55. if ((_itembuy) && (license_civ_vehiclefab)) then {
  56. (CONTROL(2300,2303)) ctrlSetStructuredText parseText format [
  57. (localize "STR_Shop_Veh_UI_Rental")+ " <t color='#8cff9b'>%1€</t><br/>" +
  58. "Schéma de Fabrication :<br/> <t color='#8cff9b'>%2</t><br/>" +
  59. (localize "STR_Shop_Veh_UI_MaxSpeed")+ "<t color='#8cff9b'> %3 km/h</t><br/>" +
  60. (localize "STR_Shop_Veh_UI_HPower")+ " <t color='#8cff9b'>%4</t><br/>" +
  61. (localize "STR_Shop_Veh_UI_PSeats")+ " <t color='#8cff9b'>%5</t><br/>" +
  62. (localize "STR_Shop_Veh_UI_Trunk")+ " <t color='#8cff9b'>%6</t><br/>" +
  63. (localize "STR_Shop_Veh_UI_Fuel")+ " <t color='#8cff9b'>%7</t><br/>" +
  64. (localize "STR_Shop_Veh_UI_Armor")+ " <t color='#8cff9b'>%8</t>",
  65. [round(_initalPrice * _rentMultiplier)] call life_fnc_numberText,
  66. _itemtext,
  67. _maxspeed,
  68. _horsepower,
  69. _passengerseats,
  70. if (_trunkSpace isEqualTo -1) then {"None"} else {_trunkSpace},
  71. _fuel,
  72. _armor
  73. ];
  74. } else {
  75. (CONTROL(2300,2303)) ctrlSetStructuredText parseText format [
  76. (localize "STR_Shop_Veh_UI_Rental")+ " <t color='#8cff9b'>%1€</t><br/>" +
  77. (localize "STR_Shop_Veh_UI_Ownership")+ " <t color='#8cff9b'>%2€</t><br/>" +
  78. (localize "STR_Shop_Veh_UI_MaxSpeed")+ " <t color='#8cff9b'>%3 km/h</t><br/>" +
  79. (localize "STR_Shop_Veh_UI_HPower")+ " <t color='#8cff9b'>%4</t><br/>" +
  80. (localize "STR_Shop_Veh_UI_PSeats")+ " <t color='#8cff9b'>%5</t><br/>" +
  81. (localize "STR_Shop_Veh_UI_Trunk")+ " <t color='#8cff9b'>%6</t><br/>" +
  82. (localize "STR_Shop_Veh_UI_Fuel")+ " <t color='#8cff9b'>%7</t><br/>" +
  83. (localize "STR_Shop_Veh_UI_Armor")+ " <t color='#8cff9b'>%8</t>",
  84. [round(_initalPrice * _rentMultiplier)] call life_fnc_numberText,
  85. [round(_initalPrice * _buyMultiplier)] call life_fnc_numberText,
  86. _maxspeed,
  87. _horsepower,
  88. _passengerseats,
  89. if (_trunkSpace isEqualTo -1) then {"None"} else {_trunkSpace},
  90. _fuel,
  91. _armor
  92. ];
  93. };
  94.  
  95. _ctrl = CONTROL(2300,2304);
  96. lbClear _ctrl;
  97.  
  98. if (!isClass (missionConfigFile >> "LifeCfgVehicles" >> _classNameLife)) then {
  99. _classNameLife = "Default"; //Use Default class if it doesn't exist
  100. diag_log format ["%1: LifeCfgVehicles class doesn't exist",_className];
  101. };
  102. _colorArray = M_CONFIG(getArray,"LifeCfgVehicles",_classNameLife,"textures");
  103.  
  104. {
  105. _flag = (_x select 1);
  106. _textureName = (_x select 0);
  107. if ((life_veh_shop select 2) isEqualTo _flag) then {
  108. _x params ["_texture"];
  109. private _toShow = [_x] call life_fnc_levelCheck;
  110. if (_toShow) then {
  111. _ctrl lbAdd _textureName;
  112. _ctrl lbSetValue [(lbSize _ctrl)-1,_forEachIndex];
  113. };
  114. };
  115. } forEach _colorArray;
  116.  
  117. _numberindexcolorarray = [];
  118. for "_i" from 0 to (count(_colorArray) - 1) do {
  119. _numberindexcolorarray pushBack _i;
  120. };
  121. _indexrandom = _numberindexcolorarray call BIS_fnc_selectRandom;
  122. _ctrl lbSetCurSel _indexrandom;
  123.  
  124. if (_className in (LIFE_SETTINGS(getArray,"vehicleShop_rentalOnly"))) then {
  125. ctrlEnable [2309,false];
  126. } else {
  127. if (!(life_veh_shop select 3)) then {
  128. ctrlEnable [2309,true];
  129. };
  130. };
  131.  
  132. if !((lbSize _ctrl)-1 isEqualTo -1) then {
  133. ctrlShow[2304,true];
  134. } else {
  135. ctrlShow[2304,false];
  136. };
  137.  
  138. true;
Advertisement
Add Comment
Please, Sign In to add comment