mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 14:38:50 +00:00
Update docs (#96)
* Update docs * CPlayer -> OxPlayer Removed functions.md index.md includes player? * fix CVehicle -> OxVehicle Added missing dot to end of sentence Consistency with rest of docs
This commit is contained in:
1 parent
0fd6873fdf
commit
1ba636a6e6
5 files changed
+45
-15
No files matched your search
@@ -8,30 +8,30 @@ Lua doesn't have support for true classes, but rather prototype-based inheritanc
|
|||||||
A prototype can hold its own variables and methods, which another object (an instance) can reference or call.
|
A prototype can hold its own variables and methods, which another object (an instance) can reference or call.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- CPlayer will hold all inherited variables and methods for instances of it.
|
-- OxPlayer will hold all inherited variables and methods for instances of it.
|
||||||
local CPlayer = {}
|
local OxPlayer = {}
|
||||||
|
|
||||||
-- Sets the "index metamethod" of CPlayer to reference itself.
|
-- Sets the "index metamethod" of OxPlayer to reference itself.
|
||||||
-- This is how instances will know to look up the table.
|
-- This is how instances will know to look up the table.
|
||||||
CPlayer.__index = CPlayer
|
OxPlayer.__index = OxPlayer
|
||||||
|
|
||||||
-- Set a new metatable on the table passed to the function.
|
-- Set a new metatable on the table passed to the function.
|
||||||
-- The important code here is { __index = CPlayer }.
|
-- The important code here is { __index = OxPlayer }.
|
||||||
function CPlayer.new(player)
|
function OxPlayer.new(player)
|
||||||
return setmetatable(player, CPlayer)
|
return setmetatable(player, OxPlayer)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Using the `:` syntax will pass the object as the first parameter.
|
-- Using the `:` syntax will pass the object as the first parameter.
|
||||||
function CPlayer:getUsername()
|
function OxPlayer:getUsername()
|
||||||
return self.username
|
return self.username
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create our instance of CPlayer.
|
-- Create our instance of OxPlayer.
|
||||||
local player = CPlayer.new({
|
local player = OxPlayer.new({
|
||||||
username = 'Bob the Builder'
|
username = 'Bob the Builder'
|
||||||
})
|
})
|
||||||
|
|
||||||
-- This is the same as CPlayer.getUsername(player).
|
-- This is the same as OxPlayer.getUsername(player).
|
||||||
local username = player:getUsername()
|
local username = player:getUsername()
|
||||||
|
|
||||||
-- 'Bob the Builder'
|
-- 'Bob the Builder'
|
||||||
|
|||||||
@@ -25,3 +25,14 @@ lib.callback.await('ox:getLicense', delay, licenseName, targetId)
|
|||||||
- The name of the license to get data for. Can be omitted to return all licenses.
|
- The name of the license to get data for. Can be omitted to return all licenses.
|
||||||
- targetId?: `number`
|
- targetId?: `number`
|
||||||
- The server id to get license data for, defaulting to the current player.
|
- The server id to get license data for, defaulting to the current player.
|
||||||
|
|
||||||
|
### ox:getNearbyVehicles
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.callback.register('ox:getNearbyVehicles', function(radius)
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns an array of vehicle netids within a given radius of the player's location.
|
||||||
|
|
||||||
|
- radius?: `number`
|
||||||
|
- The radius from the player's location to return vehicles.
|
||||||
@@ -2,3 +2,22 @@
|
|||||||
title: Client
|
title: Client
|
||||||
sidebar_position: 1
|
sidebar_position: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### player
|
||||||
|
|
||||||
|
|
||||||
|
The player variable refers to the result of [Ox.GetPlayerData](https://github.com/overextended/ox_core/blob/main/client/player.lua#L48) unless reassigned.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
```lua
|
||||||
|
print(json.encode(player, { indent = true }))
|
||||||
|
```
|
||||||
|
- player?: `table`
|
||||||
|
- name: `string`
|
||||||
|
- firstname: `string`
|
||||||
|
- lastname: `string`
|
||||||
|
- userid: `number`
|
||||||
|
- charid: `number`
|
||||||
|
- groups: `table`
|
||||||
|
- gender: `string`
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
## Ox.GetPlayer
|
## Ox.GetPlayer
|
||||||
|
|
||||||
Return an instance of CPlayer for the given player source.
|
Return an instance of OxPlayer for the given player source.
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='lua' label='Lua'>
|
<TabItem value='lua' label='Lua'>
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ console.log(JSON.stringify(player));
|
|||||||
|
|
||||||
## Ox.GetPlayerByFilter
|
## Ox.GetPlayerByFilter
|
||||||
|
|
||||||
Return the first CPlayer that matches the filter properties.
|
Return the first OxPlayer that matches the filter properties.
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='lua' label='Lua'>
|
<TabItem value='lua' label='Lua'>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ sidebar_position: 1
|
|||||||
|
|
||||||
## Ox.GetVehicle
|
## Ox.GetVehicle
|
||||||
|
|
||||||
Return an instance of CVehicle for the given entity.
|
Return an instance of OxVehicle for the given entity.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local vehicle = Ox.GetVehicle(entity)
|
local vehicle = Ox.GetVehicle(entity)
|
||||||
@@ -27,7 +27,7 @@ end
|
|||||||
|
|
||||||
## Ox.CreateVehicle
|
## Ox.CreateVehicle
|
||||||
|
|
||||||
Spawns a vehicle and returns the instance of CVehicle.
|
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.
|
If the first argument is a number, it will attempt to spawn a vehicle from the database with a matching id.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
Reference in new issue
Block a user