💻
alt:V Athena Docs v3.0.0
  • Info
    • Introduction
    • Patreon & Support
    • Athena Discord
    • FAQ
  • Installation
    • Common Issues
    • Windows
    • Linux (Ubuntu 20.04+)
    • Debugging
    • Updating
  • Info
    • Admin
    • Configuration
    • Console
    • Database
    • Hotkeys
    • Identifier
  • Plugins
    • Load Plugins
    • Create Plugins
    • Mods
    • Clothing
  • Controllers
    • What is a Controller?
    • Blip Controller
    • Interaction Controller
    • Marker Controller
    • Object Controller
    • Ped Controller
    • Text Label Controller
    • World Notification Controller
  • Systems
    • Interiors
    • Inventory & Items
    • Inventory Rules
    • Jobs
    • Time
    • Weather
  • Menus
    • Menu Types
    • Action Menus
    • Input Menu
    • Wheel Menu
  • Player
    • Admin-Commands
    • Animations
    • Attach Objects
    • Credits
    • Currency
    • Commands
    • Error Screen
    • Message
    • Meta
    • Notifications
    • Particle
    • Progress Bar
    • Save
    • Shard
    • Sound
    • Spinners
    • Task Timeline
  • Custom WebViews
    • Introduction
    • Your First Page
    • CSS Framework
  • Misc
    • Custom Sounds
    • Custom Streamers
    • Custom Icons
    • Adding Locale / Translations
    • Adding Vehicle Rules
    • Adding Whitelist
    • Adding Wheel Menus
    • Adding Parking Garages
Powered by GitBook
On this page
  • Server Usage
  • Client Usage
  • Client Listening for Changes
Edit on GitHub
  1. Player

Meta

Meta lets you easily sync single-sided data for players.

There may be a use case where you just need a single player to know about a variable on client-side. Let's say their own bank balance for instance.

You want the player to know their balance but it's not important for other players to know about this data. That is what meta is for.

Server Usage

Setting a meta can be done like this...

Athena.player.emit.meta(player, 'bank', 500);

Client Usage

Depending on what you need; you may need to extend the meta interface.

import * as alt from 'alt-client';
import * as metaRef from '../../client/extensions/Meta'

// Extends the player interface.
declare module 'alt-client' {
    export interface Meta extends Partial<metaRef.Meta> {
        someNewValue?: null | undefined | string;
    }
}

After you can access meta on a player directly

const result = alt.Player.local.meta.someNewValue;

Client Listening for Changes

If you want to listen for changes to specific keys there is an event for it. This can only be done on client-side.

alt.on(SYSTEM_EVENTS.META_CHANGED, (key: string, value: any, oldValue: any) => {
    console.log(key);
    console.log(`${oldValue} -> ${value}`);
})
PreviousMessageNextNotifications

Last updated 3 years ago