💻
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
  • What is an Interaction?
  • Creation
  • Removal
Edit on GitHub
  1. Controllers

Interaction Controller

Learn how to add interactions.

What is an Interaction?

An interaction is an invisible position on the map where if a player walks over this spot they may press their interaction button to trigger something. This can be anything from a menu, text, etc.

Keep in mind that Interactions are GLOBAL which means all players can access them. However, you can write an if statement inside of the intraction trigger to prevent the code from going further.

All interactions are server-side so if you want it to trigger client-side you will need to emit an event to the client to trigger it. This will ensure that interaction(s) are synced through server-side first.

Creation

This will create a ColShape where the player can press their interaction button to trigger something.

Keep in mind that the paths of these files may vary.

function doThisWhenInteractionIsPressed(player: alt.Player) {
    Athena.player.emit.message(player, 'Nice!');
}

function GenerateInteractions() {
    Athena.controllers.interaction.add({
        uid: 'interaction-do-something',
        type: 'interaction:DoSomething',
        position: { x: 402.397308, y: -1029.67, z: 29.34688 },
        description: 'Neato',
        callback: doThisWhenInteractionIsPressed
    });
}

GenerateInteractions();

Removal

This will remove an interaction and its associated ColShape.

Keep in mind that the paths of these files may vary.

import * as alt from 'alt-server';

const UID = 'do-something';
const INT_TYPE = 'interaction:DoSomething';

function doThisWhenInteractionIsPressed(player: alt.Player) {
    Athena.player.emit.message(player, 'Removing Interaction!');
    Athena.controllers.interaction.remove(INT_TYPE, UID);
}

function GenerateInteractions() {
    Athena.controllers.interaction.add({
        uid: UID,
        type: INT_TYPE,
        position: { x: 402.397308, y: -1029.67, z: 29.34688 },
        description: 'Remove this interaction on press.',
        callback: doThisWhenInteractionIsPressed
    });
}

GenerateInteractions();
PreviousBlip ControllerNextMarker Controller

Last updated 3 years ago