Server Files

This commit is contained in:
Hopeless YABO
2026-03-31 19:36:44 +02:00
parent d29c93c30d
commit af039b0504
36 changed files with 4265 additions and 2 deletions
+1013
View File
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
{
"name": "develop_client",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite build --watch",
"build": "vite build"
},
"devDependencies": {
"typescript": "^5.0.0",
"vite": "^5.0.0"
},
"dependencies": {
"@entityseven/rage-fw-rpc": "^0.2.5"
}
}
+53
View File
@@ -0,0 +1,53 @@
import { Rpc } from '@entityseven/rage-fw-rpc';
const rpc = new Rpc();
let browser: BrowserMp | null = null;
// Initialize CEF via standard RAGE MP event to bootstrap the browser for RPC
mp.events.add('client:initCef', (cefUrl: string, isDebug: boolean) => {
if (isDebug) {
mp.gui.chat.push(`[Client] Initializing CEF: ${cefUrl}`);
}
if (browser) {
browser.destroy();
browser = null;
}
browser = mp.browsers.new(cefUrl);
rpc.browser = browser; // Link immediately
mp.gui.chat.push(`[Client] Browser created and linked to RPC`);
mp.gui.cursor.show(true, true);
});
// Fallback: auto-link any newly created browser if current is null
mp.events.add('browserCreated', (b: BrowserMp) => {
if (!rpc.browser) {
rpc.browser = b;
mp.gui.chat.push(`[Client] RPC Browser auto-linked via browserCreated`);
}
mp.gui.chat.show(false);
});
// Custom Chat Handlers via RPC
rpc.register('chat:toggleInput', (state: boolean) => {
// This allows you to freeze other inputs while typing if you build a UI manager later
});
rpc.register('chat:sendMessage', (msg: string) => {
// Send the message natively to the server via our RPC
rpc.callServer('server:chat:receive', [msg]);
});
// Listen for structured chat broadcasts from the server (Player chat)
rpc.register('chat:push:custom', (chatData: any) => {
rpc.callBrowser('chat:addMessage', [chatData]);
});
// Listen for incoming native string messages from the server (System prints/announcements)
mp.events.add('chat:push', (text: string) => {
rpc.callBrowser('chat:addMessage', [{ type: 'system', text: text }]);
});
export { rpc };
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*"]
}
+15
View File
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite';
import { resolve } from 'path';
export default defineConfig({
build: {
outDir: '../client_packages',
emptyOutDir: false,
lib: {
entry: resolve(__dirname, 'src/index.ts'),
formats: ['iife'],
name: 'clientBundle',
fileName: () => 'client.js'
}
}
});