Files
overextended.github.io/pages/ox_lib/Modules/VehicleProperties/Client.mdx
T
2023-06-04 15:15:21 +02:00

74 lines
1.4 KiB
Plaintext

Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props.
https://github.com/overextended/ox_lib/blob/master/resource/vehicleProperties/client.lua#L5
import { Tabs, Tab } from 'nextra-theme-docs';
### lib.getVehicleProperties
```ts
lib.getVehicleProperties(vehicle)
```
* vehicle: `entity`
<Tabs items={["Lua", "JS"]}>
<Tab>
```lua
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/client'
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
```
</Tab>
</Tabs>
### lib.setVehicleProperties
Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_.
```lua
lib.setVehicleProperties(vehicle, props)
```
* vehicle: `entity`
* props: `table` (`object`)
<Tabs items={["Lua", "JS"]}>
<Tab>
```lua
RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
lib.setVehicleProperties(NetToVeh(netid), data)
end)
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/client'
onNet('ox_lib:setVehicleProperties', (netid, data) => {
lib.setVehicleProperties(NetToVeh(netid), data)
})
```
</Tab>
</Tabs>
#### Recommended usage
The server should tell the owner of the entity to set properties, using the following trigger.
```lua
TriggerClientEvent('ox_lib:setVehicleProperties', entityOwner, vehNetId, data)
```