altmp / altv-issues

Issues and roadmap for alt:V project
93 stars 17 forks source link

metaChange event its not called serverside #2323

Open S0P4 opened 4 weeks ago

S0P4 commented 4 weeks ago

Description of the problem

metaChange event its not called serverside

Reproduction steps

import * as alt from "alt-server";

alt.on("metaChange", (entity, key, newValue, oldValue) => {
  alt.log(`meta change: ${key} ${newValue} ${oldValue}`);
});

alt.onClient("testme", player => {
  player .setMeta("meta", Date.now());
  alt.log(player.setMeta("meta"));
})

Expected behaviour

The event metaChange should be called when changing meta.

Additional context

No response

Operating system

Windows 11

Version

16.2.1-dev.1

Crashdump ID

No response

Confirmation of issue's presence

BluePeer commented 4 weeks ago

player .setMeta("meta", new Date()); <--- issue wrong alt.log(player.setMeta("meta")); <-- issue wrong

xxshady commented 4 weeks ago

as bluepeer said, did try other value type? Date is not supported outside of raw emits

BluePeer commented 4 weeks ago

But in general a serverside set meta does not call a metachange event on set on player (release too)

edit: example qa-tools player is the emit player eq

// server file
function logmeta(entity,key,nvalue,ovalue) {
alt.log("Change " + entity.id + " key: " + key + " new value: " + nvalue +  " old value: " + ovalue);
}
async function test() {
    alt.on("metaChange",logmeta);
    await alt.Utils.wait(1000);
    player.setMeta("test","a");
    player.setMeta("testb",11);
    await alt.Utils.wait(1000);
    alt.log("hasmeta test " + player.hasMeta("test") + " value: " + player.getMeta("test"));
    alt.log("hasmeta testb " + player.hasMeta("testb") + " value: " + player.getMeta("testb"));
    player.deleteMeta("test");
    player.deleteMeta("testb");
    await alt.Utils.wait(1000);
    alt.off("metaChange",logmeta);

}
test();
xxshady commented 3 weeks ago

confirmed on latest dev