Created by LeonMrBonnie
❤️ Support me by becoming a Patron
⭐ This repository if you found it useful!
This repository provides an alt:V resource to create interactions.
An interaction is a position on the map where you can press a button to do something.
This resource provides an easy way to create and remove interactions.
I cannot stress this enough. Ensure you have NodeJS 13+ or you will have problems.
- NodeJS 13+
- An Existing or New Gamemode
- General Scripting Knowledge
After simply add the name of this resource to your server.cfg
resource section.
altv-os-interactions
Also add the name of this resource to the deps
array of your resource.cfg
from your main gamemode.
Then simply clone this repository into your main server resources folder.
cd resources
git clone https://github.com/LeonMrBonnie/altv-os-interactions
Ensure your package.json
includes this property:
"type": "module"
You can import the resource by using:
import * as Interactions from "altv-os-interactions";
And you can then use the functions by using e.g. Interactions.createInteraction("test", new alt.Vector3(0, 0, 0), 5, () => alt.log("Test!"));
You can create an interaction by using the exported function createInteraction
.
Parameter | Type | Description |
---|---|---|
name |
String |
Unique name to identify the textlabel. |
pos |
Vector3 |
A Vector3 or pos to place it. |
range |
Number |
Interaction range. |
handler |
Function |
The function to be executed when the player interacts. |
You can remove an existing interaction by using the exported function removeInteraction
.
Parameter | Type | Description |
---|---|---|
name |
String |
Unique name to identify the textlabel. |
You can interact with an interaction by standing in its range and pressing E
.
If you want to change this keybind, edit the INTERACTION_KEY
constant in the client.js
file to your desired keycode.