lenix 1.7.0 → 1.7.1

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/blip.ts CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  import type { Vec4 } from '../shared/types.ts'
4
4
 
5
-
6
5
  export interface Blip {
7
6
  /**
8
7
  * Blip world coordinates and heading.
@@ -0,0 +1,98 @@
1
+ import type { Vec3, Vec4 } from '../shared/types.ts'
2
+
3
+ export const client: {
4
+ entity: {
5
+ handle: (entityNetId?: number) => number;
6
+ netId: (entity?: number) => number;
7
+ coords: {
8
+ (excludeH: true, entity?: number, isAlive?: boolean): Vec3;
9
+ (excludeH?: false, entity?: number, isAlive?: boolean): Vec4;
10
+ };
11
+ };
12
+ player: {
13
+ serverId: (playerId?: number) => number;
14
+ id: (serverId?: number) => number;
15
+ };
16
+ } = {
17
+ entity: {
18
+ /**
19
+ * Gets the local entity handle from a network ID.
20
+ *
21
+ * Network IDs are shared, but entity handles are local.
22
+ * The returned handle is only valid on the current machine.
23
+ *
24
+ * If no network ID is provided, this resolves your own player ped
25
+ * by first getting its network ID.
26
+ *
27
+ * Examples:
28
+ * - entity(vehicleNetId) -> local vehicle handle
29
+ * - entity(pedNetId) -> local ped handle
30
+ * - entity() -> your own player ped handle
31
+ */
32
+ handle: (entityNetId = client.entity.netId()) => NetworkGetEntityFromNetworkId(entityNetId),
33
+
34
+ /**
35
+ * Gets the network ID for an entity.
36
+ *
37
+ * Entity handles are local to the current machine.
38
+ * Network IDs are shared references for networked entities.
39
+ *
40
+ * If no entity is provided, this uses your own player ped.
41
+ *
42
+ * Examples:
43
+ * - netId(vehicle) -> network ID of that vehicle
44
+ * - netId(targetPed) -> network ID of that ped
45
+ * - netId() -> network ID of your own player ped
46
+ */
47
+ netId: (entity = PlayerPedId()) => NetworkGetNetworkIdFromEntity(entity),
48
+
49
+ /**
50
+ * Gets entity coordinates and heading.
51
+ */
52
+ coords: (() => {
53
+ function coords(excludeH: true, entity?: number, isAlive?: boolean): Vec3
54
+ function coords(excludeH?: false, entity?: number, isAlive?: boolean): Vec4
55
+ function coords(excludeH = false, entity = client.entity.handle(), isAlive = true) {
56
+ const entityCoords = GetEntityCoords(entity, isAlive) as Vec3
57
+
58
+ if (excludeH) return entityCoords
59
+
60
+ return [
61
+ ...entityCoords,
62
+ GetEntityHeading(entity)
63
+ ]
64
+ }
65
+
66
+ return coords
67
+ })()
68
+ },
69
+ player: {
70
+ /**
71
+ * Gets a client player ID.
72
+ *
73
+ * If a server ID is provided, this converts that server ID into a client
74
+ * player ID on the current client.
75
+ *
76
+ * If no server ID is provided, this returns your own client player ID.
77
+ *
78
+ * Examples:
79
+ * - id(targetServerId) -> target player's client player ID
80
+ * - id() -> your own client player ID
81
+ */
82
+ id: (serverId?: number) => serverId ? GetPlayerFromServerId(serverId) : PlayerId(),
83
+
84
+ /**
85
+ * Gets a player's server ID from their client player ID.
86
+ *
87
+ * Client player IDs are local to each client.
88
+ * Server IDs, also called source IDs, identify connected players on the server.
89
+ *
90
+ * If no client player ID is provided, this uses your own client player ID.
91
+ *
92
+ * Examples:
93
+ * - serverId(targetPlayerId) -> target player's server ID
94
+ * - serverId() -> your own server ID
95
+ */
96
+ serverId: (playerId = client.player.id()) => GetPlayerServerId(playerId),
97
+ }
98
+ }
package/client/index.ts CHANGED
@@ -11,5 +11,5 @@ export * from './blip.ts'
11
11
  export * from './cam.ts'
12
12
  export * from './nearest.ts'
13
13
  export * from './pool.ts'
14
- export * from './entity.ts'
15
14
  export * from './timer.ts'
15
+ export * from './client.ts'
package/client/nearest.ts CHANGED
@@ -51,9 +51,9 @@ const player = (
51
51
  const playerPed = GetPlayerPed(playerId)
52
52
  // deno-lint-ignore no-boolean-literal-for-arguments
53
53
  const vehicle = GetVehiclePedIsIn(playerPed, false)
54
- const playerCoords: Vec3 = (
55
- vehicle === 0 ? getEntity.coords(true, playerPed) : GetWorldPositionOfEntityBone(playerPed, 0) as Vec3
56
- )
54
+ const playerCoords: Vec3 = vehicle === 0
55
+ ? getEntity.coords(true, playerPed)
56
+ : GetWorldPositionOfEntityBone(playerPed, 0) as Vec3
57
57
 
58
58
  const distance = Vdist(
59
59
  coords[0],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lenix",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Typed FiveM utilities for client, server, shared, and NUI scripts",
5
5
  "author": "Lenix",
6
6
  "license": "MIT",
package/server/index.ts CHANGED
@@ -3,3 +3,5 @@
3
3
  *
4
4
  * FiveM server-side helpers.
5
5
  */
6
+
7
+ export * from './server'
@@ -0,0 +1,11 @@
1
+ export const server: {
2
+ entity: {
3
+ handle: (netId: number) => number;
4
+ handleFromSource: (source: number) => number;
5
+ };
6
+ } = {
7
+ entity: {
8
+ handle: (netId: number) => NetworkGetEntityFromNetworkId(netId),
9
+ handleFromSource: (source: number) => GetPlayerPed(source.toString())
10
+ }
11
+ }
package/shared/types.ts CHANGED
@@ -23,7 +23,6 @@ export type Request<
23
23
  > = Params extends readonly unknown[] ? never
24
24
  : [Response, Id, Params]
25
25
 
26
-
27
26
  /**
28
27
  * Internal NUI requests used by Lenix helpers. DO NOT USE
29
28
  */
@@ -33,4 +32,3 @@ export interface _InternalRequests {
33
32
  cursor: boolean
34
33
  }>
35
34
  }
36
-
package/client/entity.ts DELETED
@@ -1,22 +0,0 @@
1
- // deno-lint-ignore-file no-undef
2
- import type { Vec3, Vec4 } from '../shared/types.ts'
3
-
4
- /**
5
- * Gets entity coordinates and heading.
6
- */
7
- function coords(excludeH: true, entity?: number, isAlive?: boolean): Vec3
8
- function coords(excludeH?: false, entity?: number, isAlive?: boolean): Vec4
9
- function coords(excludeH = false, entity = PlayerPedId(), isAlive = true): Vec3 | Vec4 {
10
- const entityCoords = GetEntityCoords(entity, isAlive) as Vec3
11
-
12
- if (excludeH) return entityCoords
13
-
14
- return [
15
- ...entityCoords,
16
- GetEntityHeading(entity)
17
- ]
18
- }
19
-
20
- export const getEntity = {
21
- coords
22
- }