Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Tunnel = module("vrp", "lib/Tunnel")
- local Proxy = module("vrp", "lib/Proxy")
- vRP = Proxy.getInterface("vRP")
- vRPclient = Tunnel.getInterface("vRP","frfuel")
- fuel = 2.25 -- Fuel Cost, this could be made to randomise between 1.05 and 1.30 or something like that
- function round(num, numDecimalPlaces)
- local mult = 5^(numDecimalPlaces or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- RegisterServerEvent('frfuel:fuelAdded')
- AddEventHandler('frfuel:fuelAdded', function(amount)
- local user_id = vRP.getUserId({source}, function(user_id) return user_id end)
- local wallet = vRP.getMoney({user_id})
- local cost = fuel * amount
- local nWallet = wallet - round(cost)
- local paidAmount = vRP.tryPayment({user_id, round(cost)})
- if paidAmount then
- vRP.tryPayment({user_id, round(cost)})
- vRPclient.notify(user_id,{"You filled up with " .. round(amount) .. " gallons of fuel"})
- vRPclient.notify(user_id,{"Filling up today cost you $" .. round(cost)})
- print("Debited" .. round(cost))
- elseif not paidAmount then
- TriggerClientEvent('chatMessage', -1, "911", {255, 0, 0}, GetPlayerName(source) .." has made off without paying for fuel and is now wanted")
- SetPlayerWantedLevel(source, 1, false)
- print("Fuel payment not successful")
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement