@nativewrappers/fivem 0.0.93 → 0.0.94
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/common/Command.d.ts +3 -3
- package/common/Command.js +12 -9
- package/package.json +1 -1
package/common/Command.d.ts
CHANGED
|
@@ -21,13 +21,13 @@ type CommandHandler<T extends Parameter[]> = (args: MappedParameters<T>) => void
|
|
|
21
21
|
export declare class Command<T extends Parameter[] = Parameter[]> {
|
|
22
22
|
#private;
|
|
23
23
|
readonly name: string | string[];
|
|
24
|
-
readonly help
|
|
24
|
+
readonly help?: string | undefined;
|
|
25
25
|
readonly params?: T | undefined;
|
|
26
26
|
/**
|
|
27
27
|
* Registers a new executable command with optional parameter validation and permission restrictions.
|
|
28
28
|
* @param name The unique identifier(s) for the command, either as a single string or an array of strings.
|
|
29
|
-
* @param help A description of the command, displayed as a chat suggestion.
|
|
30
29
|
* @param handler The function to execute when the command is executed.
|
|
30
|
+
* @param help A description of the command, displayed as a chat suggestion.
|
|
31
31
|
* @param params An optional array of parameter definitions specifying the command's expected arguments,
|
|
32
32
|
* including their names, types, and descriptive help text for chat suggestions.
|
|
33
33
|
* @param restricted Determines the command's access permissions:
|
|
@@ -35,7 +35,7 @@ export declare class Command<T extends Parameter[] = Parameter[]> {
|
|
|
35
35
|
* - A string such as `"group.admin"` grants the command permission to the specified principal.
|
|
36
36
|
* - An array of strings grants permission to multiple principals.
|
|
37
37
|
*/
|
|
38
|
-
constructor(name: string | string[],
|
|
38
|
+
constructor(name: string | string[], handler: CommandHandler<T>, help?: string | undefined, params?: T | undefined, restricted?: Restricted);
|
|
39
39
|
/**
|
|
40
40
|
* Maps the arguments received from a command call to the defined parameters while validating the argument types.
|
|
41
41
|
* @param source The client that executed the command, or -1 if executed by the server.
|
package/common/Command.js
CHANGED
|
@@ -31,8 +31,8 @@ class Command {
|
|
|
31
31
|
/**
|
|
32
32
|
* Registers a new executable command with optional parameter validation and permission restrictions.
|
|
33
33
|
* @param name The unique identifier(s) for the command, either as a single string or an array of strings.
|
|
34
|
-
* @param help A description of the command, displayed as a chat suggestion.
|
|
35
34
|
* @param handler The function to execute when the command is executed.
|
|
35
|
+
* @param help A description of the command, displayed as a chat suggestion.
|
|
36
36
|
* @param params An optional array of parameter definitions specifying the command's expected arguments,
|
|
37
37
|
* including their names, types, and descriptive help text for chat suggestions.
|
|
38
38
|
* @param restricted Determines the command's access permissions:
|
|
@@ -40,12 +40,11 @@ class Command {
|
|
|
40
40
|
* - A string such as `"group.admin"` grants the command permission to the specified principal.
|
|
41
41
|
* - An array of strings grants permission to multiple principals.
|
|
42
42
|
*/
|
|
43
|
-
constructor(name,
|
|
43
|
+
constructor(name, handler, help, params, restricted = true) {
|
|
44
44
|
this.name = name;
|
|
45
45
|
this.help = help;
|
|
46
46
|
this.params = params;
|
|
47
47
|
this.#handler = handler;
|
|
48
|
-
this.name = `/${name}`;
|
|
49
48
|
registerCommand(name, (source2, args, raw) => this.call(source2, args, raw), restricted);
|
|
50
49
|
if (params) {
|
|
51
50
|
for (const parameter of params) {
|
|
@@ -53,16 +52,20 @@ class Command {
|
|
|
53
52
|
parameter.help = parameter.help ? `${parameter.help} (type: ${parameter.type})` : `(type: ${parameter.type})`;
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
|
-
|
|
55
|
+
}
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
const names = Array.isArray(name) ? name : [name];
|
|
58
|
+
for (const name2 of names) {
|
|
59
|
+
const commandObj = { ...this, name: `/${name2}` };
|
|
57
60
|
$SERVER: {
|
|
58
|
-
commands.push(
|
|
59
|
-
emitNet("chat:addSuggestions", -1,
|
|
61
|
+
commands.push(commandObj);
|
|
62
|
+
emitNet("chat:addSuggestions", -1, commandObj);
|
|
60
63
|
}
|
|
61
64
|
$CLIENT: {
|
|
62
|
-
emit("chat:addSuggestion",
|
|
65
|
+
emit("chat:addSuggestion", commandObj);
|
|
63
66
|
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
67
|
+
}
|
|
68
|
+
}, 100);
|
|
66
69
|
}
|
|
67
70
|
static {
|
|
68
71
|
__name(this, "Command");
|