Skip to content

Commit

Permalink
fix(core): textdraw cancel middleware onDisconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed Feb 15, 2024
1 parent 4289155 commit 3e4f3ec
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/core/src/controllers/textdraw/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,24 @@ export class TextDraw {
if (!player) {
if (TextDraw.getInstances(true).length === LimitsEnum.MAX_TEXT_DRAWS)
return logger.warn(
"[TextDraw]: Unable to continue to create textdraw, maximum allowable quantity has been reached"
"[TextDraw]: Unable to continue to create textdraw, maximum allowable quantity has been reached",
);
this._id = w.TextDrawCreate(x, y, text);
TextDraw.globalTextDraws.set(this.id, this);
} else {
if (TextDraw.getInstances(false).length === LimitsEnum.MAX_TEXT_DRAWS)
return logger.warn(
"[TextDraw]: Unable to continue to create textdraw, maximum allowable quantity has been reached"
"[TextDraw]: Unable to continue to create textdraw, maximum allowable quantity has been reached",
);
this._id = w.CreatePlayerTextDraw(player.id, x, y, text);
// Player-textdraws are automatically destroyed when a player disconnects.
const off = PlayerEvent.onDisconnect(({ player: p, next }) => {
const ret = next();
if (p === player) {
this.destroy();
off();
}
return next();
return ret;
});
TextDraw.playerTextDraws.set(this.id, this);
}
Expand Down Expand Up @@ -167,7 +168,7 @@ export class TextDraw {
fRotX: number,
fRotY: number,
fRotZ: number,
fZoom = 1
fZoom = 1,
): void | this {
if (this.id === -1) return TextDraw.beforeCreateWarn("set preview rot");
this.setFont(TextDrawFontsEnum.MODEL_PREVIEW);
Expand All @@ -179,7 +180,7 @@ export class TextDraw {
fRotX,
fRotY,
fRotZ,
fZoom
fZoom,
);
else w.TextDrawSetPreviewRot(this.id, fRotX, fRotY, fRotZ, fZoom);
return this;
Expand All @@ -193,7 +194,7 @@ export class TextDraw {
player.id,
this.id,
color1,
color2
color2,
);
else w.TextDrawSetPreviewVehicleColors(this.id, color1, color2);
return this;
Expand Down Expand Up @@ -281,7 +282,7 @@ export class TextDraw {
return this;
}
return logger.warn(
"[TextDraw]: player's textdraw should not be show for all."
"[TextDraw]: player's textdraw should not be show for all.",
);
}
hideAll(): void | this {
Expand All @@ -292,7 +293,7 @@ export class TextDraw {
return this;
}
return logger.warn(
"[TextDraw]: player's textdraw should not be hide for all."
"[TextDraw]: player's textdraw should not be hide for all.",
);
}
isValid(): boolean {
Expand Down

0 comments on commit 3e4f3ec

Please sign in to comment.