Advertisement
Darth_Rogue

ExileClient_object_vehicle_refuel.sqf

Oct 6th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. /**
  2. * Exile Mod
  3. * www.exilemod.com
  4. * © 2015 Exile Mod Team
  5. *
  6. * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  7. * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  8. */
  9.  
  10. private["_vehicle","_magazines","_removed","_override","_fuelDetails","_amount"];
  11. _vehicle = _this select 0;
  12. _magazines = magazinesAmmo player;
  13. _removed = false;
  14. _override = false;
  15. {
  16. _fuelDetails = _vehicle call ExileClient_util_fuel_getRealFuel;
  17. if((_fuelDetails select 0) isEqualTo (_fuelDetails select 1))exitWith
  18. {
  19. ["VehicleRefulingFailedFull"] call ExileClient_gui_notification_event_addNotification;
  20. _override = true;
  21. };
  22. _gaspump = ((getPos player) nearObjects ["Land_fs_feed_F",15]);
  23. if (!isNull (_gaspump select 0)) exitWith
  24. {
  25. _amount = ((_fuelDetails select 1) - (_fuelDetails select 0));
  26. [_vehicle,_amount] call ExileClient_util_fuel_setFuel;
  27. ["VehicleRefuled", [format ["Vehicle refuled for: %1L",_amount]]] call ExileClient_gui_notification_event_addNotification;
  28. _override = true;
  29. };
  30. if((_x select 0) isEqualTo "Exile_Item_FuelCanisterFull")then
  31. {
  32. _amount = (_x select 1);
  33. if(_amount > 0)then
  34. {
  35. if(((_fuelDetails select 1) - (_fuelDetails select 0)) < _amount)then
  36. {
  37. _amount = (_fuelDetails select 1) - (_fuelDetails select 0);
  38. [
  39. player,
  40. ["Exile_Item_FuelCanisterFull",_x select 1],
  41. ["Exile_Item_FuelCanisterFull",(_x select 1) - _amount]
  42. ] call ExileClient_util_inventory_replaceMagazine;
  43. }
  44. else
  45. {
  46. [
  47. player,
  48. ["Exile_Item_FuelCanisterFull",_x select 1],
  49. ["Exile_Item_FuelCanisterEmpty",1]
  50. ] call ExileClient_util_inventory_replaceMagazine;
  51. };
  52. _removed = true;
  53. };
  54. };
  55. if(_removed)exitWith{};
  56. }
  57. forEach _magazines;
  58. call ExileClient_object_player_save;
  59. if(_removed)then
  60. {
  61. if(local _vehicle)then
  62. {
  63. [_vehicle,_amount] call ExileClient_util_fuel_setFuel;
  64. }
  65. else
  66. {
  67. ["setFuelRequest",[netId _vehicle,_amount]] call ExileClient_system_network_send;
  68. };
  69. ["VehicleRefuled", [format ["Vehicle refuled for: %1L",_amount]]] call ExileClient_gui_notification_event_addNotification;
  70. }
  71. else
  72. {
  73. if!(_override)then
  74. {
  75. ["VehicleRefulingFailed"] call ExileClient_gui_notification_event_addNotification;
  76. };
  77. };
  78. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement