@pma-network/redm-server 0.0.8 → 0.0.12

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/PMA.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { ItemData, ItemName } from "@redm-types/Inventory";
2
- import type { PlayerUID } from "@redm-types/PMAPlayer";
3
- import { PMAPlayer } from "./class/PMAPlayer";
1
+ import type { ItemData, ItemName } from "@pma-network/redm-types/Inventory";
2
+ import type { PlayerUID } from "@pma-network/redm-types/PMAPlayer";
3
+ import { PMAPlayerWrapper } from "./class/PMAPlayer";
4
4
  import type { UsableItemCall } from "./types/Inventory";
5
5
  /**
6
6
  * A static class that's used for invoking framework types
@@ -22,16 +22,16 @@ export declare class PMA {
22
22
  * isn't initialized, this won't break anything though.
23
23
  * @returns the PMAPlayer wrapper, or `null` if the player doesn't exist
24
24
  */
25
- static from_source(source: number): PMAPlayer | null;
25
+ static from_source(source: number): PMAPlayerWrapper | null;
26
26
  /**
27
27
  * Gets the player from the specified UID
28
28
  * @returns the PMAPlayer wrapper, or `null` if there wasn't a player
29
29
  */
30
- static from_uid(uid: PlayerUID): PMAPlayer | null;
30
+ static from_uid(uid: PlayerUID): PMAPlayerWrapper | null;
31
31
  /**
32
32
  * Gets all of the players that habe the specified job(s), and the specified {@param job_rank} if specified.
33
33
  */
34
- static get_players_with_job(job_names: string | string[], job_rank?: number): PMAPlayer[];
34
+ static get_players_with_job(job_names: string | string[], job_rank?: number): PMAPlayerWrapper[];
35
35
  /**
36
36
  * Generic logging
37
37
  * TODO: Setup a clickhouse wrapper
package/PMA.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { PMAPlayer } from "./class/PMAPlayer";
3
+ import { PMAPlayerWrapper } from "./class/PMAPlayer";
4
4
  class PMA {
5
5
  static {
6
6
  __name(this, "PMA");
@@ -17,7 +17,7 @@ class PMA {
17
17
  */
