ox_core: Ox.GetPlayerByFilter

This commit is contained in:
Linden committed 2022-09-18 17:10:24 +10:00
1 parent 3aee4976c3
commit a3f1e8a419
1 file changed
+26 -1
+26 -1
View File
@@ -30,6 +30,32 @@ console.log(JSON.stringify(player));
</TabItem>
</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
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
-- 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 players = Ox.GetPlayers(usemetatable, filter)
for i = 1, #players do