Skip to content

Commit

Permalink
added ability ro refill jerry cans
Browse files Browse the repository at this point in the history
  • Loading branch information
InZidiuZ committed May 8, 2019
1 parent 48f5230 commit 1203a43
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
6 changes: 5 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 = {
Expand Down
26 changes: 25 additions & 1 deletion source/fuel_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1203a43

Please sign in to comment.