pma-locals 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. package/README.md +61 -27
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,19 +1,13 @@
1
- # pma-locals
2
-
3
- Modern TypeScript library for managing RedM ped spawning and animations.
4
-
5
- ## Installation
6
-
7
1
  ```bash
8
2
  npm install pma-locals
9
3
  # or
10
4
  pnpm add pma-locals
11
5
  ```
12
6
 
13
- ## Usage
7
+ ## Quick Start
14
8
 
15
9
  ```typescript
16
- import { registerPed, processSpawning } from "pma-locals";
10
+ import { registerPed, processSpawning, cleanupPeds } from "pma-locals";
17
11
  import { Vector3, Delay } from "@nativewrappers/redm";
18
12
 
19
13
  // Register a ped with animation
@@ -22,6 +16,7 @@ registerPed(
22
16
  new Vector3(-297.74, 791.1, 118.4), // spawn coords
23
17
  180.0, // heading
24
18
  50.0, // spawn distance (optional, default: 100.0)
19
+ true, // disable collisions
25
20
  {
26
21
  dict: "amb_wander@world_human_smoke@male@male_a@idle_a",
27
22
  anim: "idle_a",
@@ -31,47 +26,86 @@ registerPed(
31
26
 
32
27
  // In your game loop
33
28
  setTick(async () => {
34
- const playerPed = PlayerPedId();
35
- if (!playerPed) return;
29
+ const playerPed = Game.PlayerPed;
36
30
 
37
- const coords = GetEntityCoords(playerPed, true, true);
38
- const playerPos = new Vector3(coords[0], coords[1], coords[2]);
39
-
40
- await processSpawning(playerPos);
31
+ await processSpawning(playerPed.Position);
41
32
  await Delay(500);
42
33
  });
34
+
35
+ // Cleanup on resource stop
36
+ on("onResourceStop", (resourceName: string) => {
37
+ if (resourceName === GetCurrentResourceName()) {
38
+ cleanupPeds();
39
+ }
40
+ });
43
41
  ```
44
42
 
45
- ## API
43
+ ## API Reference
46
44
 
47
45
  ### `registerPed(modelName, coords, heading, spawnDistance?, animation?, propData?)`
48
46
 
49
- Register a ped to spawn when players approach.
47
+ Register a ped to spawn when players are within range.
50
48
 
51
49
  **Parameters:**
52
50
 
53
51
  - `modelName` (number): Model hash
54
52
  - `coords` (Vector3): Spawn coordinates
55
- - `heading` (number): Ped heading direction
56
- - `spawnDistance` (number): Distance threshold (default: 100.0)
57
- - `animation` (Animation): Optional animation data
58
- - `propData` (Props): Optional prop attachment
53
+ - `heading` (number): Ped heading direction (0-360)
54
+ - `spawnDistance?` (number): Distance threshold (default: 100.0)
55
+ - `collisions?` (boolean): Optional collision handler
56
+ - `animation?` (Animation): Optional animation config
57
+ - `dict` (string): Animation dictionary
58
+ - `anim` (string): Animation name
59
+ - `propData?` (Props): Optional prop attachment
60
+ - `model` (string): Prop model hash
61
+ - `boneId` (number): Bone to attach to
62
+ - `offset` (number[]): Position offset [x, y, z]
63
+ - `rotation` (number[]): Rotation [x, y, z]
59
64
 
60
65
  ### `processSpawning(playerPos: Vector3)`
61
66
 
62
- Update ped spawning based on player position. Call this in your game loop.
67
+ Process ped spawning/despawning based on player position. Call this regularly in your game loop (e.g., every 500ms).
63
68
 
64
69
  ### `cleanupPeds()`
65
70
 
66
- Delete all spawned peds (useful for resource cleanup).
71
+ Delete all spawned peds. Use this when your resource stops to clean up entities.
72
+
73
+ ## TypeScript Support
74
+
75
+ Full type definitions are included. Import types as needed:
67
76
 
68
- ## Types
77
+ ```typescript
78
+ import type { PedConfig, Animation, Props } from "pma-locals";
79
+ ```
80
+
81
+ **Exported Types:**
82
+
83
+ - `PedConfig` - Complete ped configuration
84
+ - `Animation` - Animation data structure
85
+ - `Props` - Prop attachment configuration
86
+
87
+ ## Development
88
+
89
+ ```bash
90
+ # Install dependencies
91
+ pnpm install
92
+
93
+ # Build package (creates dist/ with .js and .d.ts files)
94
+ pnpm build:package
95
+
96
+ # RedM development mode (watch)
97
+ pnpm watch
98
+
99
+ # Publish to npm
100
+ npm version patch
101
+ pnpm publish
102
+ ```
69
103
 
70
- Full TypeScript support with exported types:
104
+ **Built with:**
71
105
 
72
- - `PedConfig`
73
- - `Animation`
74
- - `Props`
106
+ - [tsup](https://tsup.egoist.dev/) - TypeScript bundler
107
+ - [esbuild](https://esbuild.github.io/) - Fast JavaScript bundler
108
+ - [@nativewrappers/redm](https://www.npmjs.com/package/@nativewrappers/redm) - RedM type definitions
75
109
 
76
110
  ## License
77
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pma-locals",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "RedM ped spawning and management library with TypeScript support",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",