pma-locals-fivem
v1.0.29
Published
FiveM ped spawning and management library with TypeScript support
Maintainers
Readme
npm install pma-locals
# or
pnpm add pma-localsQuick Start
import { registerPed, processSpawning, cleanupPeds } from "pma-locals";
import { Vector3, Delay } from "@nativewrappers/redm";
// Register a ped with animation
registerPed(
0x12345678, // model hash
new Vector3(-297.74, 791.1, 118.4), // spawn coords
180.0, // heading
50.0, // spawn distance (optional, default: 100.0)
true, // disable collisions
{
dict: "amb_wander@world_human_smoke@male@male_a@idle_a",
anim: "idle_a",
}, // optional animation
undefined // optional prop data
);
// In your game loop
setTick(async () => {
const playerPed = Game.PlayerPed;
await processSpawning(playerPed.Position);
await Delay(500);
});
// Cleanup on resource stop
on("onResourceStop", (resourceName: string) => {
if (resourceName === GetCurrentResourceName()) {
cleanupPeds();
}
});API Reference
registerPed(modelName, coords, heading, spawnDistance?, animation?, propData?)
Register a ped to spawn when players are within range.
Parameters:
modelName(number): Model hashcoords(Vector3): Spawn coordinatesheading(number): Ped heading direction (0-360)spawnDistance?(number): Distance threshold (default: 100.0)collisions?(boolean): Optional collision handleranimation?(Animation): Optional animation configdict(string): Animation dictionaryanim(string): Animation name
propData?(Props): Optional prop attachmentmodel(string): Prop model hashboneId(number): Bone to attach tooffset(number[]): Position offset [x, y, z]rotation(number[]): Rotation [x, y, z]
processSpawning(playerPos: Vector3)
Process ped spawning/despawning based on player position. Call this regularly in your game loop (e.g., every 500ms).
cleanupPeds()
Delete all spawned peds. Use this when your resource stops to clean up entities.
TypeScript Support
Full type definitions are included. Import types as needed:
import type { PedConfig, Animation, Props } from "pma-locals";Exported Types:
PedConfig- Complete ped configurationAnimation- Animation data structureProps- Prop attachment configuration
Development
# Install dependencies
pnpm install
# Build package (creates dist/ with .js and .d.ts files)
pnpm build:package
# RedM development mode (watch)
pnpm watch
# Publish to npm
npm version patch
pnpm publishBuilt with:
- tsup - TypeScript bundler
- esbuild - Fast JavaScript bundler
- @nativewrappers/redm - RedM type definitions
License
ISC
