@infernus/core 0.8.7 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +1553 -1551
- package/dist/bundle.js +1 -1
- package/dist/bundle.mjs +1 -0
- package/package.json +10 -3
- package/rollup.config.mjs +5 -2
- package/.eslintrc +0 -3
- package/src/controllers/command/index.ts +0 -57
- package/src/controllers/filterscript/index.ts +0 -69
- package/src/controllers/gamemode/index.ts +0 -277
- package/src/controllers/gamemode/settings.ts +0 -3
- package/src/controllers/gametext/index.ts +0 -61
- package/src/controllers/gangzone/baseGangZone.ts +0 -284
- package/src/controllers/gangzone/gangZoneBus.ts +0 -8
- package/src/controllers/gangzone/gangZoneEvent.ts +0 -91
- package/src/controllers/gangzone/index.ts +0 -2
- package/src/controllers/i18n/index.ts +0 -81
- package/src/controllers/index.ts +0 -12
- package/src/controllers/menu/baseMenu.ts +0 -203
- package/src/controllers/menu/index.ts +0 -2
- package/src/controllers/menu/menuBus.ts +0 -8
- package/src/controllers/menu/menuEvent.ts +0 -76
- package/src/controllers/netstats/index.ts +0 -43
- package/src/controllers/npc/index.ts +0 -2
- package/src/controllers/npc/npcEvent.ts +0 -26
- package/src/controllers/npc/npcFunc.ts +0 -64
- package/src/controllers/player/basePlayer.ts +0 -980
- package/src/controllers/player/index.ts +0 -3
- package/src/controllers/player/pauseChecker.ts +0 -39
- package/src/controllers/player/playerBus.ts +0 -9
- package/src/controllers/player/playerEvent.ts +0 -468
- package/src/controllers/promise/client/index.ts +0 -31
- package/src/controllers/promise/dialog/index.ts +0 -143
- package/src/controllers/textdraw/baseTextDraw.ts +0 -416
- package/src/controllers/textdraw/index.ts +0 -2
- package/src/controllers/textdraw/textdrawBus.ts +0 -8
- package/src/controllers/textdraw/textdrawEvent.ts +0 -61
- package/src/controllers/vehicle/baseVehicle.ts +0 -503
- package/src/controllers/vehicle/index.ts +0 -2
- package/src/controllers/vehicle/vehicleBus.ts +0 -8
- package/src/controllers/vehicle/vehicleEvent.ts +0 -201
- package/src/enums/artwork.ts +0 -5
- package/src/enums/clickSources.ts +0 -3
- package/src/enums/dialogStyles.ts +0 -8
- package/src/enums/editResponseTypes.ts +0 -5
- package/src/enums/index.ts +0 -18
- package/src/enums/invalid.ts +0 -13
- package/src/enums/keys.ts +0 -25
- package/src/enums/limits.ts +0 -18
- package/src/enums/marker.ts +0 -5
- package/src/enums/netstat.ts +0 -11
- package/src/enums/npc.ts +0 -11
- package/src/enums/object.ts +0 -25
- package/src/enums/player.ts +0 -92
- package/src/enums/record.ts +0 -5
- package/src/enums/specialActions.ts +0 -22
- package/src/enums/streamer.ts +0 -10
- package/src/enums/textdrawFonts.ts +0 -23
- package/src/enums/vehicle.ts +0 -32
- package/src/enums/weapon.ts +0 -82
- package/src/interfaces/index.ts +0 -233
- package/src/logger/index.ts +0 -24
- package/src/main.ts +0 -6
- package/src/types/index.ts +0 -48
- package/src/utils/EventBus.ts +0 -60
- package/src/utils/animateUtils.ts +0 -2504
- package/src/utils/colorUtils.ts +0 -43
- package/src/utils/helperUtils.ts +0 -403
- package/src/utils/vehicleUtils.ts +0 -321
- package/src/wrapper/native/callbacks/index.ts +0 -395
- package/src/wrapper/native/functions/index.ts +0 -3131
- package/src/wrapper/streamer/3dtext/3dTextBus.ts +0 -8
- package/src/wrapper/streamer/3dtext/3dTextEvent.ts +0 -70
- package/src/wrapper/streamer/3dtext/base3DText.ts +0 -184
- package/src/wrapper/streamer/3dtext/index.ts +0 -2
- package/src/wrapper/streamer/actor/actorBus.ts +0 -8
- package/src/wrapper/streamer/actor/actorEvent.ts +0 -95
- package/src/wrapper/streamer/actor/baseActor.ts +0 -278
- package/src/wrapper/streamer/actor/index.ts +0 -2
- package/src/wrapper/streamer/area/areaBus.ts +0 -8
- package/src/wrapper/streamer/area/areaEvent.ts +0 -99
- package/src/wrapper/streamer/area/baseArea.ts +0 -450
- package/src/wrapper/streamer/area/index.ts +0 -2
- package/src/wrapper/streamer/checkpoint/baseCheckpoint.ts +0 -136
- package/src/wrapper/streamer/checkpoint/checkPointBus.ts +0 -8
- package/src/wrapper/streamer/checkpoint/checkPointEvent.ts +0 -100
- package/src/wrapper/streamer/checkpoint/index.ts +0 -2
- package/src/wrapper/streamer/common/index.ts +0 -318
- package/src/wrapper/streamer/index.ts +0 -9
- package/src/wrapper/streamer/mapIcon/baseMapIcon.ts +0 -128
- package/src/wrapper/streamer/mapIcon/index.ts +0 -2
- package/src/wrapper/streamer/mapIcon/mapIconBus.ts +0 -8
- package/src/wrapper/streamer/mapIcon/mapIconEvent.ts +0 -67
- package/src/wrapper/streamer/object/baseObject.ts +0 -415
- package/src/wrapper/streamer/object/index.ts +0 -2
- package/src/wrapper/streamer/object/objectBus.ts +0 -8
- package/src/wrapper/streamer/object/objectEvent.ts +0 -177
- package/src/wrapper/streamer/pickup/basePickup.ts +0 -114
- package/src/wrapper/streamer/pickup/index.ts +0 -2
- package/src/wrapper/streamer/pickup/pickupBus.ts +0 -8
- package/src/wrapper/streamer/pickup/pickupEvent.ts +0 -84
- package/src/wrapper/streamer/raceCP/baseRaceCP.ts +0 -151
- package/src/wrapper/streamer/raceCP/index.ts +0 -2
- package/src/wrapper/streamer/raceCP/raceCPBus.ts +0 -8
- package/src/wrapper/streamer/raceCP/raceCPEvent.ts +0 -100
- package/tsconfig.json +0 -16
- /package/{LICENSE → LICENSE.md} +0 -0
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { IFilterScript } from "@/interfaces";
|
|
2
|
-
import { logger } from "@/logger";
|
|
3
|
-
import { OnGameModeExit, OnGameModeInit } from "@/wrapper/native/callbacks";
|
|
4
|
-
|
|
5
|
-
const preInstallScripts: Array<IFilterScript> = [];
|
|
6
|
-
const installedScripts: Array<IFilterScript> = [];
|
|
7
|
-
|
|
8
|
-
export const loadUseScript = (scriptName: string): void => {
|
|
9
|
-
setTimeout(async () => {
|
|
10
|
-
try {
|
|
11
|
-
const fsIdx = preInstallScripts.findIndex((fs) => fs.name === scriptName);
|
|
12
|
-
if (fsIdx === -1) return;
|
|
13
|
-
|
|
14
|
-
const fs = preInstallScripts[fsIdx];
|
|
15
|
-
await fs.load();
|
|
16
|
-
|
|
17
|
-
preInstallScripts.splice(fsIdx, 1);
|
|
18
|
-
installedScripts.push(fs);
|
|
19
|
-
} catch (err) {
|
|
20
|
-
logger.error(`[GameMode]: script ${scriptName} load fail`);
|
|
21
|
-
logger.warn(new Error(JSON.stringify(err)));
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
export const unloadUseScript = (scriptName: string): void => {
|
|
26
|
-
setTimeout(async () => {
|
|
27
|
-
try {
|
|
28
|
-
const fsIdx = installedScripts.findIndex((fs) => fs.name === scriptName);
|
|
29
|
-
if (fsIdx === -1) return;
|
|
30
|
-
|
|
31
|
-
const fs = installedScripts[fsIdx];
|
|
32
|
-
await fs.unload();
|
|
33
|
-
|
|
34
|
-
installedScripts.splice(fsIdx, 1);
|
|
35
|
-
preInstallScripts.push(fs);
|
|
36
|
-
} catch (err) {
|
|
37
|
-
logger.error(`[GameMode]: script ${scriptName} unload fail`);
|
|
38
|
-
logger.warn(new Error(JSON.stringify(err)));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const reloadUseScript = (scriptName: string) => {
|
|
44
|
-
unloadUseScript(scriptName);
|
|
45
|
-
loadUseScript(scriptName);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
OnGameModeInit(() => {
|
|
49
|
-
preInstallScripts.forEach((fs) => loadUseScript(fs.name));
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
OnGameModeExit(() => {
|
|
53
|
-
installedScripts.forEach((fs) => unloadUseScript(fs.name));
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export const useFilterScript = function (
|
|
57
|
-
plugin: IFilterScript,
|
|
58
|
-
...options: Array<any>
|
|
59
|
-
): void {
|
|
60
|
-
if (
|
|
61
|
-
preInstallScripts.some((fs) => fs === plugin) ||
|
|
62
|
-
installedScripts.some((fs) => fs === plugin)
|
|
63
|
-
) {
|
|
64
|
-
logger.warn(`[GameMode]: script has already been applied`);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
plugin.load = plugin.load.bind(plugin, ...options);
|
|
68
|
-
preInstallScripts.push(plugin);
|
|
69
|
-
};
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OnGameModeExit,
|
|
3
|
-
OnGameModeInit,
|
|
4
|
-
OnIncomingConnection,
|
|
5
|
-
} from "@/wrapper/native/callbacks";
|
|
6
|
-
import * as fns from "@/wrapper/native/functions";
|
|
7
|
-
import { logger } from "@/logger";
|
|
8
|
-
import {
|
|
9
|
-
OnRconCommand,
|
|
10
|
-
OnRconLoginAttempt,
|
|
11
|
-
promisifyCallback,
|
|
12
|
-
} from "@/utils/helperUtils";
|
|
13
|
-
import { defaultCharset } from "./settings";
|
|
14
|
-
import type { TCommonCallback } from "@/types";
|
|
15
|
-
import {
|
|
16
|
-
loadUseScript,
|
|
17
|
-
reloadUseScript,
|
|
18
|
-
unloadUseScript,
|
|
19
|
-
useFilterScript,
|
|
20
|
-
} from "../filterscript";
|
|
21
|
-
import {
|
|
22
|
-
ClearBanList,
|
|
23
|
-
IsBanned,
|
|
24
|
-
IsValidNickName,
|
|
25
|
-
AllowNickNameCharacter,
|
|
26
|
-
IsNickNameCharacterAllowed,
|
|
27
|
-
AddServerRule,
|
|
28
|
-
SetServerRule,
|
|
29
|
-
IsValidServerRule,
|
|
30
|
-
RemoveServerRule,
|
|
31
|
-
GetWeaponSlot,
|
|
32
|
-
GetAvailableClasses,
|
|
33
|
-
GetPlayerClass,
|
|
34
|
-
EditPlayerClass,
|
|
35
|
-
ToggleChatTextReplacement,
|
|
36
|
-
ChatTextReplacementToggled,
|
|
37
|
-
AllowAdminTeleport,
|
|
38
|
-
IsAdminTeleportAllowed,
|
|
39
|
-
AllowInteriorWeapons,
|
|
40
|
-
AreInteriorWeaponsAllowed,
|
|
41
|
-
AreAllAnimationsEnabled,
|
|
42
|
-
EnableAllAnimations,
|
|
43
|
-
} from "@infernus/wrapper";
|
|
44
|
-
import type { IFilterScript } from "@/interfaces";
|
|
45
|
-
|
|
46
|
-
export class GameMode {
|
|
47
|
-
static charset = defaultCharset;
|
|
48
|
-
private initialized = false;
|
|
49
|
-
|
|
50
|
-
constructor() {
|
|
51
|
-
OnGameModeInit((): void => {
|
|
52
|
-
if (this.initialized)
|
|
53
|
-
return logger.error("[GameMode]: Cannot be initialized more than once");
|
|
54
|
-
GameMode.supportAllNickname();
|
|
55
|
-
this.initialized = true;
|
|
56
|
-
this.onInit && this.onInit();
|
|
57
|
-
});
|
|
58
|
-
OnGameModeExit((): void => {
|
|
59
|
-
if (!this.initialized)
|
|
60
|
-
return logger.error("[GameMode]: Cannot unload more than once");
|
|
61
|
-
this.initialized = false;
|
|
62
|
-
this.onExit && this.onExit();
|
|
63
|
-
});
|
|
64
|
-
OnIncomingConnection(promisifyCallback(this, "onIncomingConnection"));
|
|
65
|
-
OnRconCommand(
|
|
66
|
-
promisifyCallback(this, "onRconCommand", "OnRconCommandI18n")
|
|
67
|
-
);
|
|
68
|
-
OnRconLoginAttempt(promisifyCallback(this, "onRconLoginAttempt"));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
isInitialized(): boolean {
|
|
72
|
-
return this.initialized;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// do something during close/restart server, such as storage of player data
|
|
76
|
-
static exit(): void {
|
|
77
|
-
// it's restart
|
|
78
|
-
fns.GameModeExit();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// support filter script which use @infernus/core
|
|
82
|
-
static use = (plugin: IFilterScript, ...options: Array<any>) => {
|
|
83
|
-
useFilterScript(plugin, ...options);
|
|
84
|
-
return this;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
static loadScript = loadUseScript;
|
|
88
|
-
static unloadScript = unloadUseScript;
|
|
89
|
-
static reloadScript = reloadUseScript;
|
|
90
|
-
|
|
91
|
-
static supportAllNickname() {
|
|
92
|
-
/**
|
|
93
|
-
* In utf8, different national languages take up different numbers of bytes,
|
|
94
|
-
* but no matter how many bytes they take up, a byte always takes up 8 bits of binary,
|
|
95
|
-
* i.e., a decimal integer up to 255.
|
|
96
|
-
*/
|
|
97
|
-
for (let i = 0; i <= 255; i++) {
|
|
98
|
-
if (!GameMode.isNickNameCharacterAllowed(i))
|
|
99
|
-
GameMode.allowNickNameCharacter(i, true);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
onInit?(): void;
|
|
104
|
-
onExit?(): void;
|
|
105
|
-
onIncomingConnection?(
|
|
106
|
-
playerid: number,
|
|
107
|
-
ipAddress: string,
|
|
108
|
-
port: number
|
|
109
|
-
): TCommonCallback;
|
|
110
|
-
onRconCommand?(cmd: string): TCommonCallback;
|
|
111
|
-
onRconLoginAttempt?(
|
|
112
|
-
ip: string,
|
|
113
|
-
password: string,
|
|
114
|
-
success: boolean
|
|
115
|
-
): TCommonCallback;
|
|
116
|
-
static allowAdminTeleport = AllowAdminTeleport;
|
|
117
|
-
static isAdminTeleportAllowed = IsAdminTeleportAllowed;
|
|
118
|
-
static allowInteriorWeapons = AllowInteriorWeapons;
|
|
119
|
-
static areInteriorWeaponsAllowed = AreInteriorWeaponsAllowed;
|
|
120
|
-
static areAllAnimationsEnabled = AreAllAnimationsEnabled;
|
|
121
|
-
static enableAllAnimations = EnableAllAnimations;
|
|
122
|
-
static enableStuntBonusForAll = fns.EnableStuntBonusForAll;
|
|
123
|
-
static enableVehicleFriendlyFire = fns.EnableVehicleFriendlyFire;
|
|
124
|
-
static enableZoneNames = fns.EnableZoneNames;
|
|
125
|
-
static disableInteriorEnterExits = fns.DisableInteriorEnterExits;
|
|
126
|
-
static setGameModeText = fns.SetGameModeText;
|
|
127
|
-
static getGravity = fns.GetGravity;
|
|
128
|
-
static setGravity = fns.SetGravity;
|
|
129
|
-
static showNameTags = fns.ShowNameTags;
|
|
130
|
-
static disableNameTagLOS = fns.DisableNameTagLOS;
|
|
131
|
-
static usePlayerPedAnims = fns.UsePlayerPedAnims;
|
|
132
|
-
static showPlayerMarkers = fns.ShowPlayerMarkers;
|
|
133
|
-
static limitPlayerMarkerRadius = fns.LimitPlayerMarkerRadius;
|
|
134
|
-
static limitGlobalChatRadius = fns.LimitGlobalChatRadius;
|
|
135
|
-
static setNameTagDrawDistance = fns.SetNameTagDrawDistance;
|
|
136
|
-
static setWeather(weather: number): number {
|
|
137
|
-
if (weather < 0 || weather > 255) {
|
|
138
|
-
logger.error("[GameMode]: The valid weather value is only 0 to 255");
|
|
139
|
-
return 0;
|
|
140
|
-
}
|
|
141
|
-
return fns.SetWeather(weather);
|
|
142
|
-
}
|
|
143
|
-
static setWorldTime(hour: number): number {
|
|
144
|
-
if (hour < 0 || hour > 23) {
|
|
145
|
-
logger.error("[GameMode]: The valid hour value is only 0 to 23");
|
|
146
|
-
return 0;
|
|
147
|
-
}
|
|
148
|
-
return fns.SetWorldTime(hour);
|
|
149
|
-
}
|
|
150
|
-
static setTeamCount = fns.SetTeamCount;
|
|
151
|
-
static sendRconCommand = fns.SendRconCommand;
|
|
152
|
-
static addPlayerClass = fns.AddPlayerClass;
|
|
153
|
-
static addPlayerClassEx = fns.AddPlayerClassEx;
|
|
154
|
-
static createExplosion(
|
|
155
|
-
X: number,
|
|
156
|
-
Y: number,
|
|
157
|
-
Z: number,
|
|
158
|
-
type: number,
|
|
159
|
-
Radius: number
|
|
160
|
-
): number {
|
|
161
|
-
if (type < 0 || type > 13) {
|
|
162
|
-
logger.error(
|
|
163
|
-
"[GameMode]: The valid explosion type value is only 0 to 13"
|
|
164
|
-
);
|
|
165
|
-
return 0;
|
|
166
|
-
}
|
|
167
|
-
return fns.CreateExplosion(X, Y, Z, type, Radius);
|
|
168
|
-
}
|
|
169
|
-
static manualVehicleEngineAndLights = fns.ManualVehicleEngineAndLights;
|
|
170
|
-
static blockIpAddress = fns.BlockIpAddress;
|
|
171
|
-
static unBlockIpAddress = fns.UnBlockIpAddress;
|
|
172
|
-
static getServerTickRate = fns.GetServerTickRate;
|
|
173
|
-
static addSimpleModel(
|
|
174
|
-
virtualworld: number,
|
|
175
|
-
baseid: number,
|
|
176
|
-
newid: number,
|
|
177
|
-
dffname: string,
|
|
178
|
-
txdname: string
|
|
179
|
-
): number {
|
|
180
|
-
if (this.checkSimpleModel(virtualworld, baseid, newid, dffname, txdname)) {
|
|
181
|
-
return fns.AddSimpleModel(virtualworld, baseid, newid, dffname, txdname);
|
|
182
|
-
}
|
|
183
|
-
return 0;
|
|
184
|
-
}
|
|
185
|
-
static addSimpleModelTimed(
|
|
186
|
-
virtualworld: number,
|
|
187
|
-
baseid: number,
|
|
188
|
-
newid: number,
|
|
189
|
-
dffname: string,
|
|
190
|
-
txdname: string,
|
|
191
|
-
timeon: number,
|
|
192
|
-
timeoff: number
|
|
193
|
-
): number {
|
|
194
|
-
if (
|
|
195
|
-
this.checkSimpleModel(
|
|
196
|
-
virtualworld,
|
|
197
|
-
baseid,
|
|
198
|
-
newid,
|
|
199
|
-
dffname,
|
|
200
|
-
txdname,
|
|
201
|
-
timeon,
|
|
202
|
-
timeoff
|
|
203
|
-
)
|
|
204
|
-
) {
|
|
205
|
-
return fns.AddSimpleModelTimed(
|
|
206
|
-
virtualworld,
|
|
207
|
-
baseid,
|
|
208
|
-
newid,
|
|
209
|
-
dffname,
|
|
210
|
-
txdname,
|
|
211
|
-
timeon,
|
|
212
|
-
timeoff
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
return 0;
|
|
216
|
-
}
|
|
217
|
-
private static checkSimpleModel(
|
|
218
|
-
virtualworld: number,
|
|
219
|
-
baseid: number,
|
|
220
|
-
newid: number,
|
|
221
|
-
dffname: string,
|
|
222
|
-
txdname: string,
|
|
223
|
-
timeon?: number,
|
|
224
|
-
timeoff?: number
|
|
225
|
-
): number {
|
|
226
|
-
if (virtualworld < -1) {
|
|
227
|
-
logger.error("[GameMode]: AddSimpleModel - Error virtual world");
|
|
228
|
-
return 0;
|
|
229
|
-
}
|
|
230
|
-
if (baseid < 0) {
|
|
231
|
-
logger.error("[GameMode]: AddSimpleModel - Error baseid");
|
|
232
|
-
return 0;
|
|
233
|
-
}
|
|
234
|
-
if (newid > -1000 || newid < -30000) {
|
|
235
|
-
logger.error("[GameMode]: AddSimpleModel - Error newid range");
|
|
236
|
-
return 0;
|
|
237
|
-
}
|
|
238
|
-
if (dffname.trim().length < 0) {
|
|
239
|
-
logger.error("[GameMode]: AddSimpleModel - Empty dffname");
|
|
240
|
-
return 0;
|
|
241
|
-
}
|
|
242
|
-
if (txdname.trim().length < 0) {
|
|
243
|
-
logger.error("[GameMode]: AddSimpleModel - Empty txdname");
|
|
244
|
-
return 0;
|
|
245
|
-
}
|
|
246
|
-
if (timeon !== undefined && (timeon < 0 || timeon > 23)) {
|
|
247
|
-
logger.error("[GameMode]: AddSimpleModel - Error time on range");
|
|
248
|
-
return 0;
|
|
249
|
-
}
|
|
250
|
-
if (timeoff !== undefined && (timeoff < 0 || timeoff > 23)) {
|
|
251
|
-
logger.error("[GameMode]: AddSimpleModel - Error time off range");
|
|
252
|
-
return 0;
|
|
253
|
-
}
|
|
254
|
-
return 1;
|
|
255
|
-
}
|
|
256
|
-
static findModelFileNameFromCRC = fns.FindModelFileNameFromCRC;
|
|
257
|
-
static findTextureFileNameFromCRC = fns.FindTextureFileNameFromCRC;
|
|
258
|
-
static getWeaponName = fns.GetWeaponName;
|
|
259
|
-
static setObjectsDefaultCameraCollision =
|
|
260
|
-
fns.SetObjectsDefaultCameraCollision;
|
|
261
|
-
static vectorSize = fns.VectorSize;
|
|
262
|
-
static clearBanList = ClearBanList;
|
|
263
|
-
static isBanned = IsBanned;
|
|
264
|
-
static isValidNickName = IsValidNickName;
|
|
265
|
-
static allowNickNameCharacter = AllowNickNameCharacter;
|
|
266
|
-
static isNickNameCharacterAllowed = IsNickNameCharacterAllowed;
|
|
267
|
-
static addServerRule = AddServerRule;
|
|
268
|
-
static setServerRule = SetServerRule;
|
|
269
|
-
static isValidServerRule = IsValidServerRule;
|
|
270
|
-
static removeServerRule = RemoveServerRule;
|
|
271
|
-
static getWeaponSlot = GetWeaponSlot;
|
|
272
|
-
static getAvailableClasses = GetAvailableClasses;
|
|
273
|
-
static getPlayerClass = GetPlayerClass;
|
|
274
|
-
static editPlayerClass = EditPlayerClass;
|
|
275
|
-
static toggleChatTextReplacement = ToggleChatTextReplacement;
|
|
276
|
-
static chatTextReplacementToggled = ChatTextReplacementToggled;
|
|
277
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GameTextForAll,
|
|
3
|
-
GameTextForPlayer,
|
|
4
|
-
HasGameText,
|
|
5
|
-
HideGameTextForAll,
|
|
6
|
-
HideGameTextForPlayer,
|
|
7
|
-
} from "@/wrapper/native/functions";
|
|
8
|
-
import type { Player } from "../player";
|
|
9
|
-
|
|
10
|
-
export class GameText<P extends Player = Player> {
|
|
11
|
-
private _text: string;
|
|
12
|
-
private _time: number;
|
|
13
|
-
private _style: number;
|
|
14
|
-
|
|
15
|
-
get text(): string {
|
|
16
|
-
return this._text;
|
|
17
|
-
}
|
|
18
|
-
set text(value: string) {
|
|
19
|
-
this._text = value;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get time(): number {
|
|
23
|
-
return this._time;
|
|
24
|
-
}
|
|
25
|
-
set time(value: number) {
|
|
26
|
-
this._time = value;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get style(): number {
|
|
30
|
-
return this._style;
|
|
31
|
-
}
|
|
32
|
-
set style(value: number) {
|
|
33
|
-
this._style = value;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
constructor(str: string, time: number, style: number) {
|
|
37
|
-
this._text = str;
|
|
38
|
-
this._time = time;
|
|
39
|
-
this._style = style;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static hideForAll(style: number) {
|
|
43
|
-
HideGameTextForAll(style);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static has<P extends Player>(player: P, style: number) {
|
|
47
|
-
return HasGameText(player.id, style);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
forAll() {
|
|
51
|
-
GameTextForAll(this.text, this.time, this.style);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
forPlayer(player: P) {
|
|
55
|
-
GameTextForPlayer(player.id, this.text, this.time, this.style);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
hideForPlayer(player: P) {
|
|
59
|
-
return HideGameTextForPlayer(player.id, this.style);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { LimitsEnum } from "@/enums";
|
|
2
|
-
import type { IGangZone } from "@/interfaces";
|
|
3
|
-
import { logger } from "@/logger";
|
|
4
|
-
import { rgba } from "@/utils/colorUtils";
|
|
5
|
-
import * as fns from "@/wrapper/native/functions";
|
|
6
|
-
import type { GangZonePos } from "@infernus/wrapper";
|
|
7
|
-
import {
|
|
8
|
-
CreatePlayerGangZone,
|
|
9
|
-
PlayerGangZoneDestroy,
|
|
10
|
-
PlayerGangZoneShow,
|
|
11
|
-
PlayerGangZoneHide,
|
|
12
|
-
PlayerGangZoneFlash,
|
|
13
|
-
PlayerGangZoneStopFlash,
|
|
14
|
-
IsValidPlayerGangZone,
|
|
15
|
-
IsValidGangZone,
|
|
16
|
-
IsPlayerInPlayerGangZone,
|
|
17
|
-
IsPlayerInGangZone,
|
|
18
|
-
IsPlayerGangZoneVisible,
|
|
19
|
-
IsGangZoneVisibleForPlayer,
|
|
20
|
-
PlayerGangZoneGetColour,
|
|
21
|
-
IsPlayerGangZoneFlashing,
|
|
22
|
-
IsGangZoneFlashingForPlayer,
|
|
23
|
-
PlayerGangZoneGetPos,
|
|
24
|
-
GangZoneGetPos,
|
|
25
|
-
UsePlayerGangZoneCheck,
|
|
26
|
-
UseGangZoneCheck,
|
|
27
|
-
GangZoneGetColourForPlayer,
|
|
28
|
-
GangZoneGetFlashColourForPlayer,
|
|
29
|
-
PlayerGangZoneGetFlashColour,
|
|
30
|
-
} from "@infernus/wrapper";
|
|
31
|
-
|
|
32
|
-
import type { Player } from "../player";
|
|
33
|
-
import { gangZoneBus, gangZoneHooks } from "./gangZoneBus";
|
|
34
|
-
|
|
35
|
-
export class GangZone<P extends Player> {
|
|
36
|
-
private _id = -1;
|
|
37
|
-
private static createdGlobalCount = 0;
|
|
38
|
-
private static createdPlayerCount = 0;
|
|
39
|
-
readonly sourceInfo: IGangZone<P>;
|
|
40
|
-
|
|
41
|
-
constructor(gangZone: IGangZone<P>) {
|
|
42
|
-
this.sourceInfo = gangZone;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get id() {
|
|
46
|
-
return this._id;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
create(): void {
|
|
50
|
-
if (this.id !== -1)
|
|
51
|
-
return logger.warn("[GangZone]: Unable to create the gangzone again");
|
|
52
|
-
|
|
53
|
-
const { player } = this.sourceInfo;
|
|
54
|
-
if (!player) {
|
|
55
|
-
if (GangZone.createdGlobalCount === LimitsEnum.MAX_GANG_ZONES)
|
|
56
|
-
return logger.warn(
|
|
57
|
-
"[GangZone]: Unable to continue to create gangzone, maximum allowable quantity has been reached"
|
|
58
|
-
);
|
|
59
|
-
const { minx, miny, maxx, maxy } = this.sourceInfo;
|
|
60
|
-
this._id = fns.GangZoneCreate(minx, miny, maxx, maxy);
|
|
61
|
-
GangZone.createdGlobalCount++;
|
|
62
|
-
} else {
|
|
63
|
-
if (GangZone.createdPlayerCount === LimitsEnum.MAX_GANG_ZONES)
|
|
64
|
-
return logger.warn(
|
|
65
|
-
"[GangZone]: Unable to continue to create gangzone, maximum allowable quantity has been reached"
|
|
66
|
-
);
|
|
67
|
-
const { minx, miny, maxx, maxy } = this.sourceInfo;
|
|
68
|
-
this._id = CreatePlayerGangZone(player.id, minx, miny, maxx, maxy);
|
|
69
|
-
GangZone.createdPlayerCount++;
|
|
70
|
-
// PlayerGangZones may be automatically destroyed when a player disconnects.
|
|
71
|
-
samp.addEventListener("OnPlayerDisconnect", this.unregisterEvent);
|
|
72
|
-
}
|
|
73
|
-
gangZoneBus.emit(gangZoneHooks.created, {
|
|
74
|
-
key: { id: this.id, global: player === undefined },
|
|
75
|
-
value: this,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
destroy() {
|
|
80
|
-
if (this.id === -1)
|
|
81
|
-
return logger.warn(
|
|
82
|
-
"[GangZone]: Unable to destroy the gangzone before create"
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const { player } = this.sourceInfo;
|
|
86
|
-
if (!player) {
|
|
87
|
-
fns.GangZoneDestroy(this.id);
|
|
88
|
-
GangZone.createdGlobalCount--;
|
|
89
|
-
} else {
|
|
90
|
-
PlayerGangZoneDestroy(player.id, this.id);
|
|
91
|
-
GangZone.createdPlayerCount--;
|
|
92
|
-
}
|
|
93
|
-
gangZoneBus.emit(gangZoneHooks.destroyed, {
|
|
94
|
-
id: this.id,
|
|
95
|
-
global: player === undefined,
|
|
96
|
-
});
|
|
97
|
-
this._id = -1;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
showForAll(colour: string | number): void | this {
|
|
101
|
-
if (this.id === -1)
|
|
102
|
-
return logger.warn(
|
|
103
|
-
"[GangZone]: Unable to show the gangzone before create"
|
|
104
|
-
);
|
|
105
|
-
const p = this.sourceInfo.player;
|
|
106
|
-
if (!p) {
|
|
107
|
-
fns.GangZoneShowForAll(this.id, colour);
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
return logger.warn(
|
|
111
|
-
"[GangZone]: player's gangzone should not be show for all."
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
showForPlayer(colour: string | number, player?: P): void | this {
|
|
116
|
-
if (this.id === -1)
|
|
117
|
-
return logger.warn(
|
|
118
|
-
"[GangZone]: Unable to show the gangzone before create"
|
|
119
|
-
);
|
|
120
|
-
const p = this.sourceInfo.player;
|
|
121
|
-
if (p) PlayerGangZoneShow(p.id, this.id, rgba(colour));
|
|
122
|
-
else {
|
|
123
|
-
if (player) fns.GangZoneShowForPlayer(player.id, this.id, colour);
|
|
124
|
-
else return logger.warn("[GangZone]: invalid player for show");
|
|
125
|
-
}
|
|
126
|
-
return this;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
hideForAll(): void | this {
|
|
130
|
-
if (this.id === -1)
|
|
131
|
-
return logger.warn(
|
|
132
|
-
"[GangZone]: Unable to hide the gangzone before create"
|
|
133
|
-
);
|
|
134
|
-
const p = this.sourceInfo.player;
|
|
135
|
-
if (!p) {
|
|
136
|
-
fns.GangZoneHideForAll(this.id);
|
|
137
|
-
return this;
|
|
138
|
-
}
|
|
139
|
-
return logger.warn(
|
|
140
|
-
"[GangZone]: player's gangzone should not be hide for all."
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
hideForPlayer(player?: P): void | this {
|
|
145
|
-
if (this.id === -1)
|
|
146
|
-
return logger.warn(
|
|
147
|
-
"[GangZone]: Unable to hide the gangzone before create"
|
|
148
|
-
);
|
|
149
|
-
const p = this.sourceInfo.player;
|
|
150
|
-
if (p) PlayerGangZoneHide(p.id, this.id);
|
|
151
|
-
else {
|
|
152
|
-
if (player) fns.GangZoneHideForPlayer(player.id, this.id);
|
|
153
|
-
else return logger.warn("[GangZone]: invalid player for hide");
|
|
154
|
-
}
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
flashForAll(flashcolour: string | number): void | this {
|
|
159
|
-
if (this.id === -1)
|
|
160
|
-
return logger.warn(
|
|
161
|
-
"[GangZone]: Unable to flash the gangzone before create"
|
|
162
|
-
);
|
|
163
|
-
const p = this.sourceInfo.player;
|
|
164
|
-
if (!p) {
|
|
165
|
-
fns.GangZoneFlashForAll(this.id, flashcolour);
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
return logger.warn(
|
|
169
|
-
"[GangZone]: player's gangzone should not be flash for all."
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
flashForPlayer(player: P, flashcolour: string | number): void | this {
|
|
174
|
-
if (this.id === -1)
|
|
175
|
-
return logger.warn(
|
|
176
|
-
"[GangZone]: Unable to flash the gangzone before create"
|
|
177
|
-
);
|
|
178
|
-
const p = this.sourceInfo.player;
|
|
179
|
-
if (p) PlayerGangZoneFlash(p.id, this.id, rgba(flashcolour));
|
|
180
|
-
else {
|
|
181
|
-
if (player) fns.GangZoneFlashForPlayer(player.id, this.id, flashcolour);
|
|
182
|
-
else return logger.warn("[GangZone]: invalid player for flash");
|
|
183
|
-
}
|
|
184
|
-
return this;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
StopFlashForAll(): void | this {
|
|
188
|
-
if (this.id === -1)
|
|
189
|
-
return logger.warn(
|
|
190
|
-
"[GangZone]: Unable to stop flash the gangzone before create"
|
|
191
|
-
);
|
|
192
|
-
const p = this.sourceInfo.player;
|
|
193
|
-
if (!p) {
|
|
194
|
-
fns.GangZoneStopFlashForAll(this.id);
|
|
195
|
-
return this;
|
|
196
|
-
}
|
|
197
|
-
return logger.warn(
|
|
198
|
-
"[GangZone]: player's gangzone should not be stop flash for all."
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
StopFlashForPlayer(player: P): void | this {
|
|
203
|
-
if (this.id === -1)
|
|
204
|
-
return logger.warn(
|
|
205
|
-
"[GangZone]: Unable to stop flash the gangzone before create"
|
|
206
|
-
);
|
|
207
|
-
const p = this.sourceInfo.player;
|
|
208
|
-
if (p) PlayerGangZoneStopFlash(p.id, this.id);
|
|
209
|
-
else {
|
|
210
|
-
if (player) fns.GangZoneStopFlashForPlayer(player.id, this.id);
|
|
211
|
-
else return logger.warn("[GangZone]: invalid player for flash");
|
|
212
|
-
}
|
|
213
|
-
return this;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
isValid(): boolean {
|
|
217
|
-
if (this.id === -1) return false;
|
|
218
|
-
const p = this.sourceInfo.player;
|
|
219
|
-
if (p) return IsValidPlayerGangZone(p.id, this.id);
|
|
220
|
-
return IsValidGangZone(this.id);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
isPlayerIn(player: P): boolean {
|
|
224
|
-
if (this.id === -1) return false;
|
|
225
|
-
const p = this.sourceInfo.player;
|
|
226
|
-
if (p) return IsPlayerInPlayerGangZone(p.id, this.id);
|
|
227
|
-
return IsPlayerInGangZone(player.id, this.id);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
isVisibleForPlayer(player: P): boolean {
|
|
231
|
-
if (this.id === -1) return false;
|
|
232
|
-
const p = this.sourceInfo.player;
|
|
233
|
-
if (p) return IsPlayerGangZoneVisible(p.id, this.id);
|
|
234
|
-
return IsGangZoneVisibleForPlayer(player.id, this.id);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
getColourForPlayer(player: P): void | number {
|
|
238
|
-
if (this.id === -1)
|
|
239
|
-
return logger.warn("[GangZone]: Unable to get colour before create");
|
|
240
|
-
const p = this.sourceInfo.player;
|
|
241
|
-
if (p) return PlayerGangZoneGetColour(p.id, this.id);
|
|
242
|
-
return GangZoneGetColourForPlayer(player.id, this.id);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
getFlashColourForPlayer(player: P): void | number {
|
|
246
|
-
if (this.id === -1)
|
|
247
|
-
return logger.warn(
|
|
248
|
-
"[GangZone]: Unable to get flash colour before create"
|
|
249
|
-
);
|
|
250
|
-
const p = this.sourceInfo.player;
|
|
251
|
-
if (p) return PlayerGangZoneGetFlashColour(p.id, this.id);
|
|
252
|
-
return GangZoneGetFlashColourForPlayer(player.id, this.id);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
isFlashingForPlayer(player: P): boolean {
|
|
256
|
-
if (this.id === -1) return false;
|
|
257
|
-
const p = this.sourceInfo.player;
|
|
258
|
-
if (p) return IsPlayerGangZoneFlashing(p.id, this.id);
|
|
259
|
-
return IsGangZoneFlashingForPlayer(player.id, this.id);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
getPos(): void | GangZonePos {
|
|
263
|
-
if (this.id === -1)
|
|
264
|
-
return logger.warn("[GangZone]: Unable to get position before create");
|
|
265
|
-
const p = this.sourceInfo.player;
|
|
266
|
-
if (p) return PlayerGangZoneGetPos(p.id, this.id);
|
|
267
|
-
return GangZoneGetPos(this.id);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
useCheck(toggle: boolean): void | this {
|
|
271
|
-
if (this.id === -1)
|
|
272
|
-
return logger.warn("[GangZone]: Unable to use check before create");
|
|
273
|
-
const p = this.sourceInfo.player;
|
|
274
|
-
if (p) UsePlayerGangZoneCheck(p.id, this.id, toggle);
|
|
275
|
-
else UseGangZoneCheck(this.id, toggle);
|
|
276
|
-
return this;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
private unregisterEvent(): number {
|
|
280
|
-
this.destroy();
|
|
281
|
-
samp.removeEventListener("OnPlayerDisconnect", this.unregisterEvent);
|
|
282
|
-
return 1;
|
|
283
|
-
}
|
|
284
|
-
}
|