Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. local Tunnel = module("vrp", "lib/Tunnel")
  2. local Proxy = module("vrp", "lib/Proxy")
  3.  
  4. vRP = Proxy.getInterface("vRP")
  5. vRPclient = Tunnel.getInterface("vRP","frfuel")
  6.  
  7. fuel = 2.25 -- Fuel Cost, this could be made to randomise between 1.05 and 1.30 or something like that
  8.  
  9. function round(num, numDecimalPlaces)
  10. local mult = 5^(numDecimalPlaces or 0)
  11. return math.floor(num * mult + 0.5) / mult
  12. end
  13.  
  14. RegisterServerEvent('frfuel:fuelAdded')
  15. AddEventHandler('frfuel:fuelAdded', function(amount)
  16.  
  17. local user_id = vRP.getUserId({source}, function(user_id) return user_id end)
  18. local wallet = vRP.getMoney({user_id})
  19. local cost = fuel * amount
  20. local nWallet = wallet - round(cost)
  21. local paidAmount = vRP.tryPayment({user_id, round(cost)})
  22.  
  23. if paidAmount then
  24. vRP.tryPayment({user_id, round(cost)})
  25. vRPclient.notify(user_id,{"You filled up with " .. round(amount) .. " gallons of fuel"})
  26. vRPclient.notify(user_id,{"Filling up today cost you $" .. round(cost)})
  27. print("Debited" .. round(cost))
  28. elseif not paidAmount then
  29. TriggerClientEvent('chatMessage', -1, "911", {255, 0, 0}, GetPlayerName(source) .." has made off without paying for fuel and is now wanted")
  30. SetPlayerWantedLevel(source, 1, false)
  31. print("Fuel payment not successful")
  32. end
  33. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement