@pma-network/redm-types 0.0.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/Inventory.d.ts +51 -0
- package/Inventory.js +20 -0
- package/Notifications.d.ts +12 -0
- package/Notifications.js +0 -0
- package/PMAPlayer.d.ts +52 -0
- package/PMAPlayer.js +10 -0
- package/README.md +45 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +18 -0
package/Inventory.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type InventoryType = "player" | "horse" | "localHorse" | "ground";
|
|
2
|
+
export type Bitwise<T> = T;
|
|
3
|
+
export declare enum ItemFlags {
|
|
4
|
+
None = 0,
|
|
5
|
+
CantBeStolen = 2,
|
|
6
|
+
Usable = 4,
|
|
7
|
+
IsWeapon = 8,
|
|
8
|
+
IsAmmo = 8,
|
|
9
|
+
Stackable = 32
|
|
10
|
+
}
|
|
11
|
+
export type ItemName = string;
|
|
12
|
+
export type ItemId = number;
|
|
13
|
+
export interface ItemData {
|
|
14
|
+
item_id: ItemId;
|
|
15
|
+
name: ItemName;
|
|
16
|
+
weight: number;
|
|
17
|
+
flags: Bitwise<ItemFlags>;
|
|
18
|
+
stack_limit: number;
|
|
19
|
+
label: string;
|
|
20
|
+
description: string;
|
|
21
|
+
}
|
|
22
|
+
export interface InventoryItem {
|
|
23
|
+
item_data_ref: ItemData;
|
|
24
|
+
quantity: number;
|
|
25
|
+
}
|
|
26
|
+
export type OptionalItem = InventoryItem | null | undefined;
|
|
27
|
+
export declare abstract class BaseInventory {
|
|
28
|
+
/**
|
|
29
|
+
* Gets the item with {@link item_name}
|
|
30
|
+
* @returns the {@link InventoryItem} or undefined if the player doesn't have that item in their inventory.
|
|
31
|
+
*/
|
|
32
|
+
abstract get_item(item_name: ItemName): OptionalItem;
|
|
33
|
+
/**
|
|
34
|
+
* Adds the item with {@link item_name} to the players next free slot
|
|
35
|
+
* @throws This will throw an error if {@link item_name} is invalid, or if {@link quantity} is negative
|
|
36
|
+
* @returns the {@link InventoryItem} that was created, or undefined if there wasn't a free slot to put the item into.
|
|
37
|
+
*/
|
|
38
|
+
abstract add_item(item_name: ItemName, quantity: number): OptionalItem;
|
|
39
|
+
/**
|
|
40
|
+
* Removes the item with {@link item_name} from the players inventory
|
|
41
|
+
* @throws This will throw an error if there wasn't enough {@link quantity} in the players inventory, you should use use {@link has_enough_of_item} to check before calling
|
|
42
|
+
* @param item_name the item to remove
|
|
43
|
+
* @param quantity the amount of the item to remove
|
|
44
|
+
*/
|
|
45
|
+
abstract remove_item(item_name: ItemName, quantity: number): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if the player has enough of {@link item_name}
|
|
48
|
+
* @returns `true` if they had enough {@link quantity}, `false` otherwise
|
|
49
|
+
*/
|
|
50
|
+
abstract has_enough_of_item(item_name: ItemName, quantity: number): boolean;
|
|
51
|
+
}
|
package/Inventory.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var ItemFlags = /* @__PURE__ */ ((ItemFlags2) => {
|
|
4
|
+
ItemFlags2[ItemFlags2["None"] = 0] = "None";
|
|
5
|
+
ItemFlags2[ItemFlags2["CantBeStolen"] = 2] = "CantBeStolen";
|
|
6
|
+
ItemFlags2[ItemFlags2["Usable"] = 4] = "Usable";
|
|
7
|
+
ItemFlags2[ItemFlags2["IsWeapon"] = 8] = "IsWeapon";
|
|
8
|
+
ItemFlags2[ItemFlags2["IsAmmo"] = 8] = "IsAmmo";
|
|
9
|
+
ItemFlags2[ItemFlags2["Stackable"] = 32] = "Stackable";
|
|
10
|
+
return ItemFlags2;
|
|
11
|
+
})(ItemFlags || {});
|
|
12
|
+
class BaseInventory {
|
|
13
|
+
static {
|
|
14
|
+
__name(this, "BaseInventory");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
BaseInventory,
|
|
19
|
+
ItemFlags
|
|
20
|
+
};
|
|
@@ -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 NotificationVariant = "default" | "error" | "success";
|
|
3
|
+
export type PMAPartialNotification = Omit<PMANotification, "id">;
|
|
4
|
+
export type PMANotification = {
|
|
5
|
+
id: number;
|
|
6
|
+
title?: string;
|
|
7
|
+
body?: string;
|
|
8
|
+
variant: NotificationVariant;
|
|
9
|
+
duration?: number;
|
|
10
|
+
position?: Position;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
};
|
package/Notifications.js
ADDED
|
File without changes
|
package/PMAPlayer.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ItemName, OptionalItem } from "./Inventory";
|
|
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
|
+
};
|
|
9
|
+
export declare abstract class AbstractPMAPlayer {
|
|
10
|
+
abstract get_sex(): number;
|
|
11
|
+
abstract get_height(): number;
|
|
12
|
+
abstract get_dob(): string;
|
|
13
|
+
abstract get_unique_id(): PlayerUID;
|
|
14
|
+
abstract get_call_sign(): CallSign;
|
|
15
|
+
abstract get_character_name(): string;
|
|
16
|
+
abstract get_log_name(): string;
|
|
17
|
+
abstract get_item(item_name: ItemName): OptionalItem;
|
|
18
|
+
/**
|
|
19
|
+
* Adds the item with {@param item_name} to the players next free slot
|
|
20
|
+
* @throws This will throw an error if {@param item_name} is invalid, or if {@param quantity} is negative
|
|
21
|
+
* @returns the {@link InventoryItem} that was created, or undefined if there wasn't a free slot to put the item into.
|
|
22
|
+
*/
|
|
23
|
+
abstract add_item(item_name: ItemName, quantity: number): OptionalItem;
|
|
24
|
+
/**
|
|
25
|
+
* Removes the item with {@param item_name} from the players inventory
|
|
26
|
+
* @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
|
|
27
|
+
*/
|
|
28
|
+
abstract remove_item(item_name: ItemName, quantity: number): void;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the player has enough of {@param item_name}
|
|
31
|
+
* @returns `true` if they had enough {@param quantity}, `false` otherwise
|
|
32
|
+
*/
|
|
33
|
+
abstract has_enough_of_item(item_name: ItemName, quantity: number): boolean;
|
|
34
|
+
abstract get_job(): PlayerJob;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the players job to the specified {@param job_name} and {@param rank}
|
|
37
|
+
* @throws This will throw if the players job is invalid
|
|
38
|
+
*/
|
|
39
|
+
abstract set_job(job_name: string, rank: number): void;
|
|
40
|
+
abstract get_bank(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Adds the {@param positive_amount} to the players bank.
|
|
43
|
+
* @throws if {@param positive_amount} is negative this will throw an error.
|
|
44
|
+
*/
|
|
45
|
+
abstract add_to_bank(positive_amount: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Removes the {@param negative_amount} to the players bank.
|
|
48
|
+
* @throws if {@param negative_amount} is positive this will throw an error.
|
|
49
|
+
*/
|
|
50
|
+
abstract remove_from_bank(negative_amount: number): void;
|
|
51
|
+
abstract save(): Promise<void>;
|
|
52
|
+
}
|
package/PMAPlayer.js
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<h1 align="center">Monorepo for a FiveM server/client wrapper</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<i>🔥 A Javascript/Typescript package for FiveM resource development 🎮</i>
|
|
5
|
+
<br>
|
|
6
|
+
<small>This project is in no way affiliated with FiveM or the Cfx.re Collective.</small>
|
|
7
|
+
</br></br>
|
|
8
|
+
<a href="https://github.com/nativewrappers/nativewrappers/blob/master/LICENSE">
|
|
9
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat" alt="License: MIT">
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@nativewrappers/fivem">
|
|
12
|
+
<img src="https://img.shields.io/npm/v/@nativewrappers/fivem?style=flat" alt="npm version">
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@nativewrappers/fivem">
|
|
15
|
+
<img src="https://img.shields.io/npm/dm/@nativewrappers/fivem?style=flat">
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://github.com/nativewrappers/nativewrappers/actions/workflows/config.yml">
|
|
18
|
+
<img src="https://github.com/nativewrappers/nativewrappers/actions/workflows/config.yml/badge.svg" alt="Workflow Status">
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://github.com/nativewrappers/nativewrappers/commits/master">
|
|
21
|
+
<img src="https://img.shields.io/github/last-commit/nativewrappers/fivem.svg?style=flat" alt="Last commit">
|
|
22
|
+
</a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<h3 align="center">This project is currently iterating rapidly, there will be breaking changes.</h3>
|
|
26
|
+
|
|
27
|
+
<p align="center">
|
|
28
|
+
<h2 align="center"><a href="https://github.com/nativewrappers/nativewrappers/tree/main/docs">Documentation</a></h2>
|
|
29
|
+
<!-- <a href="https://forum.fivem.net/t/fivem-js-v1-3-2-javascript-typescript-wrapper-now-with-menu-class-nativeui/268640">Forum</a> -->
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- No runtime dependencies
|
|
35
|
+
- Entity management through class objects (i.e. `Vehicle` and `Ped` entities)
|
|
36
|
+
- Server and Client side variants on wrapper
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Download & Install
|
|
40
|
+
```
|
|
41
|
+
pnpm add @nativewrappers/redm # for redm,
|
|
42
|
+
pnpm add @nativewrappers/fivem # for fivem
|
|
43
|
+
pnpm add @nativewrappers/common # for any, should be game agnostic, provides Vector3, decors, kvps, helper functions, etc
|
|
44
|
+
pnpm add @nativewrappers/server # for server
|
|
45
|
+
```
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pma-network/redm-types",
|
|
3
|
+
"description": "Native wrappers and utilities for use with PMA RedM Server.",
|
|
4
|
+
"contributors": [
|
|
5
|
+
"Dillon Skaggs <AvarianKnight>"
|
|
6
|
+
],
|
|
7
|
+
"type": "module",
|
|
8
|
+
"version": "0.0.1",
|
|
9
|
+
"files": [
|
|
10
|
+
"./**/*.js",
|
|
11
|
+
"./**/*.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./index.js",
|
|
16
|
+
"./*": "./*"
|
|
17
|
+
}
|
|
18
|
+
}
|