18
18
  static register_usable_item(item_name, fn) {
19
19
  const usable_item_wrapper = /* @__PURE__ */ __name((abstract_ply, inventory, item) => {
20
- const ply = PMAPlayer.from_raw(abstract_ply);
20
+ const ply = PMAPlayerWrapper.from_raw(abstract_ply);
21
21
  fn(ply, inventory, item);
22
22
  }, "usable_item_wrapper");
23
23
  exports["pma"].register_usable_item(item_name, usable_item_wrapper);
@@ -30,7 +30,7 @@ class PMA {
30
30
  * @returns the PMAPlayer wrapper, or `null` if the player doesn't exist
31
31
  */
32
32
  static from_source(source) {
33
- return PMAPlayer.from_source(source);
33
+ return PMAPlayerWrapper.from_source(source);
34
34
  }
35
35
  /**
36
36
  * Gets the player from the specified UID
@@ -38,14 +38,14 @@ class PMA {
38
38
  */
39
39
  static from_uid(uid) {
40
40
  const data = exports["pma"].from_uid(uid);
41
- return data ? PMAPlayer.from_raw(data) : null;
41
+ return data ? PMAPlayerWrapper.from_raw(data) : null;
42
42
  }
43
43
  /**
44
44
  * Gets all of the players that habe the specified job(s), and the specified {@param job_rank} if specified.
45
45
  */
46
46
  static get_players_with_job(job_names, job_rank) {
47
47
  const players = exports["pma"].get_players_with_job(job_names, job_rank);
48
- return players.map((v) => PMAPlayer.from_raw(v));
48
+ return players.map((v) => PMAPlayerWrapper.from_raw(v));
49
49
  }
50
50
  /**
51
51
  * Generic logging
@@ -0,0 +1,21 @@
1
+ import type { ItemName, OptionalItem } from "@pma-network/redm-types/Inventory";
2
+ import { CommonAbstractPMAPlayer } from "../shared-server/types/CommonAbstractPMAPlayer";
3
+ export declare abstract class AbstractPMAPlayer extends CommonAbstractPMAPlayer {
4
+ abstract get_item(item_name: ItemName): OptionalItem;
5
+ /**
6
+ * Adds the item with {@param item_name} to the players next free slot
7
+ * @throws This will throw an error if {@param item_name} is invalid, or if {@param quantity} is negative
8
+ * @returns the {@link InventoryItem} that was created, or undefined if there wasn't a free slot to put the item into.
9
+ */
10
+ abstract add_item(item_name: ItemName, quantity: number): OptionalItem;
11
+ /**
12
+ * Removes the item with {@param item_name} from the players inventory
13
+ * @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
14
+ */
15
+ abstract remove_item(item_name: ItemName, quantity: number): void;
16
+ /**
17
+ * Checks if the player has enough of {@param item_name}
18
+ * @returns `true` if they had enough {@param quantity}, `false` otherwise
19
+ */
20
+ abstract has_enough_of_item(item_name: ItemName, quantity: number): boolean;
21
+ }
@@ -0,0 +1,11 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { CommonAbstractPMAPlayer } from "../shared-server/types/CommonAbstractPMAPlayer";
4
+ class AbstractPMAPlayer extends CommonAbstractPMAPlayer {
5
+ static {
6
+ __name(this, "AbstractPMAPlayer");
7
+ }
8
+ }
9
+ export {
10
+ AbstractPMAPlayer
11
+ };
@@ -1,22 +1,25 @@
1
- import type { ItemName, OptionalItem } from "@redm-types/Inventory";
2
- import { CommonPMAPlayer } from "@shared-server/class/CommonPMAPlayer";
3
- import type { CommonAbstractPMAPlayer } from "@shared-server/types/CommonAbstractPMAPlayer";
4
- export declare class PMAPlayer extends CommonPMAPlayer {
1
+ import type { ItemName, OptionalItem } from "@pma-network/redm-types/Inventory";
2
+ import type { NotificationVariant, PMAPartialNotification } from "@pma-network/redm-types/Notifications";
3
+ import { CommonPMAPlayer } from "../shared-server/class/CommonPMAPlayer";
4
+ import type { CommonAbstractPMAPlayer } from "../shared-server/types/CommonAbstractPMAPlayer";
5
+ export declare class PMAPlayerWrapper extends CommonPMAPlayer {
5
6
  #private;
6
7
  /**
7
8
  * Creates the player from the ScRT msgpack'd class
8
9
  */
9
- static from_raw(ply: CommonAbstractPMAPlayer): PMAPlayer;
10
+ static from_raw(ply: CommonAbstractPMAPlayer): PMAPlayerWrapper;
10
11
  /**
11
12
  * Does basic checks that the player exists before lazy initializing the player
12
13
  */
13
- static from_source(source: number): PMAPlayer | null;
14
+ static from_source(source: number): PMAPlayerWrapper | null;
14
15
  /**
15
16
  * Creates the player from the source without doing any validity checks
16
17
  */
17
18
  static from_source_unchecked(source: number): CommonPMAPlayer;
18
19
  constructor(source: number);
19
20
  constructor(pma_player: CommonAbstractPMAPlayer);
21
+ send_notification(title?: string, description?: string, variant?: NotificationVariant, duration?: number): void;
22
+ send_notification_object(partial: PMAPartialNotification): void;
20
23
  get_item(item_name: ItemName): OptionalItem;
21
24
  add_item(item_name: ItemName, quantity: number): OptionalItem;
22
25
  }
@@ -1,9 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { CommonPMAPlayer } from "@shared-server/class/CommonPMAPlayer";
4
- class PMAPlayer extends CommonPMAPlayer {
3
+ import { CommonPMAPlayer } from "../shared-server/class/CommonPMAPlayer";
4
+ class PMAPlayerWrapper extends CommonPMAPlayer {
5
5
  static {
6
- __name(this, "PMAPlayer");
6
+ __name(this, "PMAPlayerWrapper");
7
7
  }
8
8
  // This will get lazy-initialized whenever we actually call a function that needs it,
9
9
  // this will make sure we don't pay the un-needed serialize cost if we're only using this for
@@ -13,7 +13,7 @@ class PMAPlayer extends CommonPMAPlayer {
13
13
  * Creates the player from the ScRT msgpack'd class
14
14
  */
15
15
  static from_raw(ply) {
16
- return new PMAPlayer(ply);
16
+ return new PMAPlayerWrapper(ply);
17
17
  }
18
18
  /**
19
19
  * Does basic checks that the player exists before lazy initializing the player
@@ -22,7 +22,7 @@ class PMAPlayer extends CommonPMAPlayer {
22
22
  if (!DoesPlayerExist(source)) {
23
23
  return null;
24
24
  }
25
- return new PMAPlayer(source);
25
+ return new PMAPlayerWrapper(source);
26
26
  }
27
27
  /**
28
28
  * Creates the player from the source without doing any validity checks
@@ -39,6 +39,17 @@ class PMAPlayer extends CommonPMAPlayer {
39
39
  super(source);
40
40
  }
41
41
  }
42
+ send_notification(title, description, variant = "default", duration = 5e3) {
43
+ const noti = {
44
+ body: description,
45
+ duration,
46
+ variant
47
+ };
48
+ this.emit("pma:add_notifications", noti);
49
+ }
50
+ send_notification_object(partial) {
51
+ this.emit("pma:add_notification", partial);
52
+ }
42
53
  get_item(item_name) {
43
54
  this.ensure_init();
44
55
  return this.#pma_player.get_item(item_name);
@@ -49,5 +60,5 @@ class PMAPlayer extends CommonPMAPlayer {
49
60
  }
50
61
  }
51
62
  export {
52
- PMAPlayer
63
+ PMAPlayerWrapper
53
64
  };
@@ -1,5 +1,5 @@
1
- import { PMAPlayer } from "../class/PMAPlayer";
2
- type PMAServerEventType = (player: PMAPlayer, ...args: any[]) => Promise<void> | void;
1
+ import { PMAPlayerWrapper } from "../class/PMAPlayer";
2
+ type PMAServerEventType = (player: PMAPlayerWrapper, ...args: any[]) => Promise<void> | void;
3
3
  /**
4
4
  * Registers the Net Event call for {@link eventName} to this method
5
5
  *
@@ -1,6 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { PMAPlayer } from "../class/PMAPlayer";
3
+ import { PMAPlayerWrapper } from "../class/PMAPlayer";
4
4
  function OnPMANetEvent(eventName) {
5
5
  return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
6
6
  if (context.private) {
@@ -9,7 +9,7 @@ function OnPMANetEvent(eventName) {
9
9
  context.addInitializer(function() {
10
10
  const _t = this;
11
11
  onNet(eventName, async (...args) => {
12
- const ply = new PMAPlayer(source);
12
+ const ply = new PMAPlayerWrapper(source);
13
13
  if (_t.__permissionMap) {
14
14
  const permissions = _t.__permissionMap.get(context.name);
15
15
  if (permissions) {
@@ -1,5 +1,5 @@
1
+ import type { ItemName } from "@pma-network/redm-types/Inventory";
1
2
  import type { UsableItemCall } from "../types/Inventory";
2
- import type { ItemName } from "@redm-types/Inventory";
3
3
  /**
4
4
  * Registers the {@link item_name} to be usable
5
5
  *
package/index.d.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  export * from "./PMA";
2
2
  export * from "./types/Inventory";
3
+ export * from "./shared-server/CommonPMA";
4
+ export * from "./shared-server/utils/CooldownTracker";
5
+ export * from "./shared-server/utils/FrameworkName";
6
+ export * from "./shared-server/utils/GlobalOverrides";
7
+ export * from "./shared-server/utils/InfractionsWrapper";
8
+ export * from "./shared-server/types/CommonAbstractPMAPlayer";
9
+ export * from "./shared-server/types/CommonNotifications";
10
+ export * from "./shared-server/types/SharedTypes";
11
+ export * from "./shared-server/class/CommonPMAPlayer";
3
12
  export * from "./decors/PMANetEvent";
4
13
  export * from "./decors/RegisterUsableItems";
14
+ export * from "./class/AbstractPMAPlayer";
5
15
  export * from "./class/PMAPlayer";
package/index.js CHANGED
@@ -1,5 +1,15 @@
1
1
  export * from "./PMA";
2
2
  export * from "./types/Inventory";
3
+ export * from "./shared-server/CommonPMA";
4
+ export * from "./shared-server/utils/CooldownTracker";
5
+ export * from "./shared-server/utils/FrameworkName";
6
+ export * from "./shared-server/utils/GlobalOverrides";
7
+ export * from "./shared-server/utils/InfractionsWrapper";
8
+ export * from "./shared-server/types/CommonAbstractPMAPlayer";
9
+ export * from "./shared-server/types/CommonNotifications";
10
+ export * from "./shared-server/types/SharedTypes";
11
+ export * from "./shared-server/class/CommonPMAPlayer";
3
12
  export * from "./decors/PMANetEvent";
4
13
  export * from "./decors/RegisterUsableItems";
14
+ export * from "./class/AbstractPMAPlayer";
5
15
  export * from "./class/PMAPlayer";
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Dillon Skaggs <AvarianKnight>"
6
6
  ],
7
7
  "type": "module",
8
- "version": "0.0.8",
8
+ "version": "0.0.12",
9
9
  "files": [
10
10
  "./**/*.js",
11
11
  "./**/*.d.ts"
@@ -0,0 +1,31 @@
1
+ import { CommonPMAPlayer } from "./class/CommonPMAPlayer";
2
+ import type { PlayerUID } from "./types/SharedTypes";
3
+ /**
4
+ * A wraper around common functions that canbe used both in FiveM and RedM
5
+ */
6
+ export declare class CommonPMA {
7
+ /**
8
+ * Gets the player from the specified source
9
+ * @note the PMAPlayer is lazy initialized so we don't do un-needed scrt
10
+ * calls, this means that we *can* possibly end up in a state where the player
11
+ * isn't initialized, this won't break anything though.
12
+ * @returns the PMAPlayer wrapper, or `null` if the player doesn't exist
13
+ */
14
+ static from_source(source: number): CommonPMAPlayer | null;
15
+ /**
16
+ * Gets the player from the specified UID
17
+ * @returns the PMAPlayer wrapper, or `null` if there wasn't a player
18
+ */
19
+ static from_uid(uid: PlayerUID): CommonPMAPlayer | null;
20
+ /**
21
+ * Gets all of the players that habe the specified job(s), and the specified {@param job_rank} if specified.
22
+ */
23
+ static get_players_with_job(job_names: string | string[], job_rank?: number): CommonPMAPlayer[];
24
+ /**
25
+ * Generic logging
26
+ * TODO: Setup a clickhouse wrapper
27
+ */
28
+ static log(log_message: string, additional_data?: {
29
+ [key: string]: any;
30
+ }): void;
31
+ }
@@ -0,0 +1,44 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { CommonPMAPlayer } from "./class/CommonPMAPlayer";
4
+ import { framework_name } from "./utils/FrameworkName";
5
+ class CommonPMA {
6
+ static {
7
+ __name(this, "CommonPMA");
8
+ }
9
+ /**
10
+ * Gets the player from the specified source
11
+ * @note the PMAPlayer is lazy initialized so we don't do un-needed scrt
12
+ * calls, this means that we *can* possibly end up in a state where the player
13
+ * isn't initialized, this won't break anything though.
14
+ * @returns the PMAPlayer wrapper, or `null` if the player doesn't exist
15
+ */
16
+ static from_source(source) {
17
+ return CommonPMAPlayer.from_source(source);
18
+ }
19
+ /**
20
+ * Gets the player from the specified UID
21
+ * @returns the PMAPlayer wrapper, or `null` if there wasn't a player
22
+ */
23
+ static from_uid(uid) {
24
+ const data = exports[framework_name].from_uid(uid);
25
+ return data ? CommonPMAPlayer.from_raw(data) : null;
26
+ }
27
+ /**
28
+ * Gets all of the players that habe the specified job(s), and the specified {@param job_rank} if specified.
29
+ */
30
+ static get_players_with_job(job_names, job_rank) {
31
+ const players = exports[framework_name].get_players_with_job(job_names, job_rank);
32
+ return players.map((v) => CommonPMAPlayer.from_raw(v));
33
+ }
34
+ /**
35
+ * Generic logging
36
+ * TODO: Setup a clickhouse wrapper
37
+ */
38
+ static log(log_message, additional_data) {
39
+ console.log(log_message, additional_data);
40
+ }
41
+ }
42
+ export {
43
+ CommonPMA
44
+ };
@@ -0,0 +1,42 @@
1
+ import { Player } from "@nativewrappers/server";
2
+ import type { CommonAbstractPMAPlayer } from "../types/CommonAbstractPMAPlayer";
3
+ import type { CommonNotificationVariant, CommonPMAPartialNotification } from "../types/CommonNotifications";
4
+ import type { CallSign, ItemName, PlayerJob, PlayerUID } from "../types/SharedTypes";
5
+ export declare class CommonPMAPlayer extends Player implements CommonAbstractPMAPlayer {
6
+ #private;
7
+ /**
8
+ * Creates the player from the ScRT msgpack'd class
9
+ */
10
+ static from_raw(ply: CommonAbstractPMAPlayer): CommonPMAPlayer;
11
+ /**
12
+ * Does basic checks that the player exists before lazy initializing the player
13
+ */
14
+ static from_source(source: number): CommonPMAPlayer | null;
15
+ /**
16
+ * Creates the player from the source without doing any validity checks
17
+ */
18
+ static from_source_unchecked(source: number): CommonPMAPlayer;
19
+ constructor(source: number);
20
+ constructor(pma_player: CommonAbstractPMAPlayer);
21
+ ensure_init(): void;
22
+ is_player_valid(): boolean;
23
+ send_notification(title?: string, description?: string, variant?: CommonNotificationVariant, duration?: number): void;
24
+ send_notification_object(partial: CommonPMAPartialNotification): void;
25
+ get_sex(): number;
26
+ get_height(): number;
27
+ get_dob(): string;
28
+ get_unique_id(): PlayerUID;
29
+ get_call_sign(): CallSign;
30
+ get_character_name(): string;
31
+ get_log_name(): string;
32
+ get_item(item_name: ItemName): unknown;
33
+ add_item(item_name: ItemName, quantity: number): unknown;
34
+ remove_item(item_name: ItemName, quantity: number): void;
35
+ has_enough_of_item(item_name: ItemName, quantity: number): boolean;
36
+ get_job(): PlayerJob;
37
+ set_job(job_name: string, rank: number): void;
38
+ get_bank(): number;
39
+ add_to_bank(positive_amount: number): void;
40
+ remove_from_bank(negative_amount: number): void;
41
+ save(): Promise<void>;
42
+ }
@@ -0,0 +1,143 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Player } from "@nativewrappers/server";
4
+ import { framework_name } from "../utils/FrameworkName";
5
+ import { pma_get_player_from_id } from "../utils/GlobalOverrides";
6
+ class CommonPMAPlayer extends Player {
7
+ static {
8
+ __name(this, "CommonPMAPlayer");
9
+ }
10
+ // This will get lazy-initialized whenever we actually call a function that needs it,
11
+ // this will make sure we don't pay the un-needed serialize cost if we're only using this for
12
+ // basic nativewrappers types
13
+ #pma_player = null;
14
+ /**
15
+ * Creates the player from the ScRT msgpack'd class
16
+ */
17
+ static from_raw(ply) {
18
+ return new CommonPMAPlayer(ply);
19
+ }
20
+ /**
21
+ * Does basic checks that the player exists before lazy initializing the player
22
+ */
23
+ static from_source(source) {
24
+ if (!DoesPlayerExist(source)) {
25
+ return null;
26
+ }
27
+ return new CommonPMAPlayer(source);
28
+ }
29
+ /**
30
+ * Creates the player from the source without doing any validity checks
31
+ */
32
+ static from_source_unchecked(source) {
33
+ return new CommonPMAPlayer(source);
34
+ }
35
+ constructor(source) {
36
+ if (typeof source !== "number") {
37
+ const ply = source;
38
+ super(ply.source);
39
+ this.#pma_player = ply;
40
+ } else {
41
+ super(source);
42
+ }
43
+ }
44
+ // Ensure we initialize the player whenever we're doing something that needs it.
45
+ ensure_init() {
46
+ if (!this.#pma_player) {
47
+ this.#pma_player = globalThis.pma_get_player_from_id ? (
48
+ // @ts-ignore: we override this in GlobalOverrides
49
+ globalThis.pma_get_player_from_id(this.Source)
50
+ ) : pma_get_player_from_id(this.Source);
51
+ }
52
+ }
53
+ /*
54
+ * This will initialize the player and check that the player exists
55
+ * @returns `true` if the player is loaded in the framework or `false` otherwise
56
+ */
57
+ is_player_valid() {
58
+ this.ensure_init();
59
+ return this.#pma_player !== null;
60
+ }
61
+ send_notification(title, description, variant = "default", duration = 5e3) {
62
+ const noti = {
63
+ body: description,
64
+ duration,
65
+ variant
66
+ };
67
+ this.emit("pma:add_notifications", noti);
68
+ }
69
+ send_notification_object(partial) {
70
+ this.emit("pma:add_notification", partial);
71
+ }
72
+ get_sex() {
73
+ this.ensure_init();
74
+ return this.#pma_player.get_sex();
75
+ }
76
+ get_height() {
77
+ this.ensure_init();
78
+ return this.#pma_player.get_height();
79
+ }
80
+ get_dob() {
81
+ this.ensure_init();
82
+ return this.#pma_player.get_dob();
83
+ }
84
+ get_unique_id() {
85
+ this.ensure_init();
86
+ return this.#pma_player.get_unique_id();
87
+ }
88
+ get_call_sign() {
89
+ this.ensure_init();
90
+ return this.#pma_player.get_call_sign();
91
+ }
92
+ get_character_name() {
93
+ this.ensure_init();
94
+ return this.#pma_player.get_character_name();
95
+ }
96
+ get_log_name() {
97
+ this.ensure_init();
98
+ return this.#pma_player.get_character_name();
99
+ }
100
+ get_item(item_name) {
101
+ this.ensure_init();
102
+ return this.#pma_player.get_item(item_name);
103
+ }
104
+ add_item(item_name, quantity) {
105
+ this.ensure_init();
106
+ return this.#pma_player.add_item(item_name, quantity);
107
+ }
108
+ remove_item(item_name, quantity) {
109
+ this.ensure_init();
110
+ return this.#pma_player.remove_item(item_name, quantity);
111
+ }
112
+ has_enough_of_item(item_name, quantity) {
113
+ this.ensure_init();
114
+ return this.#pma_player.has_enough_of_item(item_name, quantity);
115
+ }
116
+ get_job() {
117
+ this.ensure_init();
118
+ return this.#pma_player.get_job();
119
+ }
120
+ set_job(job_name, rank) {
121
+ this.ensure_init();
122
+ return this.#pma_player.set_job(job_name, rank);
123
+ }
124
+ get_bank() {
125
+ this.ensure_init();
126
+ return this.#pma_player.get_bank();
127
+ }
128
+ add_to_bank(positive_amount) {
129
+ this.ensure_init();
130
+ return this.#pma_player.add_to_bank(positive_amount);
131
+ }
132
+ remove_from_bank(negative_amount) {
133
+ this.ensure_init();
134
+ return this.#pma_player.remove_from_bank(negative_amount);
135
+ }
136
+ save() {
137
+ this.ensure_init();
138
+ return this.#pma_player.save();
139
+ }
140
+ }
141
+ export {
142
+ CommonPMAPlayer
143
+ };
@@ -0,0 +1,48 @@
1
+ import type { CallSign, ItemName, PlayerJob, PlayerUID } from "./SharedTypes";
2
+ export declare abstract class CommonAbstractPMAPlayer {
3
+ abstract get_sex(): number;
4
+ abstract get_height(): number;
5
+ abstract get_dob(): string;
6
+ abstract get_unique_id(): PlayerUID;
7
+ abstract get_call_sign(): CallSign;
8
+ abstract get_character_name(): string;
9
+ abstract get_log_name(): string;
10
+ abstract get_item(item_name: ItemName): unknown;
11
+ /**
12
+ * Adds the item with {@param item_name} to the players next free slot
13
+ *
14
+ * On RedM this will return `InventoryItem` on FiveM this will return `void`
15
+ *
16
+ * @throws This will throw an error if {@param item_name} is invalid, or if {@param quantity} is negative
17
+ * @returns the {@link InventoryItem} that was created, or undefined if there wasn't a free slot to put the item into.
18
+ */
19
+ abstract add_item(item_name: ItemName, quantity: number): unknown;
20
+ /**
21
+ * Removes the item with {@param item_name} from the players inventory
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
+ */
24
+ abstract remove_item(item_name: ItemName, quantity: number): void;
25
+ /**
26
+ * Checks if the player has enough of {@param item_name}
27
+ * @returns `true` if they had enough {@param quantity}, `false` otherwise
28
+ */
29
+ abstract has_enough_of_item(item_name: ItemName, quantity: number): boolean;
30
+ abstract get_job(): PlayerJob;
31
+ /**
32
+ * Sets the players job to the specified {@param job_name} and {@param rank}
33
+ * @throws This will throw if the players job is invalid
34
+ */
35
+ abstract set_job(job_name: string, rank: number): void;
36
+ abstract get_bank(): number;
37
+ /**
38
+ * Adds the {@param positive_amount} to the players bank.
39
+ * @throws if {@param positive_amount} is negative this will throw an error.
40
+ */
41
+ abstract add_to_bank(positive_amount: number): void;
42
+ /**
43
+ * Removes the {@param negative_amount} to the players bank.
44
+ * @throws if {@param negative_amount} is positive this will throw an error.
45
+ */
46
+ abstract remove_from_bank(negative_amount: number): void;
47
+ abstract save(): Promise<void>;
48
+ }
@@ -0,0 +1,10 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class CommonAbstractPMAPlayer {
4
+ static {
5
+ __name(this, "CommonAbstractPMAPlayer");
6
+ }
7
+ }
8
+ export {
9
+ CommonAbstractPMAPlayer
10
+ };
@@ -0,0 +1,12 @@
1
+ export type Position = "top-left" | "top-center" | "top-right" | "middle-left" | "middle" | "middle-right" | "bottom-left" | "bottom-center" | "bottom-right";
2
+ export type CommonNotificationVariant = "default" | "error" | "success";
3
+ export type CommonPMAPartialNotification = Omit<CommonPMANotification, "id">;
4
+ export type CommonPMANotification = {
5
+ id: number;
6
+ title?: string;
7
+ body?: string;
8
+ variant: CommonNotificationVariant;
9
+ duration?: number;
10
+ position?: Position;
11
+ timeout?: number;
12
+ };
File without changes
@@ -0,0 +1,8 @@
1
+ export type ItemName = string;
2
+ export type Source = number;
3
+ export type PlayerUID = number;
4
+ export type CallSign = string | undefined;
5
+ export type PlayerJob = {
6
+ name: string;
7
+ rank: number;
8
+ };
File without changes
@@ -0,0 +1,8 @@
1
+ type CooldownTrackerCallback = (src: number, details: string) => void;
2
+ export declare class CooldownTracker {
3
+ #private;
4
+ constructor(cooldown: number, cb: CooldownTrackerCallback);
5
+ private player_dropped;
6
+ try_add_cooldown(src: number, additional_details: string): boolean;
7
+ }
8
+ export {};
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Event } from "@nativewrappers/server";
4
+ class CooldownTracker {
5
+ static {
6
+ __name(this, "CooldownTracker");
7
+ }
8
+ #cooldown_map = /* @__PURE__ */ new Map();
9
+ #cooldown;
10
+ #cb;
11
+ constructor(cooldown, cb) {
12
+ this.#cooldown = cooldown;
13
+ this.#cb = cb;
14
+ }
15
+ @Event("playerDropped")
16
+ player_dropped() {
17
+ this.#cooldown_map.delete(source);
18
+ }
19
+ /*
20
+ * @returns This returns `true` if it was successful in adding the player, or `false` the user already existed on the list
21
+ */
22
+ try_add_cooldown(src, additional_details) {
23
+ const gt = GetGameTimer();
24
+ const time = this.#cooldown_map.get(src);
25
+ if (!time || time < gt) {
26
+ this.#cooldown_map.set(src, gt + this.#cooldown);
27
+ return true;
28
+ }
29
+ this.#cb(src, additional_details);
30
+ return false;
31
+ }
32
+ }
33
+ export {
34
+ CooldownTracker
35
+ };
@@ -0,0 +1 @@
1
+ export declare const framework_name: string;
@@ -0,0 +1,4 @@
1
+ const framework_name = GetGameName() === "fivem" ? "pma-framework" : "pma";
2
+ export {
3
+ framework_name
4
+ };
@@ -0,0 +1,3 @@
1
+ import type { CommonPMAPlayer } from "../class/CommonPMAPlayer";
2
+ import type { Source } from "../types/SharedTypes";
3
+ export declare function pma_get_player_from_id(source: Source): CommonPMAPlayer;
@@ -0,0 +1,11 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { framework_name } from "./FrameworkName";
4
+ function pma_get_player_from_id(source) {
5
+ return exports[framework_name].from_source(source);
6
+ }
7
+ __name(pma_get_player_from_id, "pma_get_player_from_id");
8
+ globalThis.pma_get_player_from_id = pma_get_player_from_id;
9
+ export {
10
+ pma_get_player_from_id
11
+ };
File without changes
File without changes
@@ -1,7 +1,7 @@
1
- import type { PMAPlayer } from "../class/PMAPlayer";
2
- import type { BaseInventory, InventoryItem } from "@redm-types/Inventory";
3
- import type { AbstractPMAPlayer } from "@redm-types/PMAPlayer";
4
- export type UsableItemCall = (ply: PMAPlayer, inventory: BaseInventory, item: InventoryItem) => void;
1
+ import type { BaseInventory, InventoryItem } from "@pma-network/redm-types/Inventory";
2
+ import type { AbstractPMAPlayer } from "../class/AbstractPMAPlayer";
3
+ import type { PMAPlayerWrapper } from "../class/PMAPlayer";
4
+ export type UsableItemCall = (ply: PMAPlayerWrapper, inventory: BaseInventory, item: InventoryItem) => void;
5
5
  export type UsableItemCallShared = (ply: AbstractPMAPlayer, inventory: BaseInventory, item: InventoryItem) => void;
6
6
  export type UsableItems = {
7
7
  fn: UsableItemCallShared;