# Interaction Controller

## 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.*

```typescript
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.*

```typescript
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();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stuykgaming.gitbook.io/old/controllers/interactioncontroller.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
