Kartik Scripts

Live Collaboration Setup

Enable real-time collaboration in your MDT for seamless communication and synchronized data updates! Whether editing an incident report, filling out warrants, or updating profiles, multiple officers can edit documents simultaneously with changes propagating in real time.

[!NOTE] Kartik MDT V2 uses a high-performance built-in WebSocket server running directly on your FiveM server on port 3002. Standard event-based syncing (using NUI events) has been deprecated in V2 in favor of this far more robust, real-time WebSocket architecture.


⚙️ Configuration in server_config.lua

To enable real-time collaboration, open shared/server_config.lua and locate the ServerConfig.WebSocket configuration block:

-- Live Collaboration WebSocket Server
-- This is server-side only and never exposed to shared/config.lua
ServerConfig.WebSocket = {
    Enabled = true, -- Enable the built-in WebSocket server
    
    -- Used when TunnelURL is empty. ws:// only works if the game client is on the same machine.
    IP = "127.0.0.1",
    Port = 3002, -- Built-in WebSocket Server Port

    -- Cloudflare Tunnel URL (required for remote/multi-player setups to bypass HTTPS block)
    TunnelURL = "wss://YOUR-TUNNEL-NAME.trycloudflare.com"
}

🔒 The Secure Protocol (wss://) Requirement

Because FiveM clients and modern web browsers connect over secure connections (HTTPS), the browser blocklist prohibits connecting to insecure WebSockets (ws://).

[!CAUTION] When pasting your tunnel URL in TunnelURL, you MUST use the wss:// prefix (not https://, http://, or ws://).

  • Correct: wss://vanilla-limits-shorts-mature.trycloudflare.com
  • Incorrect: https://vanilla-limits-shorts-mature.trycloudflare.com
  • Incorrect: ws://vanilla-limits-shorts-mature.trycloudflare.com

🌐 Tunnel Configuration Options

For multiplayer/remote server setups, you must expose the local WebSocket port 3002 to a secure public address. Below are the two most common and secure methods to accomplish this.

Cloudflare Tunnels provide a secure, low-latency, and free connection back to your local port.

1. Installation

Install Cloudflared using winget via CMD:

winget install Cloudflare.Cloudflared

If winget is not available, download the executable directly from Cloudflare Releases and rename it to cloudflared.exe.

2. Start the Tunnel

To expose your WebSocket port 3002 securely without a Cloudflare account login:

cloudflared tunnel --url http://localhost:3002

If the above command uses the QUIC protocol and encounters connection blocks on your network, force it to use h2mux instead:

cloudflared tunnel --protocol h2mux --url http://localhost:3002

3. Configure the URL

Once the tunnel starts, it will print a public URL in the console resembling:

https://randomstring.trycloudflare.com

Copy this URL, change the https:// prefix to wss://, and paste it into your TunnelURL config:

TunnelURL = "wss://randomstring.trycloudflare.com"

Option B: Ngrok Tunnel

Ngrok is an easy-to-use developer tunnel service that supports quick testing.

1. Installation & Setup

  1. Sign up for a free account at Ngrok.
  2. Install Ngrok via CMD:
    winget install Ngrok.Ngrok
  3. Retrieve your auth token from your Ngrok dashboard and authenticate:
    ngrok config add-authtoken <YOUR_AUTH_TOKEN>

2. Start the Tunnel

Start the HTTP tunnel on port 3002:

ngrok http 3002

3. Configure the URL

Ngrok will generate a secure public address in your terminal:

https://randomstring.ngrok-free.app

Copy this URL, change the https:// prefix to wss://, and paste it into your TunnelURL config:

TunnelURL = "wss://randomstring.ngrok-free.app"

On this page