Skip to content

5. onKeyChange

Stuyk edited this page Jul 2, 2023 · 1 revision

When you need to listen for specific key changes across entities in a resource you can use crc.events.onKeyChange.

This means that when the data is written to the database; it will call any callbacks assigned to the function.

Example

crc.events.onKeyChange('cash', (player: alt.Entity, newCash: number, oldCash: number | undefined) => {
    if (!(player instanceof alt.Player)) {
        return;
    }

    alt.log(`Player Cash changed from ${oldCash} to ${newCash});
});
Clone this wiki locally