Skip to content
dev2alert edited this page Feb 4, 2022 · 1 revision

Home ▸ Groups

Definition

Group is an array that allows you to group Object, TextDraw, and many other elements.

The group has the functions create, destroy, show and hide, thanks to which you can perform actions on elements.

Example

Creating and displaying TextDraw:

import {GameMode, Group, Player, TextDraw} from "@sa-mp/core";

const textdraws: Group<TextDraw> = new Group(
    new TextDraw({text: "Text #1!", x: 300, y: 100, color: 0xf2630aAA}),
    new TextDraw({text: "Text #2!", x: 300, y: 150, color: 0xf2630aAA}),
    new TextDraw({text: "Text #3!", x: 300, y: 200, color: 0xf2630aAA}),
    new TextDraw({text: "Text #4!", x: 300, y: 250, color: 0xf2630aAA}),
    new TextDraw({text: "Text #5!", x: 300, y: 300, color: 0xf2630aAA})
);

GameMode.on("init", () => textdraws.create());

Player.on("connect", (player) => textdraws.show(player));
Clone this wiki locally