This commit is contained in:
Luke committed 2023-06-04 15:15:21 +02:00
1 parent 3cebaf7fa5
commit b5eba8423f
229 files changed
+6238 -10690

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
---
title: Server
sidebar_position: 1
---
## Ox.GetVehicle
Return an instance of OxVehicle for the given entity.
```lua
local vehicle = Ox.GetVehicle(entity)
print(json.encode(vehicle, { indent = true }))
```
## Ox.GetVehicles
Returns an array containing all vehicles. Methods will not be applied if the first argument is false.
```lua
local vehicles = Ox.GetVehicles(usemetatable)
for i = 1, #vehicles do
local vehicle = vehicles[i]
print(json.encode(vehicle, { indent = true }))
end
```
## Ox.CreateVehicle
Spawns a vehicle and returns the instance of OxVehicle.
If the first argument is a number, it will attempt to spawn a vehicle from the database with a matching id.
```lua
local vehicleId = MySQL.scalar.await('SELECT id FROM vehicles WHERE owner = ? LIMIT 1', { player.charid })
if vehicleId then
local coords = player.getCoords()
local vehicle = Ox.CreateVehicle(vehicleId, vector3(coords.x, coords.y + 1.0, coords.z) , GetEntityHeading(player.ped))
if vehicle then
print(json.encode(vehicle, { indent = true }))
end
end
```
If the first argument is a table and the owner property is a number, or nil, the vehicle will be added to the database.
Setting the owner as false creates a non-persistent vehicle.
```lua
local vehicle = Ox.CreateVehicle({
model = 'sultanrs',
owner = player.charid,
}, player.getCoords(), GetEntityHeading(player.ped))
```
@@ -0,0 +1,14 @@
---
title: Callbacks
---
### ox:getNearbyVehicles
Get all vehicles within range of the target player.
```lua
lib.callback.await('ox:getNearbyVehicles', playerId, radius)
```
- playerId: `number`
- radius?: `number`
+96
View File
@@ -0,0 +1,96 @@
---
title: Methods
---
These functions are inherited from the [Vehicle class](../Server/).
## vehicle.set
Sets the vehicle's metadata for key to the given value.
```lua
vehicle.set(key, value)
```
- key: `string`
- value: `any`
## vehicle.get
Get a value from the vehicles's metadata, or omit the argument to get all metadata.
```lua
vehicle.get(key)
```
- key?: `string`
## vehicle.getState
Return the vehicle's statebag.
```lua
vehicle.getState()
```
## vehicle.getCoords
Return the vehicle's position.
```lua
vehicle.getCoords()
```
## vehicle.despawn
Despawns the vehicle but doesn't save it or update the stored value.
## vehicle.delete
Remove the vehicle from the database and despawns the entity.
```lua
vehicle.delete()
```
## vehicle.setStored
Updates the vehicle's "stored" value and optionally despawns it.
```lua
vehicle.setStored(value, despawn)
```
- value?: `string`
- despawn?: `boolean`
## vehicle.setOwner
Sets the vehicle's owner, matching a charid or nil to set it as unowned.
```lua
vehicle.setOwner(owner)
```
- owner?: `number`
## vehicle.setGroup
Sets the vehicle's group, which can be used for garage restrictions, unowned group vehicles, etc.
```lua
vehicle.setGroup(group)
```
- group?: `string`
## vehicle.setPlate
Sets the vehicle's plate, used in the database to ensure uniqueness. Does not necessarily match the plate property (i.e. fake plates).
Plate is always formatted to 8 characters.
```lua
vehicle.setPlate(plate)
```
- plate: `string`