mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 06:28:54 +00:00
add js/ts versions of methods
This commit is contained in:
1 parent
26e93458ef
commit
aeb90c297f
4 files changed
+162
-1
No files matched your search
@@ -3,19 +3,39 @@ title: Server
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
## Ox.GetPlayer
|
||||
|
||||
Return an instance of CPlayer for the given player source.
|
||||
<Tabs>
|
||||
<TabItem value='lua' label='Lua'>
|
||||
|
||||
```lua
|
||||
local player = Ox.GetPlayer(source)
|
||||
print(json.encode(player, { indent = true }))
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='js/ts' label='JS/TS'>
|
||||
|
||||
```ts
|
||||
import { GetPlayer } from '@overextended/ox_core/server'
|
||||
|
||||
const player = GetPlayer(source)
|
||||
console.log(JSON.stringify(player, null, 2))
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
## Ox.GetPlayers
|
||||
|
||||
Returns an array containing all players. Methods will not be applied if the first argument is false.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='lua' label='Lua'>
|
||||
|
||||
```lua
|
||||
local players = Ox.GetPlayers(usemetatable)
|
||||
|
||||
@@ -24,3 +44,17 @@ for i = 1, #players do
|
||||
print(json.encode(player, { indent = true }))
|
||||
end
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='js/ts' label='JS/TS'>
|
||||
|
||||
```ts
|
||||
import { GetPlayers } from '@overextended/ox_core/server'
|
||||
|
||||
const players = GetPlayers()
|
||||
for (let i = 0; i < players.length; i++) {
|
||||
const player = players[i]
|
||||
console.log(JSON.stringify(player, null, 2))
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
Reference in new issue
Block a user