lenix 1.7.2 → 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 +41 -1
- package/client/nearest.ts +4 -4
- 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,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,
|
|
@@ -96,6 +111,31 @@ export const client: {
|
|
|
96
111
|
) => {
|
|
97
112
|
SetEntityCoords(entity, x, y, z, alive, deadDisable, ragdol, clearArea)
|
|
98
113
|
SetEntityHeading(entity, h ?? client.entity.coords()[3])
|
|
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)
|
|
99
139
|
}
|
|
100
140
|
},
|
|
101
141
|
player: {
|
package/client/nearest.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// deno-lint-ignore-file no-undef
|
|
2
2
|
import type { Vec3 } from '../shared/types.ts'
|
|
3
|
-
import {
|
|
3
|
+
import { client } from './client.ts'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Finds the nearest coordinates from a list.
|
|
@@ -52,7 +52,7 @@ const player = (
|
|
|
52
52
|
// deno-lint-ignore no-boolean-literal-for-arguments
|
|
53
53
|
const vehicle = GetVehiclePedIsIn(playerPed, false)
|
|
54
54
|
const playerCoords: Vec3 = vehicle === 0
|
|
55
|
-
?
|
|
55
|
+
? client.entity.coords(true, playerPed)
|
|
56
56
|
: GetWorldPositionOfEntityBone(playerPed, 0) as Vec3
|
|
57
57
|
|
|
58
58
|
const distance = Vdist(
|
|
@@ -86,14 +86,14 @@ const player = (
|
|
|
86
86
|
* Finds the nearest vehicle around an entity.
|
|
87
87
|
*/
|
|
88
88
|
const vehicle = (entity: number, radialSpace: number): number | undefined => {
|
|
89
|
-
const coords: Vec3 =
|
|
89
|
+
const coords: Vec3 = client.entity.coords(true, entity)
|
|
90
90
|
const vehicles = GetGamePool('CVehicle') as number[]
|
|
91
91
|
|
|
92
92
|
let closest: number | undefined
|
|
93
93
|
let closestDistance = radialSpace
|
|
94
94
|
|
|
95
95
|
for (const vehicle of vehicles) {
|
|
96
|
-
const vehCoords: Vec3 =
|
|
96
|
+
const vehCoords: Vec3 = client.entity.coords(true, vehicle)
|
|
97
97
|
const x = coords[0] - vehCoords[0]
|
|
98
98
|
const y = coords[1] - vehCoords[1]
|
|
99
99
|
const z = coords[2] - vehCoords[2]
|
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
|
+
}
|