mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 14:38:50 +00:00
ox_core/player/server docs
This commit is contained in:
1 parent
4522a76f69
commit
355d7eb052
2 files changed
+93
No files matched your search
@@ -2,3 +2,25 @@
|
|||||||
title: Server
|
title: Server
|
||||||
sidebar_position: 1
|
sidebar_position: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Ox.GetPlayer
|
||||||
|
|
||||||
|
Return an instance of CPlayer for the given player source.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local player = Ox.GetPlayer(source)
|
||||||
|
print(json.encode(player, { indent = true }))
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ox.GetPlayers
|
||||||
|
|
||||||
|
Returns an array containing all players. Methods will not be applied if the first argument is false.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local players = Ox.GetPlayers(usemetatable)
|
||||||
|
|
||||||
|
for i = 1, #players do
|
||||||
|
local player = players[i]
|
||||||
|
print(json.encode(player, { indent = true }))
|
||||||
|
end
|
||||||
|
```
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
---
|
||||||
|
title: Methods
|
||||||
|
---
|
||||||
|
|
||||||
|
These functions are inherited by instances of CPlayer.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local player = Ox.GetPlayer(source)
|
||||||
|
```
|
||||||
|
|
||||||
|
## player.set
|
||||||
|
|
||||||
|
Sets the player's metadata for key to the given value.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local key, value = 'iq', 300
|
||||||
|
player.set(key, value)
|
||||||
|
```
|
||||||
|
|
||||||
|
## player.get
|
||||||
|
|
||||||
|
Return the player's metadata. Sending an argument will retrieve a specific metadata key.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local data = player.get()
|
||||||
|
local iq = player.get('iq')
|
||||||
|
```
|
||||||
|
|
||||||
|
## player.getCoords
|
||||||
|
|
||||||
|
Return the player's world position. The value will be cached for future calls, so send true for the first argument to update it.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local coords = player.getCoords(update)
|
||||||
|
```
|
||||||
|
|
||||||
|
## player.setGroup
|
||||||
|
|
||||||
|
Updates the player's grade for the given group. A value of 0 will remove the player
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local group, grade = 'police', 3
|
||||||
|
player.setGroup(group, grade)
|
||||||
|
```
|
||||||
|
|
||||||
|
## player.hasGroup
|
||||||
|
|
||||||
|
Check if the player is a member of a given group, and returns the matching group name and grade.
|
||||||
|
The filter can be a string, array, or object where key is the group, and value is the minimum grade.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local filter = { police = 0, sheriff = 0 }
|
||||||
|
local group, grade = player.hasGroup(filter)
|
||||||
|
```
|
||||||
|
|
||||||
|
## player.isPlayerInScope
|
||||||
|
|
||||||
|
Check if the given source is inside the player's scope.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local target = 2
|
||||||
|
local inScope = player.isPlayerInScope(target)
|
||||||
|
```
|
||||||
|
|
||||||
|
## player.triggerScopedEvent
|
||||||
|
|
||||||
|
Trigger a client event for all players in the player's scope.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
player.triggerScopedEvent(eventName, ...)
|
||||||
|
```
|
||||||
Reference in new issue
Block a user