From 1203a439cdafb9615ef01f0648f3b88002154563 Mon Sep 17 00:00:00 2001 From: InZidiuZ Date: Wed, 8 May 2019 22:46:47 +0200 Subject: [PATCH] added ability ro refill jerry cans --- config.lua | 6 +++++- source/fuel_client.lua | 26 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/config.lua b/config.lua index 2855051..eb0b8f2 100644 --- a/config.lua +++ b/config.lua @@ -5,6 +5,7 @@ Config.UseESX = true -- What should the price of jerry cans be? Config.JerryCanCost = 100 +Config.RefillCost = 50 -- If it is missing half of it capacity, this amount will be divided in half, and so on. -- Fuel decor - No need to change this, just leave it. Config.FuelDecor = "_FUEL_LEVEL" @@ -29,11 +30,14 @@ Config.Strings = { CancelFuelingPump = "Press ~g~E ~w~to cancel the fueling", CancelFuelingJerryCan = "Press ~g~E ~w~to cancel the fueling", NotEnoughCash = "Not enough cash", - AlreadyHasJerryCan = "You already have a jerry can" + RefillJerryCan = "Press ~g~E ~w~ to refill the jerry can for ", + NotEnoughCashJerryCan = "Not enough cash to refill jerry can", + JerryCanFull = "Jerry can is full" } if not Config.UseESX then Config.Strings.PurchaseJerryCan = "Press ~g~E ~w~to grab a jerry can" + Config.Strings.RefillJerryCan = "Press ~g~E ~w~ to refill the jerry can" end Config.PumpModels = { diff --git a/source/fuel_client.lua b/source/fuel_client.lua index ebc4485..27a2635 100644 --- a/source/fuel_client.lua +++ b/source/fuel_client.lua @@ -306,7 +306,31 @@ Citizen.CreateThread(function() currentCash = ESX.GetPlayerData().money end else - DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.AlreadyHasJerryCan) + if Config.UseESX then + local refillCost = Round(Config.RefillCost * (1 - GetAmmoInPedWeapon(ped, 883325847) / 4500)) + + if refillCost > 0 then + if currentCash >= refillCost then + DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.RefillJerryCan .. refillCost) + + if IsControlJustReleased(0, 38) then + TriggerServerEvent('fuel:pay', refillCost) + + SetPedAmmo(ped, 883325847, 4500) + end + else + DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.NotEnoughCashJerryCan) + end + else + DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.JerryCanFull) + end + else + DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.RefillJerryCan) + + if IsControlJustReleased(0, 38) then + SetPedAmmo(ped, 883325847, 4500) + end + end end else DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.NotEnoughCash)