diff --git a/client/vehicle/index.ts b/client/vehicle/index.ts index 6f500866..d36fae97 100644 --- a/client/vehicle/index.ts +++ b/client/vehicle/index.ts @@ -1,8 +1,6 @@ import { cache, - getVehicleProperties, onServerCallback, - setVehicleProperties, waitFor, } from '@overextended/ox_lib/client'; import { Vector3 } from '@nativewrappers/fivem'; @@ -45,47 +43,3 @@ AddStateBagChangeHandler('initVehicle', '', async (bagName: string, key: string, SetVehicleOnGroundProperly(entity); setTimeout(() => Entity(entity).state.set(key, null, true)); }); - -AddStateBagChangeHandler('vehicleProperties', '', async (bagName: string, key: string, value: any) => { - if (!value) return DEBUG && console.info(`removed ${key} state from ${bagName}`); - - const entity = await waitFor( - async () => { - const entity = GetEntityFromStateBagName(bagName); - DEV: console.info(key, entity); - - if (entity) return entity; - }, - 'failed to get entity from statebag name', - 10000 - ); - - if (!entity) return; - - const status = await new Promise((resolve) => { - let i = 0; - let interval: CitizenTimer; - - interval = setInterval(() => { - i++; - const doesEntityExist = DoesEntityExist(entity); - - if (i % 5) console.info(`Attempting to set ${bagName} on entity ${entity} (${i})`); - - if (i > 100 || !doesEntityExist || !Entity(entity).state[key]) { - resolve(doesEntityExist ? 0 : i > 100 ? 1 : 2); - return clearInterval(interval); - } - - setVehicleProperties(entity, value); - }, 200); - }); - - console.info( - status - ? status === 1 - ? `Failed to set ${bagName} on entity ${entity} (timed out)` - : `Set ${bagName} on entity ${entity}` - : `Failed to set ${bagName} on entity ${entity} (entity does not exist)` - ); -}); diff --git a/common/index.ts b/common/index.ts index 90ac1f47..8c83a608 100644 --- a/common/index.ts +++ b/common/index.ts @@ -1,7 +1,7 @@ import { checkDependency } from '@overextended/ox_lib/'; import type { OxGroupPermissions } from 'types'; -if (!checkDependency('ox_lib', '3.20.0', true)) throw new Error(`Failed dependency check.`); +if (!checkDependency('ox_lib', '3.24.0', true)) throw new Error(`Failed dependency check.`); export function LoadDataFile(file: string) { return JSON.parse(LoadResourceFile('ox_core', `/common/data/${file}.json`)); diff --git a/package.json b/package.json index d1fe3cf8..b1162814 100644 --- a/package.json +++ b/package.json @@ -34,15 +34,15 @@ "devDependencies": { "@citizenfx/client": "latest", "@citizenfx/server": "latest", - "@types/node": "^20.14.2", + "@types/node": "^20.14.10", "esbuild": "^0.20.2", - "prettier": "^3.3.1", + "prettier": "^3.3.3", "tsc-alias": "^1.8.10", - "typescript": "^5.4.5" + "typescript": "^5.5.3" }, "dependencies": { "@nativewrappers/fivem": "^0.0.28", - "@overextended/ox_lib": "^3.22.2", + "@overextended/ox_lib": "^3.24.0", "mariadb": "^3.3.1" }, "engines": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 881ed808..c7605648 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,41 +12,41 @@ importers: specifier: ^0.0.28 version: 0.0.28 '@overextended/ox_lib': - specifier: ^3.22.2 - version: 3.22.2 + specifier: ^3.24.0 + version: 3.24.0 mariadb: specifier: ^3.3.1 version: 3.3.1 devDependencies: '@citizenfx/client': specifier: latest - version: 2.0.8450-1 + version: 2.0.8903-1 '@citizenfx/server': specifier: latest - version: 2.0.8450-1 + version: 2.0.8903-1 '@types/node': - specifier: ^20.14.2 - version: 20.14.2 + specifier: ^20.14.10 + version: 20.14.10 esbuild: specifier: ^0.20.2 version: 0.20.2 prettier: - specifier: ^3.3.1 - version: 3.3.1 + specifier: ^3.3.3 + version: 3.3.3 tsc-alias: specifier: ^1.8.10 version: 1.8.10 typescript: - specifier: ^5.4.5 - version: 5.4.5 + specifier: ^5.5.3 + version: 5.5.3 packages: - '@citizenfx/client@2.0.8450-1': - resolution: {integrity: sha512-km4/FS5JImB2cPxASVd0b3Ogr90EvUS+5IInYx/AIL/8BfOh0LJZsuu1SG/S3AV25dSfOmMVDSZ/iv4sNDwjGg==} + '@citizenfx/client@2.0.8903-1': + resolution: {integrity: sha512-w5EEpYiX9w8Znm5+95El8GyFjN43B9X0WI/x0D7lKidKIk2bvm3LatIh9ThWJWyk0m1m1NgAMba8TfR5ranOHg==} - '@citizenfx/server@2.0.8450-1': - resolution: {integrity: sha512-ZtTfzi/zmryWFLkZMXSyC4/a+OypFY9SXJBQtJRFbqnivRYmRRxxMrlJfACULp+7uDsd2ElWjYNrs7M0HtPPwQ==} + '@citizenfx/server@2.0.8903-1': + resolution: {integrity: sha512-08COhAwTkhNgoBbpdZ694ZAO2ffFswIUPXFuico5CusFqVdS48RC3i90iCYf+BW2Ew/b/vlvMq0Q7AotALKOIg==} '@esbuild/aix-ppc64@0.20.2': resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==} @@ -204,14 +204,14 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@overextended/ox_lib@3.22.2': - resolution: {integrity: sha512-DApBDrsHYlyiFpDG83d0AdzjerzHpGvo5ECraPcW5vNDlaiJ9O8SnIHwcxv2EzE+E4oUhZ2Nng5f0DcfPFb3UQ==} + '@overextended/ox_lib@3.24.0': + resolution: {integrity: sha512-diI+hvmGfDBoYzuFeKrVLrdXff1yYIgARNP22i8oQqrzlBig46HJMXm7YRmwsE+8Z/w6TwQv9UL9j/vzVGpnnQ==} '@types/geojson@7946.0.14': resolution: {integrity: sha512-WCfD5Ht3ZesJUsONdhvm84dmzWOiOzOAqOncN0++w0lBw1o8OuDNJF2McvvCef/yBqb/HYRahp1BYtODFQ8bRg==} - '@types/node@20.14.2': - resolution: {integrity: sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==} + '@types/node@20.14.10': + resolution: {integrity: sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==} anymatch@3.1.3: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} @@ -308,9 +308,8 @@ packages: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} - lru-cache@10.2.2: - resolution: {integrity: sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==} - engines: {node: 14 || >=16.14} + lru-cache@10.4.3: + resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} mariadb@3.3.1: resolution: {integrity: sha512-L8bh4iuZU3J8H7Co7rQ6OY9FDLItAN1rGy8kPA7Dyxo8AiHADuuONoypKKp1pE09drs6e5LR7UW9luLZ/A4znA==} @@ -344,8 +343,8 @@ packages: resolution: {integrity: sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==} engines: {node: '>=12'} - prettier@3.3.1: - resolution: {integrity: sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==} + prettier@3.3.3: + resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==} engines: {node: '>=14'} hasBin: true @@ -382,8 +381,8 @@ packages: resolution: {integrity: sha512-Ibv4KAWfFkFdKJxnWfVtdOmB0Zi1RJVxcbPGiCDsFpCQSsmpWyuzHG3rQyI5YkobWwxFPEyQfu1hdo4qLG2zPw==} hasBin: true - typescript@5.4.5: - resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} + typescript@5.5.3: + resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==} engines: {node: '>=14.17'} hasBin: true @@ -392,9 +391,9 @@ packages: snapshots: - '@citizenfx/client@2.0.8450-1': {} + '@citizenfx/client@2.0.8903-1': {} - '@citizenfx/server@2.0.8450-1': {} + '@citizenfx/server@2.0.8903-1': {} '@esbuild/aix-ppc64@0.20.2': optional: true @@ -481,16 +480,16 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 - '@overextended/ox_lib@3.22.2': + '@overextended/ox_lib@3.24.0': dependencies: '@nativewrappers/client': 1.7.33 csstype: 3.1.3 fast-printf: 1.6.9 - typescript: 5.4.5 + typescript: 5.5.3 '@types/geojson@7946.0.14': {} - '@types/node@20.14.2': + '@types/node@20.14.10': dependencies: undici-types: 5.26.5 @@ -611,15 +610,15 @@ snapshots: is-number@7.0.0: {} - lru-cache@10.2.2: {} + lru-cache@10.4.3: {} mariadb@3.3.1: dependencies: '@types/geojson': 7946.0.14 - '@types/node': 20.14.2 + '@types/node': 20.14.10 denque: 2.1.0 iconv-lite: 0.6.3 - lru-cache: 10.2.2 + lru-cache: 10.4.3 merge2@1.4.1: {} @@ -640,7 +639,7 @@ snapshots: dependencies: queue-lit: 1.5.2 - prettier@3.3.1: {} + prettier@3.3.3: {} queue-lit@1.5.2: {} @@ -673,6 +672,6 @@ snapshots: normalize-path: 3.0.0 plimit-lit: 1.6.1 - typescript@5.4.5: {} + typescript@5.5.3: {} undici-types@5.26.5: {} diff --git a/server/vehicle/index.ts b/server/vehicle/index.ts index ce3a2b27..48c0c18c 100644 --- a/server/vehicle/index.ts +++ b/server/vehicle/index.ts @@ -2,11 +2,10 @@ import { OxVehicle } from './class'; import { CreateNewVehicle, GetStoredVehicleFromId, IsPlateAvailable, VehicleRow } from './db'; import { GetVehicleData } from '../../common/vehicles'; import { DEBUG } from '../../common/config'; - import './class'; import './commands'; import './events'; -import { VehicleProperties } from '@overextended/ox_lib'; +import { VehicleProperties, setVehicleProperties } from '@overextended/ox_lib/server'; import { VectorFromBuffer } from '../../common'; if (DEBUG) import('./parser'); @@ -121,19 +120,7 @@ export async function CreateVehicle( const state = vehicle.getState(); state.set('initVehicle', true, true); - state.set('vehicleProperties', metadata.properties, true); - - let interval: CitizenTimer; - - interval = setInterval(() => { - if (GetVehicleNumberPlateText(entity) !== '') { - console.log(`Set vehicleProperties for entity ${entity}`); - state.set('vehicleProperties', null, true); - return clearInterval(interval); - } - - if (!DoesEntityExist(entity)) clearInterval(interval); - }, 200); + setVehicleProperties(entity, metadata.properties) return vehicle; }