Skip to content

Commit

Permalink
fix(lib/client): default groups object
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Mar 1, 2024
1 parent a813e17 commit f1e2683
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/client/player.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/client/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number> = {};
let groups: Dict<number>;

class PlayerInterface {
[key: string]: any;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f1e2683

Please sign in to comment.