mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 14:38:50 +00:00
ox_core: Ox.GetPlayerByFilter
This commit is contained in:
1 parent
3aee4976c3
commit
a3f1e8a419
1 file changed
+26
-1
@@ -30,6 +30,32 @@ console.log(JSON.stringify(player));
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
## Ox.GetPlayerByFilter
|
||||||
|
|
||||||
|
Return the first CPlayer that matches the filter properties.
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='lua' label='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local filter = { phoneNumber = '556-560-6609' }
|
||||||
|
local player = Ox.GetPlayerByFilter(source, filter)
|
||||||
|
print(json.encode(player, { indent = true }))
|
||||||
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='js/ts' label='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { GetPlayerByFilter } from '@overextended/ox_core/server';
|
||||||
|
|
||||||
|
const filter = { phoneNumber: '556-560-6609' };
|
||||||
|
const player = GetPlayerByFilter(source);
|
||||||
|
console.log(JSON.stringify(player));
|
||||||
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
## Ox.GetPlayers
|
## Ox.GetPlayers
|
||||||
|
|
||||||
Returns an array containing all players. Methods will not be applied if the first argument is false.
|
Returns an array containing all players. Methods will not be applied if the first argument is false.
|
||||||
@@ -41,7 +67,6 @@ Players can be filtered to only return players that match the given properties,
|
|||||||
```lua
|
```lua
|
||||||
-- Get an array containing all players in the police or sheriff groups, with grade 3 or higher.
|
-- Get an array containing all players in the police or sheriff groups, with grade 3 or higher.
|
||||||
local filter = { groups = {['sheriff'] = 3, ['police'] = 3} })
|
local filter = { groups = {['sheriff'] = 3, ['police'] = 3} })
|
||||||
|
|
||||||
local players = Ox.GetPlayers(usemetatable, filter)
|
local players = Ox.GetPlayers(usemetatable, filter)
|
||||||
|
|
||||||
for i = 1, #players do
|
for i = 1, #players do
|
||||||
|
|||||||
Reference in new issue
Block a user