diff --git a/lib/client/player.lua b/lib/client/player.lua index db98da42..aae7f1f4 100644 --- a/lib/client/player.lua +++ b/lib/client/player.lua @@ -1,5 +1,5 @@ local OxPlayer = lib.class('OxPlayer') -local groups = {} +local groups -- Support for `player.method` rather than self (:) syntax function OxPlayer:__index(index) @@ -43,7 +43,7 @@ function OxPlayer:get(key) end) getters[key] = true - self[key] = exports.ox_core:CallPlayer('get', key); + self[key] = self:__call('get', key); end return self[key] @@ -96,6 +96,7 @@ end local Ox = Ox local ok, resp = pcall(function() return exports.ox_core.GetPlayer() end) local player = OxPlayer:new(ok and resp or {}) +groups = player.charId and OxPlayer:__call('getGroups') or {} function Ox.GetPlayer() return player diff --git a/lib/client/player.ts b/lib/client/player.ts index 27b4ba25..ec953ffb 100644 --- a/lib/client/player.ts +++ b/lib/client/player.ts @@ -2,7 +2,7 @@ import { cache } from '@overextended/ox_lib/client'; import type { OxPlayer } from 'client/player'; import type { Dict } from 'types'; -const groups: Dict = {}; +let groups: Dict; class PlayerInterface { [key: string]: any; @@ -96,6 +96,7 @@ const { userId, charId, stateId } = ((): { userId: number; charId?: number; stat })(); const player = new PlayerInterface(userId, charId, stateId) as typeof OxPlayer & PlayerInterface; +groups = player.charId ? exports.ox_core.CallPlayer('getGroups') : {}; export function GetPlayer() { return player;