forked from InZidiuZ/LegacyFuel
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathserver.lua
32 lines (31 loc) · 1.01 KB
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
ESX = nil
TriggerEvent(Config.ESX.ESXSHAREDOBJECT, function(obj) ESX = obj end)
RegisterServerEvent("renzu_fuel:payfuel")
AddEventHandler("renzu_fuel:payfuel",function(price,jeryycan,vehicle,fuel,fuel2,key)
local source = source
local output = {}
output = {
['price'] = Config.stock.default_price,
}
local xPlayer = ESX.GetPlayerFromId(source)
if price > 0 then
local amount = 0
money = xPlayer.getMoney()
if money >= price then
xPlayer.removeMoney(price)
if jeryycan then
xPlayer.removeWeapon('WEAPON_PETROLCAN')
Wait(500)
xPlayer.addWeapon('WEAPON_PETROLCAN',4500)
else
amount = math.floor(price/output.price)
fuel = math.floor(fuel/output.price)
TriggerClientEvent('renzu_fuel:syncfuel',-1,vehicle,fuel)
TriggerClientEvent("renzu_fuel:Notify",source,"Paid <b>$"..price.." </b> in "..amount.." liters.")
end
else
TriggerClientEvent('renzu_fuel:insuficiente',source,vehicle,fuel2)
TriggerClientEvent("renzu_fuel:Notify",source,"Insuficient money.")
end
end
end)