@erlcjs/core 1.0.0 → 1.0.2
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 +111 -111
- package/package.json +37 -37
package/README.md
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
# @erlcjs/core
|
|
2
|
-
|
|
3
|
-
`@erlcjs/core` is a lightweight, fully-featured, and strongly-typed API wrapper for Roblox's **Emergency Response: Liberty County (ER:LC)** private servers. It handles the low-level API mechanics, caching, and rate limiting so you can focus on building server integrations, moderation tools, and dashboards.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
* **TypeScript Native**: Written completely in TypeScript with comprehensive declarations.
|
|
8
|
-
* **Automatic Rate Limiting**: Built-in REST client queues API commands and handles rate limit resets.
|
|
9
|
-
* **Real-time Event Emitters**: Track game updates using high-frequency Polling or Webhook Gateway modes.
|
|
10
|
-
* **Entity Cache**: Caches player states, spawned vehicles, active emergency calls, kill logs, and mod calls automatically.
|
|
11
|
-
* **Console Commands**: Easily trigger commands like `:kick`, `:kill`, `:pm` directly through JS/TS methods.
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
Install `@erlcjs/core` in your project:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install @erlcjs/core
|
|
19
|
-
# or
|
|
20
|
-
pnpm add @erlcjs/core
|
|
21
|
-
# or
|
|
22
|
-
yarn add @erlcjs/core
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Quick Start
|
|
26
|
-
|
|
27
|
-
### Polling Mode
|
|
28
|
-
|
|
29
|
-
Polling is the simplest way to get started. It queries the ER:LC HTTP API every 5 seconds to fetch server changes.
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
import { Client, ERLCEvents } from '@erlcjs/core';
|
|
33
|
-
|
|
34
|
-
const client = new Client({
|
|
35
|
-
serverKey: 'YOUR_ERLC_SERVER_API_KEY',
|
|
36
|
-
polling: true
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
client.on(ERLCEvents.playerJoin, (player) => {
|
|
40
|
-
console.log(`Player joined: ${player.username} (ID: ${player.id})`);
|
|
41
|
-
|
|
42
|
-
// Send a welcome message in-game
|
|
43
|
-
player.message('Welcome to our server!');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
client.on(ERLCEvents.kill, (killLog) => {
|
|
47
|
-
console.log(`${killLog.killerUsername} killed ${killLog.killedUsername}`);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
client.on(ERLCEvents.emergencyCallAdd, (call) => {
|
|
51
|
-
console.log(`Emergency Call #${call.callNumber}: ${call.description}`);
|
|
52
|
-
});
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Webhook Gateway Mode (Alpha)
|
|
56
|
-
|
|
57
|
-
Set up a local server to receive real-time webhook events pushed directly by ER:LC.
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
import { Client, ERLCEvents } from '@erlcjs/core';
|
|
61
|
-
|
|
62
|
-
const client = new Client({
|
|
63
|
-
serverKey: 'YOUR_ERLC_SERVER_API_KEY',
|
|
64
|
-
webhook: {
|
|
65
|
-
enabled: true,
|
|
66
|
-
port: 3000,
|
|
67
|
-
path: '/events-webhook'
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
client.on(ERLCEvents.playerJoin, (player) => {
|
|
72
|
-
console.log(`${player.username} joined via gateway webhook!`);
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Core Structure Methods
|
|
77
|
-
|
|
78
|
-
The wrapper resolves entities into structures representing in-game components.
|
|
79
|
-
|
|
80
|
-
### Players
|
|
81
|
-
Retrieve cached players, or issue immediate actions:
|
|
82
|
-
```typescript
|
|
83
|
-
const player = client.players.cache.get(1234567); // get by UserId
|
|
84
|
-
|
|
85
|
-
// Kick a player
|
|
86
|
-
await player.kick('Violating server rules');
|
|
87
|
-
|
|
88
|
-
// Kill a player
|
|
89
|
-
await player.kill();
|
|
90
|
-
|
|
91
|
-
// Message a player
|
|
92
|
-
await player.message('Please review the rules');
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Vehicles
|
|
96
|
-
Retrieve vehicle details:
|
|
97
|
-
```typescript
|
|
98
|
-
const vehicle = client.vehicles.cache.get('PLATE_ABC_123');
|
|
99
|
-
console.log(`Vehicle model: ${vehicle.name}, Owner: ${vehicle.ownerUsername}`);
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Executing Commands
|
|
103
|
-
Issue custom commands directly:
|
|
104
|
-
```typescript
|
|
105
|
-
await client.commands.execute(':heal jamie');
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## Documentation
|
|
109
|
-
|
|
110
|
-
To read the complete API Reference and detailed guides, view the documentation site:
|
|
111
|
-
[ERLCjs Documentation Portal](https://
|
|
1
|
+
# @erlcjs/core
|
|
2
|
+
|
|
3
|
+
`@erlcjs/core` is a lightweight, fully-featured, and strongly-typed API wrapper for Roblox's **Emergency Response: Liberty County (ER:LC)** private servers. It handles the low-level API mechanics, caching, and rate limiting so you can focus on building server integrations, moderation tools, and dashboards.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
* **TypeScript Native**: Written completely in TypeScript with comprehensive declarations.
|
|
8
|
+
* **Automatic Rate Limiting**: Built-in REST client queues API commands and handles rate limit resets.
|
|
9
|
+
* **Real-time Event Emitters**: Track game updates using high-frequency Polling or Webhook Gateway modes.
|
|
10
|
+
* **Entity Cache**: Caches player states, spawned vehicles, active emergency calls, kill logs, and mod calls automatically.
|
|
11
|
+
* **Console Commands**: Easily trigger commands like `:kick`, `:kill`, `:pm` directly through JS/TS methods.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Install `@erlcjs/core` in your project:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @erlcjs/core
|
|
19
|
+
# or
|
|
20
|
+
pnpm add @erlcjs/core
|
|
21
|
+
# or
|
|
22
|
+
yarn add @erlcjs/core
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### Polling Mode
|
|
28
|
+
|
|
29
|
+
Polling is the simplest way to get started. It queries the ER:LC HTTP API every 5 seconds to fetch server changes.
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { Client, ERLCEvents } from '@erlcjs/core';
|
|
33
|
+
|
|
34
|
+
const client = new Client({
|
|
35
|
+
serverKey: 'YOUR_ERLC_SERVER_API_KEY',
|
|
36
|
+
polling: true
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
client.on(ERLCEvents.playerJoin, (player) => {
|
|
40
|
+
console.log(`Player joined: ${player.username} (ID: ${player.id})`);
|
|
41
|
+
|
|
42
|
+
// Send a welcome message in-game
|
|
43
|
+
player.message('Welcome to our server!');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
client.on(ERLCEvents.kill, (killLog) => {
|
|
47
|
+
console.log(`${killLog.killerUsername} killed ${killLog.killedUsername}`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
client.on(ERLCEvents.emergencyCallAdd, (call) => {
|
|
51
|
+
console.log(`Emergency Call #${call.callNumber}: ${call.description}`);
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Webhook Gateway Mode (Alpha)
|
|
56
|
+
|
|
57
|
+
Set up a local server to receive real-time webhook events pushed directly by ER:LC.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { Client, ERLCEvents } from '@erlcjs/core';
|
|
61
|
+
|
|
62
|
+
const client = new Client({
|
|
63
|
+
serverKey: 'YOUR_ERLC_SERVER_API_KEY',
|
|
64
|
+
webhook: {
|
|
65
|
+
enabled: true,
|
|
66
|
+
port: 3000,
|
|
67
|
+
path: '/events-webhook'
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
client.on(ERLCEvents.playerJoin, (player) => {
|
|
72
|
+
console.log(`${player.username} joined via gateway webhook!`);
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Core Structure Methods
|
|
77
|
+
|
|
78
|
+
The wrapper resolves entities into structures representing in-game components.
|
|
79
|
+
|
|
80
|
+
### Players
|
|
81
|
+
Retrieve cached players, or issue immediate actions:
|
|
82
|
+
```typescript
|
|
83
|
+
const player = client.players.cache.get(1234567); // get by UserId
|
|
84
|
+
|
|
85
|
+
// Kick a player
|
|
86
|
+
await player.kick('Violating server rules');
|
|
87
|
+
|
|
88
|
+
// Kill a player
|
|
89
|
+
await player.kill();
|
|
90
|
+
|
|
91
|
+
// Message a player
|
|
92
|
+
await player.message('Please review the rules');
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Vehicles
|
|
96
|
+
Retrieve vehicle details:
|
|
97
|
+
```typescript
|
|
98
|
+
const vehicle = client.vehicles.cache.get('PLATE_ABC_123');
|
|
99
|
+
console.log(`Vehicle model: ${vehicle.name}, Owner: ${vehicle.ownerUsername}`);
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Executing Commands
|
|
103
|
+
Issue custom commands directly:
|
|
104
|
+
```typescript
|
|
105
|
+
await client.commands.execute(':heal jamie');
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Documentation
|
|
109
|
+
|
|
110
|
+
To read the complete API Reference and detailed guides, view the documentation site:
|
|
111
|
+
[ERLCjs Documentation Portal](https://erlcjs.xyz)
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@erlcjs/core",
|
|
3
|
-
"description": "ERLC API Wrapper Core",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"main": "./dist/index.cjs",
|
|
6
|
-
"module": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"homepage": "
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/noinkin/erlcapi.git",
|
|
22
|
-
"directory": "packages/core"
|
|
23
|
-
},
|
|
24
|
-
"license": "Apache-2.0",
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
27
|
-
"lint": "eslint src/**/*.ts",
|
|
28
|
-
"extract": "api-extractor run --local",
|
|
29
|
-
"test": "pnpm tsx --env-file-if-exists=../../.env src/index.test.ts",
|
|
30
|
-
"bench": "pnpm tsx src/index.bench.ts"
|
|
31
|
-
},
|
|
32
|
-
"publishConfig": {
|
|
33
|
-
"access": "public"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"tsup": "^8.5.1"
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@erlcjs/core",
|
|
3
|
+
"description": "ERLC API Wrapper Core",
|
|
4
|
+
"version": "1.0.2",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"homepage": "erlcjs.xyz",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/noinkin/erlcapi.git",
|
|
22
|
+
"directory": "packages/core"
|
|
23
|
+
},
|
|
24
|
+
"license": "Apache-2.0",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
27
|
+
"lint": "eslint src/**/*.ts",
|
|
28
|
+
"extract": "api-extractor run --local",
|
|
29
|
+
"test": "pnpm tsx --env-file-if-exists=../../.env src/index.test.ts",
|
|
30
|
+
"bench": "pnpm tsx src/index.bench.ts"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"tsup": "^8.5.1"
|
|
37
|
+
}
|
|
38
38
|
}
|