ox_core: Player tweaks, and docs for accounts

This commit is contained in:
Linden committed 2022-07-27 20:16:30 +10:00
1 parent 7f99ef97e1
commit d21e19e9a3
4 files changed
+133 -28

No files matched your search

+51 -18
View File
@@ -7,21 +7,22 @@ import TabItem from '@theme/TabItem';
These functions are inherited by instances of CPlayer.
<Tabs>
<TabItem value='lua' label='Lua'>
```lua
local player = Ox.GetPlayer(source)
```
</TabItem>
<TabItem value='js/ts' label='JS/TS'>
```ts
import { GetPlayer } from '@overextended/ox_core/server'
import { GetPlayer } from '@overextended/ox_core/server';
const player = GetPlayer(source)
const player = GetPlayer(source);
```
</TabItem>
</Tabs>
@@ -29,7 +30,6 @@ const player = GetPlayer(source)
Sets the player's metadata for key to the given value.
<Tabs>
<TabItem value='lua' label='Lua'>
@@ -37,17 +37,18 @@ Sets the player's metadata for key to the given value.
local key, value = 'iq', 300
player.set(key, value)
```
</TabItem>
<TabItem value='js/ts' label='JS/TS'>
```ts
const [key, value] = ['iq', 300]
player.set(key, value)
const [key, value] = ['iq', 300];
player.set(key, value);
```
</TabItem>
</Tabs>
## player.get
Return the player's metadata. Sending an argument will retrieve a specific metadata key.
@@ -59,13 +60,36 @@ Return the player's metadata. Sending an argument will retrieve a specific metad
local data = player.get()
local iq = player.get('iq')
```
</TabItem>
<TabItem value='js/ts' label='JS/TS'>
```ts
const data = player.get()
const iq = player.get('iq')
const data = player.get();
const iq = player.get('iq');
```
</TabItem>
</Tabs>
## player.getAccounts
Returns an instance of [CAccount](../../Accounts) for the player.
<Tabs>
<TabItem value='lua' label='Lua'>
```lua
player.getAccounts()
```
</TabItem>
<TabItem value='js/ts' label='JS/TS'>
```ts
player.getAccounts()
```
</TabItem>
</Tabs>
@@ -79,18 +103,20 @@ Return the player's world position. The value will be cached for future calls, s
```lua
local coords = player.getCoords(update)
```
</TabItem>
<TabItem value='js/ts' label='JS/TS'>
```ts
const coords = player.getCoords(update)
const coords = player.getCoords(update);
```
</TabItem>
</Tabs>
## player.setGroup
Updates the player's grade for the given group. A value of 0 will remove the player
Updates the player's grade for the given group. Any value below 1 will remove the group from the player.
<Tabs>
<TabItem value='lua' label='Lua'>
@@ -99,13 +125,15 @@ Updates the player's grade for the given group. A value of 0 will remove the pla
local group, grade = 'police', 3
player.setGroup(group, grade)
```
</TabItem>
<TabItem value='js/ts' label='JS/TS'>
```ts
const [group, grade] = ['police', 3]
player.setGroup(group, grade)
const [group, grade] = ['police', 3];
player.setGroup(group, grade);
```
</TabItem>
</Tabs>
@@ -121,13 +149,15 @@ The filter can be a string, array, or object where key is the group, and value i
local filter = { police = 0, sheriff = 0 }
local group, grade = player.hasGroup(filter)
```
</TabItem>
<TabItem value='js/ts' label='JS/TS'>
```ts
const filter = { police: 0, sheriff: 0 }
const [group, grade] = player.hasGroup(filter)
const filter = { police: 0, sheriff: 0 };
const [group, grade] = player.hasGroup(filter);
```
</TabItem>
</Tabs>
@@ -142,13 +172,15 @@ Check if the given source is inside the player's scope.
local target = 2
local inScope = player.isPlayerInScope(target)
```
</TabItem>
<TabItem value='js/ts' label='JS/TS'>
```ts
const target = 2
const inScope = player.isPlayerInScope(target)
const target = 2;
const inScope = player.isPlayerInScope(target);
```
</TabItem>
</Tabs>
@@ -162,12 +194,13 @@ Trigger a client event for all players in the player's scope.
```lua
player.triggerScopedEvent(eventName, ...)
```
</TabItem>
<TabItem value='js/ts' label='JS/TS'>
```ts
player.triggerScopedEvent(eventName, ...)
```
</TabItem>
</Tabs>