From b4f2b497ac33f02fff95e8bcb0a43fcda024caaf Mon Sep 17 00:00:00 2001 From: Yiin Date: Sun, 18 Feb 2024 05:15:39 +0200 Subject: [PATCH] upgrade for altv 16 & jsv2 support --- .../core-commands/server/commands/moderator/noclip.ts | 4 ++-- src/core/server/events/waypointEvent.ts | 2 +- src/core/server/player/safe.ts | 2 +- src/core/server/player/setter.ts | 2 +- src/core/server/player/sync.ts | 4 ++-- src/core/server/systems/character.ts | 8 ++++---- src/core/server/systems/identifier.ts | 2 +- src/core/server/systems/inventory/config.ts | 4 ++-- src/core/server/systems/inventory/manager.ts | 2 +- src/core/server/systems/tick.ts | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/core/plugins/core-commands/server/commands/moderator/noclip.ts b/src/core/plugins/core-commands/server/commands/moderator/noclip.ts index 51da85891a..2967b30bd7 100644 --- a/src/core/plugins/core-commands/server/commands/moderator/noclip.ts +++ b/src/core/plugins/core-commands/server/commands/moderator/noclip.ts @@ -13,7 +13,7 @@ Athena.commands.register('noclip', '/noclip', ['admin'], (player: alt.Player) => } if (!isNoClipping && !data.isDead) { - player.setSyncedMeta('NoClipping', true); + player.setStreamSyncedMeta('NoClipping', true); Athena.player.emit.message(player, `No Clip: ${LocaleController.get(LOCALE_KEYS.LABEL_ON)}`); player.visible = false; return; @@ -24,7 +24,7 @@ Athena.commands.register('noclip', '/noclip', ['admin'], (player: alt.Player) => } player.spawn(player.pos.x, player.pos.y, player.pos.z, 0); - player.setSyncedMeta('NoClipping', false); + player.setStreamSyncedMeta('NoClipping', false); Athena.player.emit.message(player, `No Clip: ${LocaleController.get(LOCALE_KEYS.LABEL_OFF)}`); player.visible = true; player.health = 199; diff --git a/src/core/server/events/waypointEvent.ts b/src/core/server/events/waypointEvent.ts index ac71b5febf..7813d87dae 100644 --- a/src/core/server/events/waypointEvent.ts +++ b/src/core/server/events/waypointEvent.ts @@ -9,6 +9,6 @@ alt.onClient(ATHENA_EVENTS_PLAYER_CLIENT.WAYPOINT, (player: alt.Player, pos: alt } player.currentWaypoint = pos; - player.setSyncedMeta(PLAYER_SYNCED_META.WAYPOINT, pos); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.WAYPOINT, pos); ClientEvents.trigger(ATHENA_EVENTS_PLAYER_CLIENT.WAYPOINT, player, pos); }); diff --git a/src/core/server/player/safe.ts b/src/core/server/player/safe.ts index 08dc2396cf..b0a5e483e0 100644 --- a/src/core/server/player/safe.ts +++ b/src/core/server/player/safe.ts @@ -179,7 +179,7 @@ export function setDimension(player: alt.Player, value: number) { } player.dimension = value; - player.setSyncedMeta(PLAYER_SYNCED_META.DIMENSION, value); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.DIMENSION, value); } interface SafeFunctions { diff --git a/src/core/server/player/setter.ts b/src/core/server/player/setter.ts index a2eaf5502d..50fe835de2 100644 --- a/src/core/server/player/setter.ts +++ b/src/core/server/player/setter.ts @@ -25,7 +25,7 @@ export async function account(player: alt.Player, accountData: Account): Promise const newToken = await Athena.systems.jwt.create(accountData as Account); alt.emitClient(player, SYSTEM_EVENTS.QUICK_TOKEN_UPDATE, newToken); - player.setSyncedMeta(PLAYER_SYNCED_META.ACCOUNT_ID, accountData.id); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.ACCOUNT_ID, accountData.id); emit.meta(player, 'permissions', accountData.permissions); Athena.document.account.bind(player, accountData); diff --git a/src/core/server/player/sync.ts b/src/core/server/player/sync.ts index 79bdd46786..21835d7e18 100644 --- a/src/core/server/player/sync.ts +++ b/src/core/server/player/sync.ts @@ -146,8 +146,8 @@ export function syncedMeta(player: alt.Player): void { return Overrides.syncedMeta(player); } - player.setSyncedMeta(PLAYER_SYNCED_META.PING, player.ping); - player.setSyncedMeta(PLAYER_SYNCED_META.POSITION, player.pos); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.PING, player.ping); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.POSITION, player.pos); } export function playTime(player: alt.Player): void { diff --git a/src/core/server/systems/character.ts b/src/core/server/systems/character.ts index 4715726e94..6d51acaa89 100644 --- a/src/core/server/systems/character.ts +++ b/src/core/server/systems/character.ts @@ -181,10 +181,10 @@ export async function select(player: alt.Player, character: Character) { // Synchronization Athena.player.sync.currencyData(player); - player.setSyncedMeta(PLAYER_SYNCED_META.NAME, data.name); - player.setSyncedMeta(PLAYER_SYNCED_META.PING, player.ping); - player.setSyncedMeta(PLAYER_SYNCED_META.POSITION, player.pos); - player.setSyncedMeta(PLAYER_SYNCED_META.DATABASE_ID, data._id.toString()); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.NAME, data.name); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.PING, player.ping); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.POSITION, player.pos); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.DATABASE_ID, data._id.toString()); // Propagation // Athena.controllers.chat.populateCommands(player); diff --git a/src/core/server/systems/identifier.ts b/src/core/server/systems/identifier.ts index d294dcefbf..8fa221b6bd 100644 --- a/src/core/server/systems/identifier.ts +++ b/src/core/server/systems/identifier.ts @@ -51,7 +51,7 @@ export function setPlayerIdentifier(player: alt.Player) { throw new Error(`Could not set identifier for player: ${player.id}, data was not defined.`); } - player.setSyncedMeta(PLAYER_SYNCED_META.IDENTIFICATION_ID, identifier); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.IDENTIFICATION_ID, identifier); } /** diff --git a/src/core/server/systems/inventory/config.ts b/src/core/server/systems/inventory/config.ts index 819bc5057f..64820e5e43 100644 --- a/src/core/server/systems/inventory/config.ts +++ b/src/core/server/systems/inventory/config.ts @@ -31,7 +31,7 @@ let DEFAULT_CONFIG = { */ export function set(config: typeof DEFAULT_CONFIG) { DEFAULT_CONFIG = Object.assign(DEFAULT_CONFIG, config); - alt.setSyncedMeta(GLOBAL_SYNCED.INVENTORY_WEIGHT_ENABLED, DEFAULT_CONFIG.weight.enabled); + alt.setMeta(GLOBAL_SYNCED.INVENTORY_WEIGHT_ENABLED, DEFAULT_CONFIG.weight.enabled); } /** @@ -48,5 +48,5 @@ export function get(): typeof DEFAULT_CONFIG { */ export function disableWeight() { DEFAULT_CONFIG.weight.enabled = false; - alt.setSyncedMeta(GLOBAL_SYNCED.INVENTORY_WEIGHT_ENABLED, false); + alt.setMeta(GLOBAL_SYNCED.INVENTORY_WEIGHT_ENABLED, false); } diff --git a/src/core/server/systems/inventory/manager.ts b/src/core/server/systems/inventory/manager.ts index 2a95d8045e..0f16f9f966 100644 --- a/src/core/server/systems/inventory/manager.ts +++ b/src/core/server/systems/inventory/manager.ts @@ -4,7 +4,7 @@ import { BaseItem, StoredItem, Item, DefaultItemBehavior } from '@AthenaShared/i import { deepCloneArray, deepCloneObject } from '@AthenaShared/utility/deepCopy.js'; import { GLOBAL_SYNCED } from '@AthenaShared/enums/globalSynced.js'; -alt.setSyncedMeta(GLOBAL_SYNCED.INVENTORY_WEIGHT_ENABLED, true); +alt.setMeta(GLOBAL_SYNCED.INVENTORY_WEIGHT_ENABLED, true); export interface ItemQuantityChange { /** diff --git a/src/core/server/systems/tick.ts b/src/core/server/systems/tick.ts index 5a9d53f54a..a102a2ca95 100644 --- a/src/core/server/systems/tick.ts +++ b/src/core/server/systems/tick.ts @@ -74,8 +74,8 @@ function handlePing(player: alt.Player): void { return; } - player.setSyncedMeta(PLAYER_SYNCED_META.PING, player.ping); - player.setSyncedMeta(PLAYER_SYNCED_META.POSITION, player.pos); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.PING, player.ping); + player.setStreamSyncedMeta(PLAYER_SYNCED_META.POSITION, player.pos); player.nextPingTime = Date.now() + timeBetweenPings; // Handles General Saving / Synchronization