<div align="center">

# 🔥 YabosRageMPCore

### A open-source **RAGE:MP** GTA V multiplayer server framework.

[![License: GPLv3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![RAGE:MP](https://img.shields.io/badge/Platform-RAGE%3AMP-red)](https://rage.mp/)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?logo=typescript)](https://www.typescriptlang.org/)
[![Vue.js](https://img.shields.io/badge/Vue-3.x-42b883?logo=vue.js)](https://vuejs.org/)
[![Vite](https://img.shields.io/badge/Vite-5.x-646CFF?logo=vite)](https://vitejs.dev/)

_A modern, scalable server boilerplate with a type-safe RPC system and a Hot-Module-Reloading CEF UI pipeline._

</div>

---

## ✨ Features

- **Type-safe RPC** across Server, Client, and CEF using [`@entityseven/rage-fw-rpc`](https://github.com/entityseven/rage-framework)
- **Split architecture** — clean separation between server logic, client scripts, and UI
- **Modern UI pipeline** — Vue 3 + Vite with Hot Module Replacement for rapid development
- **Custom Chat UI** — in-game chat built in Vue with support for player, global, admin, system, and error messages
- **Smart CEF routing** — automatically routes CEF to `localhost:3000` (dev) or the bundled package (production) via `settings.json`
- **Zero boilerplate overhead** — only the code that matters

---

## 📁 Project Structure

```
YabosRageMPCore/
├── packages/
│   └── core/           # Server-side logic (Node.js)
│       └── index.js    # Entry point: RPC handlers, player events
│
├── develop_client/     # Client-side TypeScript source
│   └── src/
│       └── index.ts    # Compiled to client_packages/client.js
│
├── develop_cef/        # Vue 3 SPA for all in-game UI
│   └── src/
│       ├── App.vue
│       └── components/
│           └── Chat.vue   # Custom chat system
│
├── client_packages/    # [BUILD OUTPUT] — loaded by RAGE:MP
│   ├── index.js        # Loader entrypoint
│   ├── client.js       # Compiled client bundle
│   └── cef/            # Compiled Vue SPA
│
└── settings.json       # Database, debug, and CEF environment config
```

---

## 🚀 Getting Started

### Prerequisites

- [Node.js](https://nodejs.org/) >= 18.x
- [RAGE:MP Server](https://rage.mp/)

### 1. Clone the repository

```bash
git clone https://github.com/yabooo666/YabosRageMPCore
cd YabosRageMPCore
```

### 2. Configure `settings.json`

```json
{
  "mysql": {
    "host": "localhost",
    "port": 3306,
    "user": "root",
    "password": "",
    "database": "ragempcore"
  },
  "debugger": true,
  "cef": "dev"
}
```

> Set `"cef": "dev"` to use the Vite dev server, `"cef": "build"` to use the compiled bundle.

### 3. Install dependencies

```bash
# Server core
npm install

# Client script
cd ../../develop_client && npm install

# CEF UI
cd ../develop_cef && npm install
```

### 4a. Development Mode (with HMR)

```bash
# Terminal 1 — Watch & compile client script
cd develop_client && npm run dev

# Terminal 2 — Start Vite dev server for CEF
cd develop_cef && npm run dev
```

### 4b. Production Mode

```bash
# Compile client script
cd develop_client && npm run build

# Compile CEF UI
cd develop_cef && npm run build

# Start the RAGE:MP server
./ragemp-server.exe
```

---

## 🔌 RPC Communication

Cross-environment communication is handled by [RageFW RPC](https://github.com/entityseven/rage-framework).

| From   | To     | Method                                    |
| ------ | ------ | ----------------------------------------- |
| Server | Client | `rpc.callClient(player, 'event', [args])` |
| Client | Server | `rpc.callServer('event', [args])`         |
| Client | CEF    | `rpc.callBrowser('event', [args])`        |
| CEF    | Client | `chatRpc.callClient('event', [args])`     |

To register a handler:

```js
rpc.register("my:event", (player, arg1) => {
  // handle it
  return true;
});
```

---

## 📄 License

This project is licensed under the **GNU General Public License v3.0**.  
See the [LICENSE](LICENSE) file for details.

```
YabosRageMPCore — RAGE:MP Server Framework
Copyright (C) 2025

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
```

---

<div align="center">

**Made with ❤️ for the RAGE:MP community**

</div>
