lenix 1.7.3 → 1.7.5
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 +44 -10
- package/package.json +1 -1
- package/shared/index.ts +1 -0
- package/shared/repeat.ts +32 -0
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,11 +97,8 @@ export const client: {
|
|
|
83
97
|
return coords
|
|
84
98
|
})(),
|
|
85
99
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
y: number,
|
|
89
|
-
z: number,
|
|
90
|
-
h?: number,
|
|
100
|
+
/* */
|
|
101
|
+
teleport: (x, y, z, h,
|
|
91
102
|
entity = client.entity.handle(),
|
|
92
103
|
clearArea = false,
|
|
93
104
|
alive = true,
|
|
@@ -97,6 +108,29 @@ export const client: {
|
|
|
97
108
|
SetEntityCoords(entity, x, y, z, alive, deadDisable, ragdol, clearArea)
|
|
98
109
|
SetEntityHeading(entity, h ?? client.entity.coords()[3])
|
|
99
110
|
},
|
|
111
|
+
|
|
112
|
+
/* */
|
|
113
|
+
playAnim: async (dict, name,
|
|
114
|
+
blendIn = 2.0,
|
|
115
|
+
blendOut = 2.0,
|
|
116
|
+
ped = client.entity.handle(),
|
|
117
|
+
duration = -1,
|
|
118
|
+
flag = 0,
|
|
119
|
+
playbackFrom = 0.0,
|
|
120
|
+
x = false,
|
|
121
|
+
y = false,
|
|
122
|
+
z = false
|
|
123
|
+
) => {
|
|
124
|
+
RequestAnimDict(dict)
|
|
125
|
+
await repeat(() => HasAnimDictLoaded(dict), true)
|
|
126
|
+
TaskPlayAnim(ped, dict, name, blendIn, blendOut, duration, flag, playbackFrom, x, y, z)
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
/* */
|
|
130
|
+
stopAnim: (dict: string, ped = client.entity.handle()) => {
|
|
131
|
+
RemoveAnimDict(dict)
|
|
132
|
+
ClearPedTasks(ped)
|
|
133
|
+
}
|
|
100
134
|
},
|
|
101
135
|
player: {
|
|
102
136
|
/**
|
|
@@ -111,7 +145,7 @@ export const client: {
|
|
|
111
145
|
* - id(targetServerId) -> target player's client player ID
|
|
112
146
|
* - id() -> your own client player ID
|
|
113
147
|
*/
|
|
114
|
-
id: (serverId
|
|
148
|
+
id: (serverId) => serverId ? GetPlayerFromServerId(serverId) : PlayerId(),
|
|
115
149
|
|
|
116
150
|
/**
|
|
117
151
|
* Gets a player's server ID from their client player ID.
|
|
@@ -128,9 +162,9 @@ export const client: {
|
|
|
128
162
|
serverId: (playerId = client.player.id()) => GetPlayerServerId(playerId),
|
|
129
163
|
|
|
130
164
|
storage: {
|
|
131
|
-
set:
|
|
132
|
-
get:
|
|
133
|
-
delete:
|
|
165
|
+
set: (key, value) => SetResourceKvp(key, value),
|
|
166
|
+
get: (key) => GetResourceKvpString(key),
|
|
167
|
+
delete: (key) => DeleteResourceKvp(key)
|
|
134
168
|
}
|
|
135
169
|
}
|
|
136
170
|
}
|
package/package.json
CHANGED
package/shared/index.ts
CHANGED
package/shared/repeat.ts
ADDED
|
@@ -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
|
+
}
|