mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 14:38:50 +00:00
ox_core/vehicle/server docs
This commit is contained in:
1 parent
355d7eb052
commit
1482e64639
2 files changed
+105
No files matched your search
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: Server
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
## Ox.GetVehicle
|
||||
|
||||
Return an instance of CVehicle 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 CVehicle.
|
||||
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,52 @@
|
||||
---
|
||||
title: Methods
|
||||
---
|
||||
|
||||
These functions are inherited by instances of CVehicle.
|
||||
|
||||
```lua
|
||||
local vehicle = Ox.GetVehicle(entity)
|
||||
```
|
||||
|
||||
## vehicle.set
|
||||
|
||||
Sets the vehicle's metadata for key to the given value.
|
||||
|
||||
```lua
|
||||
local key, value = 'vin', '1HGBH41JXMN109186'
|
||||
vehicle.set(key, value)
|
||||
```
|
||||
|
||||
## vehicle.get
|
||||
|
||||
Return the vehicle's metadata. Sending an argument will retrieve a specific metadata key.
|
||||
|
||||
```lua
|
||||
local data = vehicle.get()
|
||||
local vin = vehicle.get('vin')
|
||||
```
|
||||
|
||||
## vehicle.getCoords
|
||||
|
||||
Return the vehicle's world position. The value will be cached for future calls, so send true for the first argument to update it.
|
||||
|
||||
```lua
|
||||
local coords = vehicle.getCoords(update)
|
||||
```
|
||||
|
||||
## vehicle.delete
|
||||
|
||||
Remove the vehicle from the database and despawns the entity.
|
||||
|
||||
```lua
|
||||
vehicle.delete()
|
||||
```
|
||||
|
||||
## vehicle.store
|
||||
|
||||
Save the vehicle to the database and despawns the entity.
|
||||
|
||||
```lua
|
||||
local store = 'garagea'
|
||||
vehicle.store(store)
|
||||
```
|
||||
Reference in new issue
Block a user