altmp / altv-js-module

JS module for alt:V Multiplayer. Powered by NodeJS & v8
MIT License
55 stars 35 forks source link

Emit function sends invalid baseobjects as null values #152

Closed xxshady closed 2 years ago

xxshady commented 2 years ago

Description of the problem

If you try emit invalid baseobject, it will be sent as null value and exception will be thrown for sender: Error: Unable to convert base object to MValue because it was destroyed and is now invalid

Reproduction steps

serverside code

alt.on('test', (entity) => alt.log('received entity:', entity?.constructor.name, entity?.valid));

const veh = new alt.Vehicle('sultan', 0, 0, 0, 0, 0, 0);
veh.destroy();
alt.emit('test', veh);

Expected behaviour

Event should not be sent?

Additional context

No response

Operating system

Windows 11

Version

release/10.1

Scope

shared

LeonMrBonnie commented 2 years ago

And where is the bug here? That is the intended behaviour

xxshady commented 2 years ago

Then it should be documented and the typings fixed, i think

LeonMrBonnie commented 2 years ago

You can add that to the typings if you want.