Kartik Scripts

Web MDT Setup

Kartik MDT V2 features a native FiveM HTTP Web Server integrated directly into the resource. This allows your department members (police, EMS, civilians) to access the MDT completely out of the game using a standard web browser (Chrome, Firefox, Edge, etc.) with authentication handled securely via Discord OAuth2.

๐Ÿ”— Access URL vs. Callback URL

[!WARNING] Do NOT share or visit the /auth/callback URL directly to open the MDT!

  • To access the Web MDT: Users must visit the base URL (ending in /kartik-mdt/):
    • http://YOUR_PUBLIC_IP:30120/kartik-mdt/
    • http://xxxxxx-xxxxxx.users.cfx.re/kartik-mdt/
  • The Callback URL (/auth/callback): This is strictly for configuring the Redirect URI in the Discord Developer Portal. Visiting this URL directly will result in an error or a failed login.

๐Ÿ›ก๏ธ Discord Developer Portal Configuration

To allow users to log in securely, you must register a Discord Application and configure the OAuth2 credentials.

1. Register a Discord Application

  1. Go to the Discord Developer Portal.
  2. Click New Application at the top right, name it (e.g., My Server MDT), and click Create.
  3. Under the OAuth2 tab on the left sidebar:
    • Copy the Client ID.
    • Click Reset Secret and copy the new Client Secret.

2. Configure Redirect URIs

In the Discord Developer Portal, under the OAuth2 -> Redirects section, you must add the callback URLs.

[!IMPORTANT] The Web MDT callback endpoint is strictly /kartik-mdt/auth/callback (NOT /kartik-mdt-v2/auth/callback). Do not add -v2 to the redirect URI path!

You can configure two types of Redirect URIs depending on your server environment:

๐ŸŒ Option A: Public IP & Port (Direct)

If your server machine's FXServer port (default 30120) is publicly open and directly accessible, you can use your public IP:

http://YOUR_PUBLIC_IP:30120/kartik-mdt/auth/callback

When your FiveM server starts, it prints a Cfx.re URL in the console. You can use this dynamic cfx.re proxy link:

http://xxxxxx-xxxxxx.users.cfx.re/kartik-mdt/auth/callback

(Make sure to copy the exact URL printed in your server console when the resource initializes)

Once added, click Save Changes at the bottom of the page.


โš™๏ธ Configuration in server_config.lua

Open your shared/server_config.lua file and configure the ServerConfig.DiscordOAuth settings with your credentials:

-- Discord OAuth2 Settings for Web MDT Portal
ServerConfig.DiscordOAuth = {
    Enabled = true,
    ClientId = "YOUR_DISCORD_CLIENT_ID", -- REPLACE with your Discord Client ID
    ClientSecret = "YOUR_DISCORD_CLIENT_SECRET", -- REPLACE with your Discord Client Secret
    
    -- Paste the exact same redirect URI you configured in the Discord Developer Portal!
    RedirectUri = "http://YOUR_PUBLIC_IP:30120/kartik-mdt/auth/callback" 
}

๐Ÿ‘ค Linking In-Game Characters

For police officers, deputies, or staff members to log in, their Discord account must be linked to their in-game character:

  • Insert a record mapping the user's Discord ID (Snowflake) to their character citizenid in the mdt_discord_mappings database table.
  • Once mapped, logging in through the web portal automatically fetches their in-game character's job, grade, and department permissions!
  • Guest Bypass: If a user logs in via Discord and has no active mapping, they are automatically signed in as a Guest Civilian using their Discord display name, allowing them to browse civilian-facing features without admin credentials.

[!IMPORTANT] Quick Reminder: When sharing the link for users to access the Web MDT, always use the base URL (e.g., http://YOUR_PUBLIC_IP:30120/kartik-mdt/). Do NOT send them the /auth/callback URL!

On this page