diff --git a/lib/client/index.ts b/lib/client/index.ts index 8bf96d98..0e8a0fba 100644 --- a/lib/client/index.ts +++ b/lib/client/index.ts @@ -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'; diff --git a/lib/index.ts b/lib/index.ts new file mode 100644 index 00000000..9282777f --- /dev/null +++ b/lib/index.ts @@ -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; diff --git a/lib/server/index.ts b/lib/server/index.ts index df42af42..d200dde6 100644 --- a/lib/server/index.ts +++ b/lib/server/index.ts @@ -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; @@ -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'; diff --git a/lib/server/player.lua b/lib/server/player.lua index bb082b98..d76a6bf4 100644 --- a/lib/server/player.lua +++ b/lib/server/player.lua @@ -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