Skip to content

Commit

Permalink
feat: delay model update for global objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Jun 13, 2024
1 parent 3c505a0 commit e224efd
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/server/controllers/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,24 @@ export function useObjectGlobal(objectData: iObject) {
}
}

function updateModel(model: number) {
async function updateModel(model: number) {
objectData.model = model;
const newObjectInstance = new alt.Object(
objectData.model,
objectData.pos,
objectData.rot ?? alt.Vector3.zero,
255,
);
newObjectInstance.dimension = objectData.dimension ?? 0;
newObjectInstance.setStreamSyncedMeta('data', objectData.data);

await alt.Utils.wait(1000);

try {
newObject.destroy();
} catch (err) {}

objectData.model = model;
newObject = new alt.Object(objectData.model, objectData.pos, objectData.rot ?? alt.Vector3.zero, 255);
newObject.dimension = objectData.dimension ?? 0;
newObject.setStreamSyncedMeta('data', objectData.data);
newObject = newObjectInstance;
}

function updatePosition(pos: alt.Vector3) {
Expand Down

0 comments on commit e224efd

Please sign in to comment.