@pma-network/fivem-server 0.0.15 → 0.0.16
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/package.json +1 -1
- package/shared-server/class/CommonPMAPlayer.d.ts +2 -2
- package/shared-server/class/CommonPMAPlayer.js +22 -23
- package/shared-server/types/CommonAbstractPMAPlayer.d.ts +1 -1
- package/shared-server/utils/GlobalOverrides.d.ts +1 -0
- package/shared-server/utils/GlobalOverrides.js +6 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import type { CommonAbstractPMAPlayer } from "../types/CommonAbstractPMAPlayer";
|
|
|
3
3
|
import type { CommonNotificationVariant, CommonPMAPartialNotification } from "../types/CommonNotifications";
|
|
4
4
|
import type { CallSign, ItemName, PlayerJob, PlayerUID } from "../types/SharedTypes";
|
|
5
5
|
export declare class CommonPMAPlayer extends Player implements CommonAbstractPMAPlayer {
|
|
6
|
-
|
|
6
|
+
protected pma_player: CommonAbstractPMAPlayer | null;
|
|
7
7
|
/**
|
|
8
8
|
* Creates the player from the ScRT msgpack'd class
|
|
9
9
|
*/
|
|
@@ -31,7 +31,7 @@ export declare class CommonPMAPlayer extends Player implements CommonAbstractPMA
|
|
|
31
31
|
get_log_name(): string;
|
|
32
32
|
get_item(item_name: ItemName): unknown;
|
|
33
33
|
add_item(item_name: ItemName, quantity: number): unknown;
|
|
34
|
-
remove_item(item_name: ItemName, quantity: number):
|
|
34
|
+
remove_item(item_name: ItemName, quantity: number): unknown;
|
|
35
35
|
has_enough_of_item(item_name: ItemName, quantity: number): boolean;
|
|
36
36
|
get_job(): PlayerJob;
|
|
37
37
|
set_job(job_name: string, rank: number): void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { Player } from "@nativewrappers/server";
|
|
4
|
-
import { framework_name } from "../utils/FrameworkName";
|
|
5
4
|
import { pma_get_player_from_id } from "../utils/GlobalOverrides";
|
|
6
5
|
class CommonPMAPlayer extends Player {
|
|
7
6
|
static {
|
|
@@ -10,7 +9,7 @@ class CommonPMAPlayer extends Player {
|
|
|
10
9
|
// This will get lazy-initialized whenever we actually call a function that needs it,
|
|
11
10
|
// this will make sure we don't pay the un-needed serialize cost if we're only using this for
|
|
12
11
|
// basic nativewrappers types
|
|
13
|
-
|
|
12
|
+
pma_player = null;
|
|
14
13
|
/**
|
|
15
14
|
* Creates the player from the ScRT msgpack'd class
|
|
16
15
|
*/
|
|
@@ -36,15 +35,15 @@ class CommonPMAPlayer extends Player {
|
|
|
36
35
|
if (typeof source !== "number") {
|
|
37
36
|
const ply = source;
|
|
38
37
|
super(ply.source);
|
|
39
|
-
this
|
|
38
|
+
this.pma_player = ply;
|
|
40
39
|
} else {
|
|
41
40
|
super(source);
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
// Ensure we initialize the player whenever we're doing something that needs it.
|
|
45
44
|
ensure_init() {
|
|
46
|
-
if (!this
|
|
47
|
-
this
|
|
45
|
+
if (!this.pma_player) {
|
|
46
|
+
this.pma_player = globalThis.pma_get_player_from_id ? (
|
|
48
47
|
// @ts-ignore: we override this in GlobalOverrides
|
|
49
48
|
globalThis.pma_get_player_from_id(this.Source)
|
|
50
49
|
) : pma_get_player_from_id(this.Source);
|
|
@@ -56,7 +55,7 @@ class CommonPMAPlayer extends Player {
|
|
|
56
55
|
*/
|
|
57
56
|
is_player_valid() {
|
|
58
57
|
this.ensure_init();
|
|
59
|
-
return this
|
|
58
|
+
return this.pma_player !== null;
|
|
60
59
|
}
|
|
61
60
|
send_notification(title, description, variant = "default", duration = 5e3) {
|
|
62
61
|
const noti = {
|
|
@@ -71,71 +70,71 @@ class CommonPMAPlayer extends Player {
|
|
|
71
70
|
}
|
|
72
71
|
get_sex() {
|
|
73
72
|
this.ensure_init();
|
|
74
|
-
return this
|
|
73
|
+
return this.pma_player.get_sex();
|
|
75
74
|
}
|
|
76
75
|
get_height() {
|
|
77
76
|
this.ensure_init();
|
|
78
|
-
return this
|
|
77
|
+
return this.pma_player.get_height();
|
|
79
78
|
}
|
|
80
79
|
get_dob() {
|
|
81
80
|
this.ensure_init();
|
|
82
|
-
return this
|
|
81
|
+
return this.pma_player.get_dob();
|
|
83
82
|
}
|
|
84
83
|
get_unique_id() {
|
|
85
84
|
this.ensure_init();
|
|
86
|
-
return this
|
|
85
|
+
return this.pma_player.get_unique_id();
|
|
87
86
|
}
|
|
88
87
|
get_call_sign() {
|
|
89
88
|
this.ensure_init();
|
|
90
|
-
return this
|
|
89
|
+
return this.pma_player.get_call_sign();
|
|
91
90
|
}
|
|
92
91
|
get_character_name() {
|
|
93
92
|
this.ensure_init();
|
|
94
|
-
return this
|
|
93
|
+
return this.pma_player.get_character_name();
|
|
95
94
|
}
|
|
96
95
|
get_log_name() {
|
|
97
96
|
this.ensure_init();
|
|
98
|
-
return this
|
|
97
|
+
return this.pma_player.get_character_name();
|
|
99
98
|
}
|
|
100
99
|
get_item(item_name) {
|
|
101
100
|
this.ensure_init();
|
|
102
|
-
return this
|
|
101
|
+
return this.pma_player.get_item(item_name);
|
|
103
102
|
}
|
|
104
103
|
add_item(item_name, quantity) {
|
|
105
104
|
this.ensure_init();
|
|
106
|
-
return this
|
|
105
|
+
return this.pma_player.add_item(item_name, quantity);
|
|
107
106
|
}
|
|
108
107
|
remove_item(item_name, quantity) {
|
|
109
108
|
this.ensure_init();
|
|
110
|
-
return this
|
|
109
|
+
return this.pma_player.remove_item(item_name, quantity);
|
|
111
110
|
}
|
|
112
111
|
has_enough_of_item(item_name, quantity) {
|
|
113
112
|
this.ensure_init();
|
|
114
|
-
return this
|
|
113
|
+
return this.pma_player.has_enough_of_item(item_name, quantity);
|
|
115
114
|
}
|
|
116
115
|
get_job() {
|
|
117
116
|
this.ensure_init();
|
|
118
|
-
return this
|
|
117
|
+
return this.pma_player.get_job();
|
|
119
118
|
}
|
|
120
119
|
set_job(job_name, rank) {
|
|
121
120
|
this.ensure_init();
|
|
122
|
-
return this
|
|
121
|
+
return this.pma_player.set_job(job_name, rank);
|
|
123
122
|
}
|
|
124
123
|
get_bank() {
|
|
125
124
|
this.ensure_init();
|
|
126
|
-
return this
|
|
125
|
+
return this.pma_player.get_bank();
|
|
127
126
|
}
|
|
128
127
|
add_to_bank(positive_amount) {
|
|
129
128
|
this.ensure_init();
|
|
130
|
-
return this
|
|
129
|
+
return this.pma_player.add_to_bank(positive_amount);
|
|
131
130
|
}
|
|
132
131
|
remove_from_bank(negative_amount) {
|
|
133
132
|
this.ensure_init();
|
|
134
|
-
return this
|
|
133
|
+
return this.pma_player.remove_from_bank(negative_amount);
|
|
135
134
|
}
|
|
136
135
|
save() {
|
|
137
136
|
this.ensure_init();
|
|
138
|
-
return this
|
|
137
|
+
return this.pma_player.save();
|
|
139
138
|
}
|
|
140
139
|
}
|
|
141
140
|
export {
|
|
@@ -21,7 +21,7 @@ export declare abstract class CommonAbstractPMAPlayer {
|
|
|
21
21
|
* Removes the item with {@param item_name} from the players inventory
|
|
22
22
|
* @throws This will throw an error if there wasn't enough {@param quantity} in the players inventory, you should use use has_enough_of_item to check before calling
|
|
23
23
|
*/
|
|
24
|
-
abstract remove_item(item_name: ItemName, quantity: number):
|
|
24
|
+
abstract remove_item(item_name: ItemName, quantity: number): unknown;
|
|
25
25
|
/**
|
|
26
26
|
* Checks if the player has enough of {@param item_name}
|
|
27
27
|
* @returns `true` if they had enough {@param quantity}, `false` otherwise
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { CommonPMAPlayer } from "../class/CommonPMAPlayer";
|
|
2
2
|
import type { Source } from "../types/SharedTypes";
|
|
3
3
|
export declare function pma_get_player_from_id(source: Source): CommonPMAPlayer;
|
|
4
|
+
export declare function pma_get_inventory_from_id(source: Source): CommonPMAPlayer;
|
|
@@ -6,6 +6,12 @@ function pma_get_player_from_id(source) {
|
|
|
6
6
|
}
|
|
7
7
|
__name(pma_get_player_from_id, "pma_get_player_from_id");
|
|
8
8
|
globalThis.pma_get_player_from_id = pma_get_player_from_id;
|
|
9
|
+
function pma_get_inventory_from_id(source) {
|
|
10
|
+
return exports[framework_name].get_inventory(source);
|
|
11
|
+
}
|
|
12
|
+
__name(pma_get_inventory_from_id, "pma_get_inventory_from_id");
|
|
13
|
+
globalThis.pma_get_inventory_from_id = pma_get_inventory_from_id;
|
|
9
14
|
export {
|
|
15
|
+
pma_get_inventory_from_id,
|
|
10
16
|
pma_get_player_from_id
|
|
11
17
|
};
|