lenix 1.7.3 → 1.7.4

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/client/client.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import { repeat } from '../shared/repeat.ts'
1
2
  import type { Vec3, Vec4 } from '../shared/types.ts'
2
3
 
3
-
4
4
  export const client: {
5
5
  entity: {
6
6
  handle: (entityNetId?: number) => number
@@ -20,6 +20,20 @@ export const client: {
20
20
  deadDisable?: boolean,
21
21
  ragdol?: boolean
22
22
  ) => void
23
+ playAnim: (
24
+ dict: string,
25
+ name: string,
26
+ blendIn: number,
27
+ blendOut: number,
28
+ ped: number,
29
+ duration: number,
30
+ flag: number,
31
+ playbackFrom: number,
32
+ x: boolean,
33
+ y: boolean,
34
+ z: boolean
35
+ ) => Promise<void>
36
+ stopAnim: (dict: string, ped?: number) => void
23
37
  }
24
38
  player: {
25
39
  serverId: (playerId?: number) => number
@@ -83,6 +97,7 @@ export const client: {
83
97
  return coords
84
98
  })(),
85
99
 
100
+ /* */
86
101
  teleport: (
87
102
  x: number,
88
103
  y: number,
@@ -97,6 +112,31 @@ export const client: {
97
112
  SetEntityCoords(entity, x, y, z, alive, deadDisable, ragdol, clearArea)
98
113
  SetEntityHeading(entity, h ?? client.entity.coords()[3])
99
114
  },
115
+
116
+ /* */
117
+ playAnim: async (
118
+ dict: string,
119
+ name: string,
120
+ blendIn = 2.0,
121
+ blendOut = 2.0,
122
+ ped = client.entity.handle(),
123
+ duration = -1,
124
+ flag = 0,
125
+ playbackFrom = 0.0,
126
+ x = false,
127
+ y = false,
128
+ z = false
129
+ ) => {
130
+ RequestAnimDict(dict)
131
+ await repeat(() => HasAnimDictLoaded(dict), true)
132
+ TaskPlayAnim(ped, dict, name, blendIn, blendOut, duration, flag, playbackFrom, x, y, z)
133
+ },
134
+
135
+ /* */
136
+ stopAnim: (dict: string, ped = client.entity.handle()) => {
137
+ RemoveAnimDict(dict)
138
+ ClearPedTasks(ped)
139
+ }
100
140
  },
101
141
  player: {
102
142
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lenix",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
4
4
  "description": "Typed FiveM utilities for client, server, shared, and NUI scripts",
5
5
  "author": "Lenix",
6
6
  "license": "MIT",
package/shared/index.ts CHANGED
@@ -6,3 +6,4 @@
6
6
 
7
7
  export * from './assert.ts'
8
8
  export * from './types.ts'
9
+ export * from './repeat.ts'
@@ -0,0 +1,32 @@
1
+ /* */
2
+ export function repeat<T>(
3
+ until: () => T,
4
+ ): Promise<T>
5
+ export function repeat<T, const C extends T>(
6
+ until: () => T,
7
+ equal: C,
8
+ each?: number,
9
+ ): Promise<C>
10
+ export function repeat <T>(
11
+ until: () => T,
12
+ equal?: T,
13
+ each?: number
14
+ ): Promise<T> {
15
+ return new Promise(resolve => {
16
+ const interval = setInterval(() => {
17
+ const result = until()
18
+
19
+ if (equal === undefined) {
20
+ if (result === undefined || result === null) return
21
+ resolve(result)
22
+ clearInterval(interval)
23
+ return
24
+ }
25
+
26
+ if (!result !== equal) return
27
+
28
+ resolve(equal ?? result)
29
+ clearInterval(interval)
30
+ }, each)
31
+ })
32
+ }