@erlcjs/core 1.0.0

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 ADDED
@@ -0,0 +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://noinkin.github.io/erlcapi/)