@panda0day/fivex 0.2.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/README.md +294 -0
- package/dist/client/blips-internal.d.ts +2 -0
- package/dist/client/blips-internal.d.ts.map +1 -0
- package/dist/client/blips-internal.js +32 -0
- package/dist/client/blips-internal.js.map +1 -0
- package/dist/client/core.d.ts +18 -0
- package/dist/client/core.d.ts.map +1 -0
- package/dist/client/core.js +24 -0
- package/dist/client/core.js.map +1 -0
- package/dist/client/entities/entity.d.ts +24 -0
- package/dist/client/entities/entity.d.ts.map +1 -0
- package/dist/client/entities/entity.js +64 -0
- package/dist/client/entities/entity.js.map +1 -0
- package/dist/client/entities/local-player.d.ts +8 -0
- package/dist/client/entities/local-player.d.ts.map +1 -0
- package/dist/client/entities/local-player.js +15 -0
- package/dist/client/entities/local-player.js.map +1 -0
- package/dist/client/entities/object.d.ts +14 -0
- package/dist/client/entities/object.d.ts.map +1 -0
- package/dist/client/entities/object.js +32 -0
- package/dist/client/entities/object.js.map +1 -0
- package/dist/client/entities/ped.d.ts +8 -0
- package/dist/client/entities/ped.d.ts.map +1 -0
- package/dist/client/entities/ped.js +16 -0
- package/dist/client/entities/ped.js.map +1 -0
- package/dist/client/entities/remote-player.d.ts +9 -0
- package/dist/client/entities/remote-player.d.ts.map +1 -0
- package/dist/client/entities/remote-player.js +20 -0
- package/dist/client/entities/remote-player.js.map +1 -0
- package/dist/client/entities/vehicle.d.ts +8 -0
- package/dist/client/entities/vehicle.d.ts.map +1 -0
- package/dist/client/entities/vehicle.js +16 -0
- package/dist/client/entities/vehicle.js.map +1 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +8 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/internal/state.d.ts +3 -0
- package/dist/client/internal/state.d.ts.map +1 -0
- package/dist/client/internal/state.js +5 -0
- package/dist/client/internal/state.js.map +1 -0
- package/dist/client/internal.d.ts +2 -0
- package/dist/client/internal.d.ts.map +1 -0
- package/dist/client/internal.js +17 -0
- package/dist/client/internal.js.map +1 -0
- package/dist/client/managers/client-pool.d.ts +5 -0
- package/dist/client/managers/client-pool.d.ts.map +1 -0
- package/dist/client/managers/client-pool.js +11 -0
- package/dist/client/managers/client-pool.js.map +1 -0
- package/dist/client/managers/event-manager.d.ts +11 -0
- package/dist/client/managers/event-manager.d.ts.map +1 -0
- package/dist/client/managers/event-manager.js +25 -0
- package/dist/client/managers/event-manager.js.map +1 -0
- package/dist/client/managers/object-pool.d.ts +10 -0
- package/dist/client/managers/object-pool.d.ts.map +1 -0
- package/dist/client/managers/object-pool.js +27 -0
- package/dist/client/managers/object-pool.js.map +1 -0
- package/dist/client/managers/ped-pool.d.ts +8 -0
- package/dist/client/managers/ped-pool.d.ts.map +1 -0
- package/dist/client/managers/ped-pool.js +14 -0
- package/dist/client/managers/ped-pool.js.map +1 -0
- package/dist/client/managers/player-pool.d.ts +9 -0
- package/dist/client/managers/player-pool.d.ts.map +1 -0
- package/dist/client/managers/player-pool.js +17 -0
- package/dist/client/managers/player-pool.js.map +1 -0
- package/dist/client/managers/rpc.d.ts +12 -0
- package/dist/client/managers/rpc.d.ts.map +1 -0
- package/dist/client/managers/rpc.js +43 -0
- package/dist/client/managers/rpc.js.map +1 -0
- package/dist/client/managers/vehicle-pool.d.ts +8 -0
- package/dist/client/managers/vehicle-pool.d.ts.map +1 -0
- package/dist/client/managers/vehicle-pool.js +14 -0
- package/dist/client/managers/vehicle-pool.js.map +1 -0
- package/dist/server/blips.d.ts +9 -0
- package/dist/server/blips.d.ts.map +1 -0
- package/dist/server/blips.js +25 -0
- package/dist/server/blips.js.map +1 -0
- package/dist/server/core.d.ts +13 -0
- package/dist/server/core.d.ts.map +1 -0
- package/dist/server/core.js +13 -0
- package/dist/server/core.js.map +1 -0
- package/dist/server/entities/entity.d.ts +22 -0
- package/dist/server/entities/entity.d.ts.map +1 -0
- package/dist/server/entities/entity.js +60 -0
- package/dist/server/entities/entity.js.map +1 -0
- package/dist/server/entities/object.d.ts +4 -0
- package/dist/server/entities/object.d.ts.map +1 -0
- package/dist/server/entities/object.js +4 -0
- package/dist/server/entities/object.js.map +1 -0
- package/dist/server/entities/ped.d.ts +5 -0
- package/dist/server/entities/ped.d.ts.map +1 -0
- package/dist/server/entities/ped.js +7 -0
- package/dist/server/entities/ped.js.map +1 -0
- package/dist/server/entities/player.d.ts +27 -0
- package/dist/server/entities/player.d.ts.map +1 -0
- package/dist/server/entities/player.js +80 -0
- package/dist/server/entities/player.js.map +1 -0
- package/dist/server/entities/vehicle.d.ts +18 -0
- package/dist/server/entities/vehicle.d.ts.map +1 -0
- package/dist/server/entities/vehicle.js +46 -0
- package/dist/server/entities/vehicle.js.map +1 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +5 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/internal/state.d.ts +3 -0
- package/dist/server/internal/state.d.ts.map +1 -0
- package/dist/server/internal/state.js +5 -0
- package/dist/server/internal/state.js.map +1 -0
- package/dist/server/managers/event-manager.d.ts +10 -0
- package/dist/server/managers/event-manager.d.ts.map +1 -0
- package/dist/server/managers/event-manager.js +25 -0
- package/dist/server/managers/event-manager.js.map +1 -0
- package/dist/server/managers/player-pool.d.ts +9 -0
- package/dist/server/managers/player-pool.d.ts.map +1 -0
- package/dist/server/managers/player-pool.js +17 -0
- package/dist/server/managers/player-pool.js.map +1 -0
- package/dist/server/managers/rpc.d.ts +12 -0
- package/dist/server/managers/rpc.d.ts.map +1 -0
- package/dist/server/managers/rpc.js +50 -0
- package/dist/server/managers/rpc.js.map +1 -0
- package/dist/server/managers/server-pool.d.ts +5 -0
- package/dist/server/managers/server-pool.d.ts.map +1 -0
- package/dist/server/managers/server-pool.js +9 -0
- package/dist/server/managers/server-pool.js.map +1 -0
- package/dist/server/managers/vehicle-pool.d.ts +8 -0
- package/dist/server/managers/vehicle-pool.d.ts.map +1 -0
- package/dist/server/managers/vehicle-pool.js +14 -0
- package/dist/server/managers/vehicle-pool.js.map +1 -0
- package/dist/shared/blips.d.ts +16 -0
- package/dist/shared/blips.d.ts.map +1 -0
- package/dist/shared/blips.js +6 -0
- package/dist/shared/blips.js.map +1 -0
- package/dist/shared/events-map.d.ts +11 -0
- package/dist/shared/events-map.d.ts.map +1 -0
- package/dist/shared/events-map.js +2 -0
- package/dist/shared/events-map.js.map +1 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/math/utils.d.ts +8 -0
- package/dist/shared/math/utils.d.ts.map +1 -0
- package/dist/shared/math/utils.js +8 -0
- package/dist/shared/math/utils.js.map +1 -0
- package/dist/shared/math/vector3.d.ts +200 -0
- package/dist/shared/math/vector3.d.ts.map +1 -0
- package/dist/shared/math/vector3.js +232 -0
- package/dist/shared/math/vector3.js.map +1 -0
- package/dist/shared/net.d.ts +7 -0
- package/dist/shared/net.d.ts.map +1 -0
- package/dist/shared/net.js +7 -0
- package/dist/shared/net.js.map +1 -0
- package/dist/shared/pool-base.d.ts +11 -0
- package/dist/shared/pool-base.d.ts.map +1 -0
- package/dist/shared/pool-base.js +27 -0
- package/dist/shared/pool-base.js.map +1 -0
- package/dist/shared/rpc-core.d.ts +23 -0
- package/dist/shared/rpc-core.d.ts.map +1 -0
- package/dist/shared/rpc-core.js +33 -0
- package/dist/shared/rpc-core.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# fivex
|
|
2
|
+
|
|
3
|
+
A TypeScript framework for FiveM. You install it into a resource project like any npm package and get a consistent, object-oriented API over the natives instead of calling them raw in every script.
|
|
4
|
+
|
|
5
|
+
`fx.events.add`, `fx.events.addCommand`, a player pool, entity objects, and a real `Vector3` class with math on it. The difference is that everything is typed.
|
|
6
|
+
|
|
7
|
+
> Package name is `@panda0day/fivex` and the global export is `fx`. Rename to taste before publishing.
|
|
8
|
+
|
|
9
|
+
## How it works
|
|
10
|
+
|
|
11
|
+
FiveM never loads `node_modules` at runtime. The client runtime is a V8 isolate with no module resolution, and server scripts run as a single bundled file. So this framework isn't loaded by FiveM directly — it's a normal library that your resource's bundler (esbuild) inlines into your `client.js` / `server.js` at build time.
|
|
12
|
+
|
|
13
|
+
That's the whole reason it "works the same in every project": FiveM only ever sees the final bundle, and your framework code is baked into it.
|
|
14
|
+
|
|
15
|
+
Because client and server expose different natives, the package has three entry points:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
@panda0day/fivex/client // client-only API + shared
|
|
19
|
+
@panda0day/fivex/server // server-only API + shared
|
|
20
|
+
@panda0day/fivex/shared // Vector3, math, event names — no natives
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Importing `/client` can never pull server natives onto the client, and vice versa.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @panda0day/fivex
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
You also need the CitizenFX typings in your project (they're peer dependencies):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -D @citizenfx/client @citizenfx/server
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
Client:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { fx, Vector3 } from '@panda0day/fivex/client';
|
|
43
|
+
|
|
44
|
+
fx.events.addCommand('up', () => {
|
|
45
|
+
fx.player.position = fx.player.position.add(new Vector3(0, 0, 5));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
fx.events.addNet('fivex:notify', (message: string) => {
|
|
49
|
+
console.log(message);
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Server:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { fx } from '@panda0day/fivex/server';
|
|
57
|
+
|
|
58
|
+
fx.events.addCommand('kickall', () => {
|
|
59
|
+
fx.players.forEach((p) => p.drop('server reset'));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
fx.events.addNet('fivex:ready', (player) => {
|
|
63
|
+
player.outputChatBox(`Welcome, ${player.name}`);
|
|
64
|
+
fx.players.broadcast(`${player.name} joined`);
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Natives are still global functions, so anything the framework doesn't wrap you just call directly:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const ped = PlayerPedId();
|
|
72
|
+
SetPedArmour(ped, 100);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Events
|
|
76
|
+
|
|
77
|
+
Local events stay on one side. Networked events cross the wire.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
// client
|
|
81
|
+
fx.events.add('someLocalEvent', handler); // same-side (on)
|
|
82
|
+
fx.events.addNet('fromServer', handler); // from server (onNet)
|
|
83
|
+
fx.events.call('someLocalEvent', ...args); // emit locally
|
|
84
|
+
fx.events.callRemote('toServer', ...args); // client -> server (emitNet)
|
|
85
|
+
|
|
86
|
+
// server
|
|
87
|
+
fx.events.add('someLocalEvent', handler);
|
|
88
|
+
fx.events.addNet('fromClient', (player, ...args) => {}); // note: player is first arg
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
On the server, `addNet` hands you a `Player` as the first argument. See "The source footgun" below for why that matters.
|
|
92
|
+
|
|
93
|
+
## Commands
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
// client
|
|
97
|
+
fx.events.addCommand('heal', (args, raw) => { /* ... */ });
|
|
98
|
+
|
|
99
|
+
// server — caller is a Player, or null for console
|
|
100
|
+
fx.events.addCommand('setjob', (player, args) => {
|
|
101
|
+
if (!player) return; // ran from server console
|
|
102
|
+
// ...
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Players
|
|
107
|
+
|
|
108
|
+
Server side, `fx.players` is a pool:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
fx.players.at(source); // Player for a specific server id
|
|
112
|
+
fx.players.toArray(); // Player[]
|
|
113
|
+
fx.players.forEach(fn);
|
|
114
|
+
fx.players.call('event', ...args); // emit to all clients
|
|
115
|
+
fx.players.broadcast('message'); // chat to all
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
A `Player` wraps a server id and gives you the common operations:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
player.name;
|
|
122
|
+
player.ped; // the ped entity handle
|
|
123
|
+
player.position; // Vector3 (read)
|
|
124
|
+
player.getIdentifier('license:');
|
|
125
|
+
player.call('event', ...args);
|
|
126
|
+
player.outputChatBox('text');
|
|
127
|
+
player.drop('reason');
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Client side, `fx.player` is the local player. It's a `LocalPlayer`, which extends `Ped`, which extends `Entity`, so it has position, health, armour and so on directly:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
fx.player.position;
|
|
134
|
+
fx.player.health = 200;
|
|
135
|
+
fx.player.currentVehicle; // Vehicle | null
|
|
136
|
+
fx.player.serverId;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Entities
|
|
140
|
+
|
|
141
|
+
Everything physical in the game is an entity handle. The client classes mirror that with inheritance:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
Entity position, health, model, heading, distanceTo, delete
|
|
145
|
+
├─ Ped armour, isInVehicle, isDead
|
|
146
|
+
│ └─ LocalPlayer
|
|
147
|
+
└─ Vehicle speed, engineOn, repair
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { Vehicle } from '@panda0day/fivex/client';
|
|
152
|
+
|
|
153
|
+
const veh = fx.player.currentVehicle;
|
|
154
|
+
if (veh) {
|
|
155
|
+
veh.engineOn = true;
|
|
156
|
+
veh.repair();
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The server has a lighter `Entity` (reads work; most writes to player peds don't — see below), and `Player` is composition rather than inheritance: a player *has* a ped, it isn't one.
|
|
161
|
+
|
|
162
|
+
## Vector3 and math
|
|
163
|
+
|
|
164
|
+
`Vector3` is a real class, not a plain `{x, y, z}`. It's structurally compatible with what natives expect, so you can pass it straight into `SetEntityCoords` and friends.
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import { Vector3, clamp, lerp } from '@panda0day/fivex/shared';
|
|
168
|
+
|
|
169
|
+
const a = new Vector3(0, 0, 0);
|
|
170
|
+
const b = new Vector3(10, 0, 0);
|
|
171
|
+
|
|
172
|
+
a.add(b);
|
|
173
|
+
a.distanceTo(b);
|
|
174
|
+
a.normalize();
|
|
175
|
+
a.lerp(b, 0.5);
|
|
176
|
+
|
|
177
|
+
Vector3.from(GetEntityCoords(ped, true)); // wrap a native result
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`shared` also has the usual helpers: `clamp`, `lerp`, `remap`, `toRadians`, `toDegrees`, `randomInt`, `randomFloat`.
|
|
181
|
+
|
|
182
|
+
## Two things this handles for you
|
|
183
|
+
|
|
184
|
+
These are the parts worth having a framework for. Both are FiveM footguns that are easy to get wrong.
|
|
185
|
+
|
|
186
|
+
### The source footgun
|
|
187
|
+
|
|
188
|
+
Inside a server networked event, FiveM exposes the calling player as a global `source` that's only valid synchronously — the first `await` invalidates it, and you silently get the wrong player. `addNet` captures it immediately and passes you a `Player`, so you never touch the global and never race it:
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
fx.events.addNet('buyItem', async (player, itemId) => {
|
|
192
|
+
// player is already resolved and safe to use after awaits
|
|
193
|
+
await db.charge(player.getIdentifier('license:'), itemId);
|
|
194
|
+
player.outputChatBox('Purchased.');
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Server writes to a player go through the client
|
|
199
|
+
|
|
200
|
+
Under OneSync the owning client is authoritative over its own ped. A server-side `SetEntityHealth` on a player gets reverted on the next sync tick, so it looks like it works and then snaps back. Setting health, armour or position on a `Player` therefore routes an internal event to that client, which applies the change locally where it actually sticks:
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
player.setHealth(200); // not player.health = 200
|
|
204
|
+
player.setPosition(coords);
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The framework registers the client-side handlers for these automatically, so you only call the server method. Reads (`player.health`, `player.position`) are direct because reading the synced value server-side is fine.
|
|
208
|
+
|
|
209
|
+
Note that this is inherent to the game's trust model: the client can ignore or fake anything you tell it to set on itself. Keep anything security-sensitive (money, permissions) in server state, never in ped state.
|
|
210
|
+
|
|
211
|
+
## Setting up a consumer project
|
|
212
|
+
|
|
213
|
+
A resource that uses the framework needs a bundler step. Minimum setup:
|
|
214
|
+
|
|
215
|
+
`package.json`
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"scripts": { "build": "node build.js" },
|
|
220
|
+
"devDependencies": {
|
|
221
|
+
"@citizenfx/client": "latest",
|
|
222
|
+
"@citizenfx/server": "latest",
|
|
223
|
+
"@panda0day/fivex": "latest",
|
|
224
|
+
"esbuild": "^0.20.0",
|
|
225
|
+
"typescript": "^5.4.0"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
`tsconfig.json` — use `moduleResolution: "bundler"` (or `node16`) or TypeScript won't read the package's subpath exports and the `/client` and `/server` types won't resolve:
|
|
231
|
+
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"compilerOptions": {
|
|
235
|
+
"target": "ES2022",
|
|
236
|
+
"module": "ESNext",
|
|
237
|
+
"moduleResolution": "bundler",
|
|
238
|
+
"strict": true,
|
|
239
|
+
"skipLibCheck": true
|
|
240
|
+
},
|
|
241
|
+
"include": ["src/**/*.ts"]
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`build.js`
|
|
246
|
+
|
|
247
|
+
```js
|
|
248
|
+
const esbuild = require('esbuild');
|
|
249
|
+
|
|
250
|
+
const base = { bundle: true, platform: 'node', target: 'node16', format: 'cjs' };
|
|
251
|
+
|
|
252
|
+
Promise.all([
|
|
253
|
+
esbuild.build({ ...base, entryPoints: ['src/client/index.ts'], outfile: 'dist/client.js' }),
|
|
254
|
+
esbuild.build({ ...base, entryPoints: ['src/server/index.ts'], outfile: 'dist/server.js' }),
|
|
255
|
+
]).then(() => console.log('built'));
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`fxmanifest.lua`
|
|
259
|
+
|
|
260
|
+
```lua
|
|
261
|
+
fx_version 'cerulean'
|
|
262
|
+
game 'gta5'
|
|
263
|
+
|
|
264
|
+
client_script 'dist/client.js'
|
|
265
|
+
server_script 'dist/server.js'
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Then `npm run build`, drop the resource in your server, and `ensure` it.
|
|
269
|
+
|
|
270
|
+
## Working on the framework itself
|
|
271
|
+
|
|
272
|
+
The framework builds with `tsc` (not esbuild) because it needs to emit `.d.ts` files for consumers:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
npm run build # tsc -p tsconfig.client.json && tsc -p tsconfig.server.json
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Client and server compile against separate tsconfigs so each side only sees its own natives. `shared` is included in both.
|
|
279
|
+
|
|
280
|
+
For live development against a real resource, use `npm link`:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
# in the framework
|
|
284
|
+
npm link
|
|
285
|
+
# in your resource project
|
|
286
|
+
npm link @panda0day/fivex
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Run `tsc -w` on the framework and your resource re-bundles against the changes.
|
|
290
|
+
|
|
291
|
+
## Notes
|
|
292
|
+
|
|
293
|
+
- `instanceof` doesn't work across resources. Each resource bundles its own copy of the framework, so an `Entity` from one resource isn't `instanceof` the `Entity` in another. This never matters inside a single resource; just don't rely on it across resource boundaries.
|
|
294
|
+
- Entity wrappers aren't cached. `fx.player.currentVehicle` returns a fresh object each call, so `===` won't hold for "the same" vehicle. Add a pool keyed by handle if you need identity.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blips-internal.d.ts","sourceRoot":"","sources":["../../src/client/blips-internal.ts"],"names":[],"mappings":"AAmBA,wBAAgB,oBAAoB,IAAI,IAAI,CAU3C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="@citizenfx/client" />
|
|
2
|
+
import { BlipNet } from "../shared/blips";
|
|
3
|
+
const handles = new Map();
|
|
4
|
+
function draw(d) {
|
|
5
|
+
const blip = AddBlipForCoord(d.coords.x, d.coords.y, d.coords.z);
|
|
6
|
+
if (d.sprite !== undefined)
|
|
7
|
+
SetBlipSprite(blip, d.sprite);
|
|
8
|
+
if (d.color !== undefined)
|
|
9
|
+
SetBlipColour(blip, d.color);
|
|
10
|
+
if (d.scale !== undefined)
|
|
11
|
+
SetBlipScale(blip, d.scale);
|
|
12
|
+
if (d.shortRange)
|
|
13
|
+
SetBlipAsShortRange(blip, true);
|
|
14
|
+
if (d.label) {
|
|
15
|
+
BeginTextCommandSetBlipName("STRING");
|
|
16
|
+
AddTextComponentSubstringPlayerName(d.label);
|
|
17
|
+
EndTextCommandSetBlipName(blip);
|
|
18
|
+
}
|
|
19
|
+
handles.set(d.id, blip);
|
|
20
|
+
}
|
|
21
|
+
export function registerBlipHandlers() {
|
|
22
|
+
onNet(BlipNet.add, (d) => draw(d));
|
|
23
|
+
onNet(BlipNet.sync, (list) => list.forEach(draw));
|
|
24
|
+
onNet(BlipNet.remove, (id) => {
|
|
25
|
+
const h = handles.get(id);
|
|
26
|
+
if (h !== undefined) {
|
|
27
|
+
RemoveBlip(h);
|
|
28
|
+
handles.delete(id);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=blips-internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blips-internal.js","sourceRoot":"","sources":["../../src/client/blips-internal.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,EAAiB,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE1C,SAAS,IAAI,CAAC,CAAW;IACxB,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACjE,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS;QAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS;QAAE,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;IACxD,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS;QAAE,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;IACvD,IAAI,CAAC,CAAC,UAAU;QAAE,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClD,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QACb,2BAA2B,CAAC,QAAQ,CAAC,CAAC;QACtC,mCAAmC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7C,yBAAyB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,oBAAoB;IACnC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAW,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,IAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAU,EAAE,EAAE;QACpC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACrB,UAAU,CAAC,CAAC,CAAC,CAAC;YACd,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Vector3 } from "../shared";
|
|
2
|
+
import { LocalPlayer } from "./entities/local-player";
|
|
3
|
+
import { EventManager } from "./managers/event-manager";
|
|
4
|
+
import { GameObjectPool } from "./managers/object-pool";
|
|
5
|
+
import { PedPool } from "./managers/ped-pool";
|
|
6
|
+
import { ClientPlayerPool } from "./managers/player-pool";
|
|
7
|
+
import { VehiclePool } from "./managers/vehicle-pool";
|
|
8
|
+
export declare class Core {
|
|
9
|
+
readonly events: EventManager;
|
|
10
|
+
readonly player: LocalPlayer;
|
|
11
|
+
readonly Vector3: typeof Vector3;
|
|
12
|
+
readonly players: ClientPlayerPool;
|
|
13
|
+
readonly vehicles: VehiclePool;
|
|
14
|
+
readonly peds: PedPool;
|
|
15
|
+
readonly objects: GameObjectPool;
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/client/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,qBAAa,IAAI;IAChB,QAAQ,CAAC,MAAM,eAAsB;IACrC,QAAQ,CAAC,MAAM,cAAqB;IACpC,QAAQ,CAAC,OAAO,iBAAW;IAG3B,QAAQ,CAAC,OAAO,mBAA0B;IAC1C,QAAQ,CAAC,QAAQ,cAAqB;IACtC,QAAQ,CAAC,IAAI,UAAiB;IAC9B,QAAQ,CAAC,OAAO,iBAAwB;;CAMxC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Vector3 } from "../shared";
|
|
2
|
+
import { registerBlipHandlers } from "./blips-internal";
|
|
3
|
+
import { LocalPlayer } from "./entities/local-player";
|
|
4
|
+
import { registerInternalHandlers } from "./internal";
|
|
5
|
+
import { EventManager } from "./managers/event-manager";
|
|
6
|
+
import { GameObjectPool } from "./managers/object-pool";
|
|
7
|
+
import { PedPool } from "./managers/ped-pool";
|
|
8
|
+
import { ClientPlayerPool } from "./managers/player-pool";
|
|
9
|
+
import { VehiclePool } from "./managers/vehicle-pool";
|
|
10
|
+
export class Core {
|
|
11
|
+
events = new EventManager();
|
|
12
|
+
player = new LocalPlayer();
|
|
13
|
+
Vector3 = Vector3;
|
|
14
|
+
// Pools
|
|
15
|
+
players = new ClientPlayerPool();
|
|
16
|
+
vehicles = new VehiclePool();
|
|
17
|
+
peds = new PedPool();
|
|
18
|
+
objects = new GameObjectPool();
|
|
19
|
+
constructor() {
|
|
20
|
+
registerInternalHandlers();
|
|
21
|
+
registerBlipHandlers();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/client/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,OAAO,IAAI;IACP,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;IAC5B,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IAC3B,OAAO,GAAG,OAAO,CAAC;IAE3B,QAAQ;IACC,OAAO,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACjC,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;IAC7B,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;IACrB,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;IAExC;QACC,wBAAwB,EAAE,CAAC;QAC3B,oBAAoB,EAAE,CAAC;IACxB,CAAC;CACD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type IVector3, Vector3 } from "../../shared";
|
|
2
|
+
export declare class Entity {
|
|
3
|
+
readonly handle: number;
|
|
4
|
+
constructor(handle: number);
|
|
5
|
+
get exists(): boolean;
|
|
6
|
+
get model(): number;
|
|
7
|
+
get isNetworked(): boolean;
|
|
8
|
+
get netId(): number;
|
|
9
|
+
get position(): Vector3;
|
|
10
|
+
set position(v: IVector3);
|
|
11
|
+
get rotation(): Vector3;
|
|
12
|
+
set rotation(v: IVector3);
|
|
13
|
+
get heading(): number;
|
|
14
|
+
set heading(v: number);
|
|
15
|
+
get health(): number;
|
|
16
|
+
set health(v: number);
|
|
17
|
+
freeze(toggle: boolean): void;
|
|
18
|
+
setCollision(toggle: boolean): void;
|
|
19
|
+
setAlpha(alpha: number): void;
|
|
20
|
+
resetAlpha(): void;
|
|
21
|
+
distanceTo(other: Entity | IVector3): number;
|
|
22
|
+
delete(): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/client/entities/entity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEtD,qBAAa,MAAM;aACU,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;IAE1C,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAEvB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAEvB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,OAAO,CAAC,CAAC,EAAE,MAAM,EAEpB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM,EAEnB;IAED,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAI7B,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAInC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,UAAU,IAAI,IAAI;IAIlB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM;IAK5C,MAAM,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="@citizenfx/client" />
|
|
2
|
+
import { Vector3 } from "../../shared";
|
|
3
|
+
export class Entity {
|
|
4
|
+
handle;
|
|
5
|
+
constructor(handle) {
|
|
6
|
+
this.handle = handle;
|
|
7
|
+
}
|
|
8
|
+
get exists() {
|
|
9
|
+
return DoesEntityExist(this.handle);
|
|
10
|
+
}
|
|
11
|
+
get model() {
|
|
12
|
+
return GetEntityModel(this.handle);
|
|
13
|
+
}
|
|
14
|
+
get isNetworked() {
|
|
15
|
+
return NetworkGetEntityIsNetworked(this.handle);
|
|
16
|
+
}
|
|
17
|
+
get netId() {
|
|
18
|
+
return NetworkGetNetworkIdFromEntity(this.handle);
|
|
19
|
+
}
|
|
20
|
+
get position() {
|
|
21
|
+
return Vector3.from(GetEntityCoords(this.handle, false));
|
|
22
|
+
}
|
|
23
|
+
set position(v) {
|
|
24
|
+
SetEntityCoords(this.handle, v.x, v.y, v.z, false, false, false, false);
|
|
25
|
+
}
|
|
26
|
+
get rotation() {
|
|
27
|
+
return Vector3.from(GetEntityRotation(this.handle, 2));
|
|
28
|
+
}
|
|
29
|
+
set rotation(v) {
|
|
30
|
+
SetEntityRotation(this.handle, v.x, v.y, v.z, 2, true);
|
|
31
|
+
}
|
|
32
|
+
get heading() {
|
|
33
|
+
return GetEntityHeading(this.handle);
|
|
34
|
+
}
|
|
35
|
+
set heading(v) {
|
|
36
|
+
SetEntityHeading(this.handle, v);
|
|
37
|
+
}
|
|
38
|
+
get health() {
|
|
39
|
+
return GetEntityHealth(this.handle);
|
|
40
|
+
}
|
|
41
|
+
set health(v) {
|
|
42
|
+
SetEntityHealth(this.handle, v);
|
|
43
|
+
}
|
|
44
|
+
freeze(toggle) {
|
|
45
|
+
FreezeEntityPosition(this.handle, toggle);
|
|
46
|
+
}
|
|
47
|
+
setCollision(toggle) {
|
|
48
|
+
SetEntityCollision(this.handle, toggle, true);
|
|
49
|
+
}
|
|
50
|
+
setAlpha(alpha) {
|
|
51
|
+
SetEntityAlpha(this.handle, alpha, false);
|
|
52
|
+
}
|
|
53
|
+
resetAlpha() {
|
|
54
|
+
ResetEntityAlpha(this.handle);
|
|
55
|
+
}
|
|
56
|
+
distanceTo(other) {
|
|
57
|
+
const p = other instanceof Entity ? other.position : other;
|
|
58
|
+
return this.position.distanceTo(Vector3.from(p));
|
|
59
|
+
}
|
|
60
|
+
delete() {
|
|
61
|
+
DeleteEntity(this.handle);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../src/client/entities/entity.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAE3C,OAAO,EAAiB,OAAO,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,OAAO,MAAM;IACU;IAA5B,YAA4B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE9C,IAAI,MAAM;QACT,OAAO,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,KAAK;QACR,OAAO,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,WAAW;QACd,OAAO,2BAA2B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,KAAK;QACR,OAAO,6BAA6B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,QAAQ,CAAC,CAAW;QACvB,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,QAAQ,CAAC,CAAW;QACvB,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,OAAO;QACV,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,OAAO,CAAC,CAAS;QACpB,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,MAAM;QACT,OAAO,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,MAAM,CAAC,CAAS;QACnB,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,MAAe;QACrB,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,YAAY,CAAC,MAAe;QAC3B,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,QAAQ,CAAC,KAAa;QACrB,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,UAAU;QACT,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,UAAU,CAAC,KAAwB;QAClC,MAAM,CAAC,GAAG,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;QAC3D,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,MAAM;QACL,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-player.d.ts","sourceRoot":"","sources":["../../../src/client/entities/local-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,qBAAa,WAAY,SAAQ,GAAG;;IAKnC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,cAAc,IAAI,OAAO,GAAG,IAAI,CAGnC;CACD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Ped } from "./ped";
|
|
2
|
+
import { Vehicle } from "./vehicle";
|
|
3
|
+
export class LocalPlayer extends Ped {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(PlayerPedId());
|
|
6
|
+
}
|
|
7
|
+
get serverId() {
|
|
8
|
+
return GetPlayerServerId(PlayerId());
|
|
9
|
+
}
|
|
10
|
+
get currentVehicle() {
|
|
11
|
+
const veh = GetVehiclePedIsIn(this.handle, false);
|
|
12
|
+
return veh !== 0 ? new Vehicle(veh) : null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=local-player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-player.js","sourceRoot":"","sources":["../../../src/client/entities/local-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,OAAO,WAAY,SAAQ,GAAG;IACnC;QACC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,cAAc;QACjB,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5C,CAAC;CACD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IVector3 } from "../../shared";
|
|
2
|
+
import { Entity } from "./entity";
|
|
3
|
+
export declare class GameObject extends Entity {
|
|
4
|
+
get hasBeenBroken(): boolean;
|
|
5
|
+
get isVisible(): boolean;
|
|
6
|
+
markForDeletion(): void;
|
|
7
|
+
placeOnGroundProperly(): void;
|
|
8
|
+
placeOnGroundOrObjectProperly(): void;
|
|
9
|
+
setActivatePhysicsAsSoonAsItIsUnfrozen(toggle: boolean): void;
|
|
10
|
+
setPhysicsParams(mass: number, gravityFactor: number, linearC: number, linearV: number, linearV2: number, angularC: number, angularV: number, angularV2: number, p9: number, maxAngSpeed: number, buoyancyFactor: number): void;
|
|
11
|
+
setTargetable(toggle: boolean): void;
|
|
12
|
+
slide(to: IVector3, speed: IVector3, collision: boolean): boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../src/client/entities/object.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,UAAW,SAAQ,MAAM;IACrC,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,eAAe,IAAI,IAAI;IAIvB,qBAAqB,IAAI,IAAI;IAI7B,6BAA6B,IAAI,IAAI;IAIrC,sCAAsC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAI7D,gBAAgB,CACf,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACpB,IAAI;IAiBP,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAIpC,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO;CAYjE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="@citizenfx/client" />
|
|
2
|
+
import { Entity } from "./entity";
|
|
3
|
+
export class GameObject extends Entity {
|
|
4
|
+
get hasBeenBroken() {
|
|
5
|
+
return HasObjectBeenBroken(this.handle);
|
|
6
|
+
}
|
|
7
|
+
get isVisible() {
|
|
8
|
+
return IsObjectVisible(this.handle);
|
|
9
|
+
}
|
|
10
|
+
markForDeletion() {
|
|
11
|
+
MarkObjectForDeletion(this.handle);
|
|
12
|
+
}
|
|
13
|
+
placeOnGroundProperly() {
|
|
14
|
+
PlaceObjectOnGroundProperly(this.handle);
|
|
15
|
+
}
|
|
16
|
+
placeOnGroundOrObjectProperly() {
|
|
17
|
+
PlaceObjectOnGroundOrObjectProperly(this.handle);
|
|
18
|
+
}
|
|
19
|
+
setActivatePhysicsAsSoonAsItIsUnfrozen(toggle) {
|
|
20
|
+
SetActivateObjectPhysicsAsSoonAsItIsUnfrozen(this.handle, toggle);
|
|
21
|
+
}
|
|
22
|
+
setPhysicsParams(mass, gravityFactor, linearC, linearV, linearV2, angularC, angularV, angularV2, p9, maxAngSpeed, buoyancyFactor) {
|
|
23
|
+
SetObjectPhysicsParams(this.handle, mass, gravityFactor, linearC, linearV, linearV2, angularC, angularV, angularV2, p9, maxAngSpeed, buoyancyFactor);
|
|
24
|
+
}
|
|
25
|
+
setTargetable(toggle) {
|
|
26
|
+
SetObjectTargettable(this.handle, toggle);
|
|
27
|
+
}
|
|
28
|
+
slide(to, speed, collision) {
|
|
29
|
+
return SlideObject(this.handle, to.x, to.y, to.z, speed.x, speed.y, speed.z, collision);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/client/entities/object.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAG3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,OAAO,UAAW,SAAQ,MAAM;IACrC,IAAI,aAAa;QAChB,OAAO,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,SAAS;QACZ,OAAO,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,eAAe;QACd,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,qBAAqB;QACpB,2BAA2B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED,6BAA6B;QAC5B,mCAAmC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;IAED,sCAAsC,CAAC,MAAe;QACrD,4CAA4C,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;IAED,gBAAgB,CACf,IAAY,EACZ,aAAqB,EACrB,OAAe,EACf,OAAe,EACf,QAAgB,EAChB,QAAgB,EAChB,QAAgB,EAChB,SAAiB,EACjB,EAAU,EACV,WAAmB,EACnB,cAAsB;QAEtB,sBAAsB,CACrB,IAAI,CAAC,MAAM,EACX,IAAI,EACJ,aAAa,EACb,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,EAAE,EACF,WAAW,EACX,cAAc,CACd,CAAC;IACH,CAAC;IAED,aAAa,CAAC,MAAe;QAC5B,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,EAAY,EAAE,KAAe,EAAE,SAAkB;QACtD,OAAO,WAAW,CACjB,IAAI,CAAC,MAAM,EACX,EAAE,CAAC,CAAC,EACJ,EAAE,CAAC,CAAC,EACJ,EAAE,CAAC,CAAC,EACJ,KAAK,CAAC,CAAC,EACP,KAAK,CAAC,CAAC,EACP,KAAK,CAAC,CAAC,EACP,SAAS,CACT,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ped.d.ts","sourceRoot":"","sources":["../../../src/client/entities/ped.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,GAAI,SAAQ,MAAM;IAC9B,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM,EAEnB;IAED,IAAI,MAAM,IAAI,OAAO,CAEpB;CACD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Entity } from "./entity";
|
|
2
|
+
export class Ped extends Entity {
|
|
3
|
+
get isInVehicle() {
|
|
4
|
+
return IsPedInAnyVehicle(this.handle, false);
|
|
5
|
+
}
|
|
6
|
+
get armour() {
|
|
7
|
+
return GetPedArmour(this.handle);
|
|
8
|
+
}
|
|
9
|
+
set armour(v) {
|
|
10
|
+
SetPedArmour(this.handle, v);
|
|
11
|
+
}
|
|
12
|
+
get isDead() {
|
|
13
|
+
return IsPedDeadOrDying(this.handle, true);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ped.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ped.js","sourceRoot":"","sources":["../../../src/client/entities/ped.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,OAAO,GAAI,SAAQ,MAAM;IAC9B,IAAI,WAAW;QACd,OAAO,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,MAAM;QACT,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,MAAM,CAAC,CAAS;QACnB,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,MAAM;QACT,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-player.d.ts","sourceRoot":"","sources":["../../../src/client/entities/remote-player.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;aACI,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM;IAEtC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;CACD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="@citizenfx/client" />
|
|
2
|
+
export class RemotePlayer {
|
|
3
|
+
id;
|
|
4
|
+
constructor(id) {
|
|
5
|
+
this.id = id;
|
|
6
|
+
}
|
|
7
|
+
get serverId() {
|
|
8
|
+
return GetPlayerServerId(this.id);
|
|
9
|
+
}
|
|
10
|
+
get name() {
|
|
11
|
+
return GetPlayerName(this.id);
|
|
12
|
+
}
|
|
13
|
+
get pedHandle() {
|
|
14
|
+
return GetPlayerPed(this.id);
|
|
15
|
+
}
|
|
16
|
+
get isLocal() {
|
|
17
|
+
return this.id === PlayerId();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=remote-player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-player.js","sourceRoot":"","sources":["../../../src/client/entities/remote-player.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAE3C,MAAM,OAAO,YAAY;IACI;IAA5B,YAA4B,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;IAAG,CAAC;IAE1C,IAAI,QAAQ;QACX,OAAO,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,IAAI;QACP,OAAO,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,SAAS;QACZ,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACD"}
|