From d4bfd2623d98d772da9231ae7d379a098d5be5b8 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sun, 27 Nov 2022 04:04:57 +1100 Subject: [PATCH] update ox_core player methods --- docs/ox_core/Player/Server/methods.md | 192 +++++--------------------- 1 file changed, 32 insertions(+), 160 deletions(-) diff --git a/docs/ox_core/Player/Server/methods.md b/docs/ox_core/Player/Server/methods.md index 36606e06..3f67615e 100644 --- a/docs/ox_core/Player/Server/methods.md +++ b/docs/ox_core/Player/Server/methods.md @@ -11,242 +11,114 @@ These functions are inherited by instances of [CPlayer](../Server/). Update the player's metadata, optionally syncing it with the client. - - - ```lua -local key, value = 'iq', 300 -player.set(key, value) +player.set(key, value, replicated) ``` - - - -```ts -const [key, value] = ['iq', 300]; -player.set(key, value); -``` - - - +- key: `string` +- value: `any` +- replicated?: `boolean` ## player.setdb -Update the player's metadata and store in the DB, optionally syncing it with the client. - - - +Update the player's metadata and store in the DB, optionally syncing it with the client. +Note: These values are not synced to the client on login; you will need to use `player.set`. ```lua -local key, value = 'iq', 300 -player.setdb(key, value) +player.setdb(key, value, replicated) ``` - - - -```ts -const [key, value] = ['iq', 300]; -player.setdb(key, value); -``` - - - +- key: `string` +- value: `string | number | table | boolean` +- replicated?: `boolean` ## player.get -Return the player's metadata. Sending an argument will retrieve a specific metadata key. - - - +Get a value from the player's metadata, or omit the argument to get all metadata. ```lua -local data = player.get() -local iq = player.get('iq') +player.get(key) ``` - - +- key?: `string` -```ts -const data = player.get(); -const iq = player.get('iq'); +## player.getState + +Return the player's statebag. + +```lua +player.getState() ``` - - - ## player.getCoords -Return the player's world position. - - - +Return the player's position. ```lua -local coords = player.getCoords() +player.getCoords() ``` - - - -```ts -const coords = player.getCoords(); -``` - - - - ## player.setGroup Updates the player's grade for the given group. Any value below 1 will remove the group from the player. - - - ```lua -local group, grade = 'police', 3 player.setGroup(group, grade) ``` - - - -```ts -const [group, grade] = ['police', 3]; -player.setGroup(group, grade); -``` - - - +- group: `string` +- grade?: `number` ## player.getGroup Returns the player's current grade for a given group. - - - ```lua -local grade = player.getGroup() +player.getGroup() ``` - - - -```ts -const grade = player.getGroup(); -``` - - - - ## player.getGroup Returns an object of all groups the player is in, with the current grade as the value. - - - ```lua -local groups = player.getGroups() +player.getGroups() ``` - - - -```ts -const groups = player.getGroups(); -``` - - - - ## 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.hasGroup(filter) ``` - - - -```ts -const filter = { police: 0, sheriff: 0 }; -const [group, grade] = player.hasGroup(filter); -``` - - - +- filter: `string | string[] | { [string]: number }` ## player.getPlayersInScope Return an array of all player id's inside the player's scope. - - - ```lua -local inScope = player.getPlayersInScope() +player.getPlayersInScope() ``` - - - -```ts -const inScope = player.getPlayersInScope(); -``` - - - - ## player.isPlayerInScope Check if the given source is inside the player's scope. - - - ```lua -local target = 2 -local inScope = player.isPlayerInScope(target) +player.isPlayerInScope(target) ``` - - - -```ts -const target = 2; -const inScope = player.isPlayerInScope(target); -``` - - - +- target: `number` ## player.triggerScopedEvent -Trigger a client event for all players in the player's scope. - - - - ```lua player.triggerScopedEvent(eventName, ...) ``` - - - -```ts -player.triggerScopedEvent(eventName, ...) -``` - - - +- eventName: `string` +- ...?: `any[]`