Skip to content

Commit

Permalink
refactor(lib): type updates and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Feb 21, 2024
1 parent 07cdcd5 commit 6ba40fb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
11 changes: 4 additions & 7 deletions lib/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
interface OxClient {
[exportKey: string]: Function;
IsPlayerLoaded(): boolean;
GetPlayerData(): { userId: number; charId: number; stateId: string };
GetPlayerData(key: string): any;
}
import { OxCore, OxCommon } from 'lib';

export const Ox: OxClient = exports.ox_core as any;
interface OxClient extends OxCommon {}

export const Ox = OxCore as OxClient;

export * from './player';
9 changes: 9 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { GetTopVehicleStats, GetVehicleData } from 'common/vehicles';

export interface OxCommon {
[key: string]: (...args: any[]) => any;
GetTopVehicleStats: typeof GetTopVehicleStats;
GetVehicleData: typeof GetVehicleData;
}

export const OxCore = exports.ox_core as OxCommon;
12 changes: 3 additions & 9 deletions lib/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import type {
SetAccountAccess,
} from 'server/accounts';
import type { OxPlayer } from 'server/player/class';
import type { CreateVehicle, SpawnVehicle } from 'server/vehicle';
import type { GetTopVehicleStats, GetVehicleData } from 'common/vehicles';
import type { GetCharIdFromStateId } from 'server/player/db';
import type { DeleteAccount, DepositMoney, WithdrawMoney } from 'server/accounts/db';
import { OxCore, OxCommon } from 'lib';

interface OxServer {
[exportKey: string]: Function;
interface OxServer extends OxCommon {
GetAccountById: typeof GetAccountById;
GetCharacterAccount: typeof GetCharacterAccount;
GetGroupAccount: typeof GetGroupAccount;
Expand All @@ -40,14 +38,10 @@ interface OxServer {
RemoveAccountAccess: typeof RemoveAccountAccess;
SaveAllPlayers: typeof OxPlayer.saveAll;
SaveAllVehicles: typeof OxVehicle.saveAll;
CreateVehicle: typeof CreateVehicle;
SpawnVehicle: typeof SpawnVehicle;
GetTopVehicleStats: typeof GetTopVehicleStats;
GetVehicleData: typeof GetVehicleData;
GetCharIdFromStateId: typeof GetCharIdFromStateId;
}

export const Ox: OxServer = exports.ox_core as any;
export const Ox = OxCore as OxServer;

export * from './player';
export * from './vehicle';
2 changes: 1 addition & 1 deletion lib/server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function OxPlayer:getCoords()
end

function OxPlayer:getState()
return Player(source).state;
return Player(self.source).state;
end

for method in pairs(exports.ox_core:GetPlayerCalls() or {}) do
Expand Down

0 comments on commit 6ba40fb

Please sign in to comment.