Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/overextended/ox_fuel
Simplistic fuel resource meant for use with ox_inventory
https://github.com/overextended/ox_fuel
Last synced: 3 months ago
JSON representation
Simplistic fuel resource meant for use with ox_inventory
- Host: GitHub
- URL: https://github.com/overextended/ox_fuel
- Owner: overextended
- License: gpl-3.0
- Created: 2022-01-15T10:30:17.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-14T13:01:54.000Z (6 months ago)
- Last Synced: 2024-07-15T08:26:45.248Z (6 months ago)
- Language: Lua
- Homepage: https://overextended.dev/ox_fuel
- Size: 105 KB
- Stars: 58
- Watchers: 9
- Forks: 75
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ox_fuel
Basic fuel resource and alternative to LegacyFuel, meant for use with ox_inventory.
## Get vehicle fuel level
This is an incredibly complicated task for some people, and they often ask for exports to do it.
You use the native function [GetVehicleFuelLevel](https://docs.fivem.net/natives/?_0x5F739BB8), or you can use a statebag.```lua
Entity(entity).state.fuel
```## Set vehicle fuel level
```lua
Entity(entity).state.fuel = fuelAmount
```## setPaymentMethod (server)
Replaces the standard payment method using "money" as an item.
```lua
exports.ox_fuel:setPaymentMethod(function(playerId, amount)
local xPlayer = ESX.GetPlayerFromId(playerId)
local bankAmount = xPlayer.getAccount('bank').moneyif bankAmount >= amount then
xPlayer.removeAccountMoney('bank', amount)
return true
endTriggerClientEvent('ox_lib:notify', source, {
type = 'error',
description = locale('not_enough_money', amount - bankAmount)
})
end)
```## setMoneyCheck (client)
Replaces the standard inventory search for "money".
```lua
exports.ox_fuel:setMoneyCheck(function()
local accounts = ESX.GetPlayerData().accountsfor i = 1, #accounts do
if accounts[i].name == 'bank' then
return accounts[i].money
end
endreturn 0
end)
```