rock-mod 0.8.0 → 0.8.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 +93 -2
- package/dist/server/RockMod.d.ts +2 -1
- package/dist/server/entities/mock/player/MockPlayersManager.d.ts +16 -0
- package/dist/server/entities/mock/player/MockPlayersManager.js +37 -0
- package/dist/server/entities/ragemp/marker/RageMarker.js +1 -2
- package/dist/server/factories/mock/MockManagersFactory.js +2 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/testing.d.ts +8 -0
- package/dist/server/testing.js +19 -0
- package/dist/server/utils/mock/MockUtilsManager.d.ts +4 -0
- package/dist/server/utils/mock/MockUtilsManager.js +16 -0
- package/package.json +19 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rock-Mod
|
|
2
2
|
|
|
3
|
-
**Rock-Mod** is a versatile and powerful framework designed for cross-platform mod development for Grand Theft Auto (GTA) servers. It supports
|
|
3
|
+
**Rock-Mod** is a versatile and powerful framework designed for cross-platform mod development for Grand Theft Auto (GTA) servers. It supports **RageMP**, **AltV**, and **Mock** multiplayer platforms, allowing you to build and manage mods seamlessly across these environments.
|
|
4
4
|
|
|
5
5
|
### Installation
|
|
6
6
|
|
|
@@ -16,10 +16,101 @@ On the server-side, initialize Rock-Mod with the appropriate multiplayer type:
|
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
const rockMod = await RockMod.create({
|
|
19
|
-
multiplayer: "RageMP", // or "AltV"
|
|
19
|
+
multiplayer: "RageMP", // or "AltV", or "Mock"
|
|
20
20
|
});
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
### Multiplayer Types
|
|
24
|
+
|
|
25
|
+
Rock-Mod supports three multiplayer types:
|
|
26
|
+
|
|
27
|
+
1. **RageMP** - For developing mods for RageMP servers
|
|
28
|
+
2. **AltV** - For developing mods for AltV servers
|
|
29
|
+
3. **Mock** - For testing and development without multiplayer dependencies
|
|
30
|
+
|
|
31
|
+
### Mock Mode
|
|
32
|
+
|
|
33
|
+
Mock mode provides a complete mock environment for testing your mods without requiring a multiplayer server. It includes:
|
|
34
|
+
|
|
35
|
+
- Full entity hierarchy (BaseObject, WorldObject, Entity)
|
|
36
|
+
- All entity types (Blip, Colshape, Marker, Object, Ped, Player, Vehicle)
|
|
37
|
+
- Type-safe events and RPC system
|
|
38
|
+
- In-memory state management
|
|
39
|
+
- Player connection simulation
|
|
40
|
+
|
|
41
|
+
Example using Mock mode for development:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { RockMod } from "rock-mod";
|
|
45
|
+
|
|
46
|
+
// Initialize in Mock mode
|
|
47
|
+
const rockMod = await RockMod.create({
|
|
48
|
+
multiplayer: "Mock",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Subscribe to events
|
|
52
|
+
rockMod.net.events.on({
|
|
53
|
+
"rm::playerConnected": (player) => {
|
|
54
|
+
console.log(`Player ${player.name} connected`);
|
|
55
|
+
},
|
|
56
|
+
"rm::playerDisconnected": (player) => {
|
|
57
|
+
console.log(`Player ${player.name} disconnected`);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Register RPC handlers
|
|
62
|
+
rockMod.net.rpc.register("getPlayerInfo", (player) => {
|
|
63
|
+
return {
|
|
64
|
+
id: player.id,
|
|
65
|
+
name: player.name,
|
|
66
|
+
position: player.position,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Example using Mock mode for testing:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { TestRockMod } from "rock-mod/testing";
|
|
75
|
+
|
|
76
|
+
// Initialize test environment
|
|
77
|
+
const rockMod = await TestRockMod.create({
|
|
78
|
+
multiplayer: "Mock",
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Simulate player connection
|
|
82
|
+
const player = rockMod.simulatePlayerConnect({
|
|
83
|
+
name: "TestPlayer",
|
|
84
|
+
position: { x: 0, y: 0, z: 0 },
|
|
85
|
+
health: 100,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Test your mod logic here
|
|
89
|
+
// ...
|
|
90
|
+
|
|
91
|
+
// Simulate player disconnection
|
|
92
|
+
rockMod.simulatePlayerDisconnect(player);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Features
|
|
96
|
+
|
|
97
|
+
- **Cross-Platform Support**: Write once, run on any supported platform
|
|
98
|
+
- **Type Safety**: Full TypeScript support with proper type definitions
|
|
99
|
+
- **Entity Management**: Unified API for managing game entities
|
|
100
|
+
- **Networking**: Type-safe events and RPC system
|
|
101
|
+
- **Testing**: Dedicated testing API through `rock-mod/testing`
|
|
102
|
+
- **Modular Design**: Easy to extend and customize
|
|
103
|
+
|
|
104
|
+
### Documentation
|
|
105
|
+
|
|
23
106
|
Please note that client-side implementation is not yet available in this version.
|
|
24
107
|
|
|
25
108
|
Rock-Mod simplifies multiplayer mod development by providing unified tools for managing game entities, networking, and more across different platforms.
|
|
109
|
+
|
|
110
|
+
### Contributing
|
|
111
|
+
|
|
112
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
113
|
+
|
|
114
|
+
### License
|
|
115
|
+
|
|
116
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
package/dist/server/RockMod.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { INetManager } from "./net/common/INetManager";
|
|
2
2
|
import { IBlipsManager, IColshapesManager, IMarkersManager, IObjectsManager, IPedsManager, IPlayersManager, IVehiclesManager } from "./entities";
|
|
3
3
|
import { IUtilsManager } from "./utils";
|
|
4
|
+
import { IManagersFactory } from "./factories/common/IManagersFactory";
|
|
4
5
|
type MultiplayerType = "RageMP" | "AltV" | "Mock";
|
|
5
6
|
export interface RockModOptions {
|
|
6
7
|
multiplayer: MultiplayerType;
|
|
@@ -28,6 +29,6 @@ export declare class RockMod {
|
|
|
28
29
|
get players(): IPlayersManager;
|
|
29
30
|
get utils(): IUtilsManager;
|
|
30
31
|
get vehicles(): IVehiclesManager;
|
|
31
|
-
|
|
32
|
+
protected constructor(managersFactory: IManagersFactory);
|
|
32
33
|
}
|
|
33
34
|
export {};
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import { IPlayersManager } from "../../common/player/IPlayersManager";
|
|
2
2
|
import { MockPlayer } from "./MockPlayer";
|
|
3
3
|
import { MockEntitiesManager } from "../entity/MockEntitiesManager";
|
|
4
|
+
import { Vector3D } from "../../../common/utils/math/Vectors";
|
|
5
|
+
export interface IMockPlayerConnectOptions {
|
|
6
|
+
id?: number;
|
|
7
|
+
name?: string;
|
|
8
|
+
socialClub?: string;
|
|
9
|
+
position?: Vector3D;
|
|
10
|
+
dimension?: number;
|
|
11
|
+
health?: number;
|
|
12
|
+
armour?: number;
|
|
13
|
+
ip?: string;
|
|
14
|
+
serial?: string;
|
|
15
|
+
}
|
|
4
16
|
export declare class MockPlayersManager extends MockEntitiesManager<MockPlayer> implements IPlayersManager {
|
|
17
|
+
private _nextId;
|
|
5
18
|
constructor();
|
|
6
19
|
getByName(name: string): MockPlayer;
|
|
7
20
|
findByName(name: string): MockPlayer | null;
|
|
8
21
|
getBySocialClub(socialClub: string): MockPlayer;
|
|
9
22
|
findBySocialClub(socialClub: string): MockPlayer | null;
|
|
23
|
+
createPlayer(options?: IMockPlayerConnectOptions): MockPlayer;
|
|
24
|
+
simulateConnect(options?: IMockPlayerConnectOptions): MockPlayer;
|
|
25
|
+
simulateDisconnect(player: MockPlayer): void;
|
|
10
26
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MockPlayersManager = void 0;
|
|
4
|
+
const MockPlayer_1 = require("./MockPlayer");
|
|
4
5
|
const MockEntitiesManager_1 = require("../entity/MockEntitiesManager");
|
|
6
|
+
const RockMod_1 = require("../../../RockMod");
|
|
7
|
+
const common_1 = require("../../common");
|
|
8
|
+
const Vectors_1 = require("../../../common/utils/math/Vectors");
|
|
5
9
|
class MockPlayersManager extends MockEntitiesManager_1.MockEntitiesManager {
|
|
10
|
+
_nextId;
|
|
6
11
|
constructor() {
|
|
7
12
|
super({
|
|
8
13
|
baseObjectsType: "player",
|
|
9
14
|
});
|
|
15
|
+
this._nextId = 0;
|
|
10
16
|
}
|
|
11
17
|
getByName(name) {
|
|
12
18
|
const player = this.findByName(name);
|
|
@@ -38,5 +44,36 @@ class MockPlayersManager extends MockEntitiesManager_1.MockEntitiesManager {
|
|
|
38
44
|
}
|
|
39
45
|
return null;
|
|
40
46
|
}
|
|
47
|
+
createPlayer(options = {}) {
|
|
48
|
+
const { id = this._nextId++, name = `Player${id}`, socialClub = `Player${id}`, position = new Vectors_1.Vector3D(0, 0, 0), dimension = 0, health = 100, armour = 0, ip = "127.0.0.1", serial = `MOCK_${id}`, } = options;
|
|
49
|
+
const player = new MockPlayer_1.MockPlayer({
|
|
50
|
+
id,
|
|
51
|
+
type: common_1.BaseObjectType.Player,
|
|
52
|
+
name,
|
|
53
|
+
socialClub,
|
|
54
|
+
position,
|
|
55
|
+
dimension,
|
|
56
|
+
health,
|
|
57
|
+
armour,
|
|
58
|
+
ip,
|
|
59
|
+
serial,
|
|
60
|
+
model: 0,
|
|
61
|
+
rotation: new Vectors_1.Vector3D(0, 0, 0),
|
|
62
|
+
});
|
|
63
|
+
this.registerBaseObject(player);
|
|
64
|
+
return player;
|
|
65
|
+
}
|
|
66
|
+
simulateConnect(options = {}) {
|
|
67
|
+
const player = this.createPlayer(options);
|
|
68
|
+
RockMod_1.RockMod.instance.net.events.emit("rm::playerConnected", player);
|
|
69
|
+
return player;
|
|
70
|
+
}
|
|
71
|
+
simulateDisconnect(player) {
|
|
72
|
+
if (!this._baseObjects.has(player.id)) {
|
|
73
|
+
throw new Error(`Player with id ${player.id} not found`);
|
|
74
|
+
}
|
|
75
|
+
RockMod_1.RockMod.instance.net.events.emit("rm::playerDisconnected", player);
|
|
76
|
+
this.unregisterBaseObject(player);
|
|
77
|
+
}
|
|
41
78
|
}
|
|
42
79
|
exports.MockPlayersManager = MockPlayersManager;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RageMarker = void 0;
|
|
4
4
|
const RageWorldObject_1 = require("../worldObject/RageWorldObject");
|
|
5
5
|
const utils_1 = require("../../../common/utils");
|
|
6
|
-
var RGBA = AltVShared.RGBA;
|
|
7
6
|
class RageMarker extends RageWorldObject_1.RageWorldObject {
|
|
8
7
|
get markerType() {
|
|
9
8
|
return this.mpEntity.model;
|
|
@@ -16,7 +15,7 @@ class RageMarker extends RageWorldObject_1.RageWorldObject {
|
|
|
16
15
|
}
|
|
17
16
|
get color() {
|
|
18
17
|
const [r, g, b, a] = this.mpEntity.getColor();
|
|
19
|
-
return new RGBA(r, g, b, a ?? 255);
|
|
18
|
+
return new utils_1.RGBA(r, g, b, a ?? 255);
|
|
20
19
|
}
|
|
21
20
|
get rotation() {
|
|
22
21
|
const { x, y, z } = this.mpEntity.rotation;
|
|
@@ -9,6 +9,7 @@ const MockMarkersManager_1 = require("../../entities/mock/marker/MockMarkersMana
|
|
|
9
9
|
const MockObjectsManager_1 = require("../../entities/mock/object/MockObjectsManager");
|
|
10
10
|
const MockPedsManager_1 = require("../../entities/mock/ped/MockPedsManager");
|
|
11
11
|
const MockVehiclesManager_1 = require("../../entities/mock/vehicle/MockVehiclesManager");
|
|
12
|
+
const MockUtilsManager_1 = require("../../utils/mock/MockUtilsManager");
|
|
12
13
|
class MockManagersFactory {
|
|
13
14
|
createNetManager() {
|
|
14
15
|
return new MockNetManager_1.MockNetManager();
|
|
@@ -32,7 +33,7 @@ class MockManagersFactory {
|
|
|
32
33
|
return new MockPlayersManager_1.MockPlayersManager();
|
|
33
34
|
}
|
|
34
35
|
createUtilsManager() {
|
|
35
|
-
|
|
36
|
+
return new MockUtilsManager_1.MockUtilsManager();
|
|
36
37
|
}
|
|
37
38
|
createVehiclesManager() {
|
|
38
39
|
return new MockVehiclesManager_1.MockVehiclesManager();
|
package/dist/server/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export * from "./common/utils";
|
|
|
3
3
|
export { BaseObjectType, IBaseObject as IRockModBaseObject, IBlip as IRockModBlip, IColshape as IRockModColshape, IEntity as IRockModEntity, IMarker as IRockModMarker, IObject as IRockModObject, IPed as IRockModPed, IPlayer as IRockModPlayer, IVehicle as IRockModVehicle, IWorldObject as IRockModWorldObject, } from "./entities";
|
|
4
4
|
export { INetServerEvents, INetClientEvents } from "./net/common/events/IEventsManager";
|
|
5
5
|
export { INetServerRPC, INetClientRPC } from "./net/common/rpc/IRPCManager";
|
|
6
|
+
export * from "./testing";
|
package/dist/server/index.js
CHANGED
|
@@ -19,3 +19,4 @@ __exportStar(require("./RockMod"), exports);
|
|
|
19
19
|
__exportStar(require("./common/utils"), exports);
|
|
20
20
|
var entities_1 = require("./entities");
|
|
21
21
|
Object.defineProperty(exports, "BaseObjectType", { enumerable: true, get: function () { return entities_1.BaseObjectType; } });
|
|
22
|
+
__exportStar(require("./testing"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MockPlayer } from "entities/mock/player/MockPlayer";
|
|
2
|
+
import { IMockPlayerConnectOptions } from "./entities/mock/player/MockPlayersManager";
|
|
3
|
+
export declare class RockModTesting {
|
|
4
|
+
static simulatePlayerConnect(options?: IMockPlayerConnectOptions): MockPlayer;
|
|
5
|
+
static simulatePlayerDisconnect(player: MockPlayer): void;
|
|
6
|
+
static createMockPlayerNow(options?: IMockPlayerConnectOptions): MockPlayer;
|
|
7
|
+
}
|
|
8
|
+
export { IMockPlayerConnectOptions, type MockPlayer };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RockModTesting = void 0;
|
|
4
|
+
const RockMod_1 = require("./RockMod");
|
|
5
|
+
class RockModTesting {
|
|
6
|
+
static simulatePlayerConnect(options) {
|
|
7
|
+
const manager = RockMod_1.RockMod.instance.players;
|
|
8
|
+
return manager.simulateConnect(options);
|
|
9
|
+
}
|
|
10
|
+
static simulatePlayerDisconnect(player) {
|
|
11
|
+
const manager = RockMod_1.RockMod.instance.players;
|
|
12
|
+
return manager.simulateDisconnect(player);
|
|
13
|
+
}
|
|
14
|
+
static createMockPlayerNow(options) {
|
|
15
|
+
const manager = RockMod_1.RockMod.instance.players;
|
|
16
|
+
return manager.createPlayer(options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.RockModTesting = RockModTesting;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockUtilsManager = void 0;
|
|
4
|
+
class MockUtilsManager {
|
|
5
|
+
hash(value) {
|
|
6
|
+
// Simple hash function for mock mode
|
|
7
|
+
let hash = 0;
|
|
8
|
+
for (let i = 0; i < value.length; i++) {
|
|
9
|
+
const char = value.charCodeAt(i);
|
|
10
|
+
hash = (hash << 5) - hash + char;
|
|
11
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
12
|
+
}
|
|
13
|
+
return hash;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.MockUtilsManager = MockUtilsManager;
|
package/package.json
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rock-mod",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./testing": {
|
|
13
|
+
"types": "./dist/testing.d.ts",
|
|
14
|
+
"default": "./dist/testing.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"typesVersions": {
|
|
18
|
+
"*": {
|
|
19
|
+
"testing": [
|
|
20
|
+
"./dist/testing.d.ts"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
7
24
|
"scripts": {
|
|
8
25
|
"start": "npx tsx src/server/index.ts",
|
|
9
26
|
"build": "npm run build:server && npm run build:client",
|
|
@@ -16,7 +33,7 @@
|
|
|
16
33
|
"lint:check": "npm run lint:server:check && npm run lint:client:check",
|
|
17
34
|
"lint:fix": "npm run lint:server:fix && npm run lint:client:fix",
|
|
18
35
|
"format:check": "prettier --check .",
|
|
19
|
-
"format:fix": "prettier --write .",
|
|
36
|
+
"format:fix": "prettier --write . --log-level=silent",
|
|
20
37
|
"type:server:check": "tsc --noEmit --project src/server/tsconfig.json",
|
|
21
38
|
"type:client:check": "tsc --noEmit --project src/client/tsconfig.json",
|
|
22
39
|
"type:check": "npm run type:server:check && npm run type:client:check",
|