UNPKG

samp-node-lib

Version:

NodeJS library for Scripting San Andreas Multiplayer:SAMP depends on samp-node plugin

44 lines 1.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TextDraws = void 0; samp.on('OnPlayerClickPlayerTextDraw', (playerid, playertextid) => { (TextDraws.tds[`id${playerid}`] || []).forEach((td) => { if (td.textid === playertextid) { td.callback.forEach(c => c(playerid)); } }); }); samp.on('OnPlayerDisconnect', (playerid) => { TextDraws.destroyAll(playerid); }); class TextDraws { static getAll(playerid) { return this.tds[`id${playerid}`] || []; } static destroy(playerid, name) { const tds = (this.tds[`id${playerid}`] || []); tds.filter(td => td.name === name).forEach(td => td.destroy()); const newValue = tds.filter(td => td.name !== name); if (newValue.length > 0) { this.tds[`id${playerid}`] = newValue; } else if (this.tds[`id${playerid}`] !== undefined) { delete this.tds[`id${playerid}`]; } } static destroyAll(playerid) { (this.tds[`id${playerid}`] || []).forEach((td) => { td.destroy(); }); delete this.tds[`id${playerid}`]; } static add(playerid, td) { if (this.tds[`id${playerid}`] === undefined) { this.tds[`id${playerid}`] = []; } this.tds[`id${playerid}`].push(td); } } exports.TextDraws = TextDraws; TextDraws.tds = {}; //# sourceMappingURL=TextDraws.js.map