CodeRender
  • Welcome To Code Render
  • Scripts
    • CR-DispatchMDT
      • Script Configuration
      • UI Configuration
      • Events and Custom Features
    • CR-Loading Screen Configuration
    • CR-CaravanJob
Powered by GitBook
On this page
  • Custom Pause Menu Integration
  • CR-MDT Notify System
  • Location Name Retrieval
  • Dispatch Alert Event
  • Best Practices
  1. Scripts
  2. CR-DispatchMDT

Events and Custom Features

The CR-DispatchMDT script includes custom features and events to enhance your server police related script . MDT and dispatch system. CR-MDT Notify, location name retrieval, and dispatch alerts with simple examples. Each feature specifies client-side or server-side usage for easy integration.


Custom Pause Menu Integration

Syncs the MDT with your server’s custom pause menu.

  • Client Side: Trigger the sriyo-policeMDT:trackPauseMenu event:

    • true: Pause menu opens.

    • false: Pause menu closes.

Example

-- Client Side: Pause menu opens
TriggerEvent("sriyo-policeMDT:trackPauseMenu", true)

-- Client Side: Pause menu closes
TriggerEvent("sriyo-policeMDT:trackPauseMenu", false)

Notes

  • Ensure your pause menu script triggers these events correctly.

  • Test in a staging environment to avoid MDT UI conflicts.


CR-MDT Notify System

Displays customizable notifications for alerts or messages using Font Awesome icons.

  • Client Side: Use the export or trigger the sriyo-policeMDT:cr-MDTNotify event.

  • Server Side: Trigger the event to notify all or specific players.

Options

  • title: Notification title (e.g., Robbery Alert).

  • description: Message (e.g., Store robbery in progress!).

  • type: success, error, info, or warning.

  • duration: Display time in milliseconds (e.g., 3000).

  • card: short or long.

  • position: tl (top-left), tc (top-center), tr (top-right).

  • progressable: true or false (shows progress bar).

Examples

Client Side: Using Export

-- Client Side
local CR_mdt_notify = exports["cr-dispatchMDT"]:cr_MDTNotify

CR_mdt_notify({
  icon = "fa-solid fa-bullhorn",
  title = "Incident Alert",
  description = "Store robbery in progress!",
  type = "error",
  duration = 3000,
  card = "short",
  position = "tc",
  progressable = false
})

Client Side: Using Event

-- Client Side
local notify = {
  icon = "fa-solid fa-bullhorn",
  title = "Incident Alert",
  description = "Store robbery in progress!",
  type = "error",
  duration = 3000,
  card = "short",
  position = "tc",
  progressable = false
}
TriggerEvent("sriyo-policeMDT:cr-MDTNotify", notify)

Server Side: Notify All

-- Server Side: All players
local notify = {
  icon = "fa-solid fa-bullhorn",
  title = "Incident Alert",
  description = "Store robbery in progress!",
  type = "error",
  duration = 3000,
  card = "short",
  position = "tc",
  progressable = false
}
TriggerClientEvent("sriyo-policeMDT:cr-MDTNotify", -1, notify)

Server Side: Specific Player

-- Server Side: One player
local src = source
local notify = {
  icon = "fa-solid fa-bullhorn",
  title = "Incident Alert",
  description = "Store robbery in progress!",
  type = "error",
  duration = 3000,
  card = "short",
  position = "tc",
  progressable = false
}
TriggerClientEvent("sriyo-policeMDT:cr-MDTNotify", src, notify)

Notes

  • Keep description short (<100 characters).

  • Avoid duration >10000ms to prevent overlap.

  • Test position and card for UI compatibility.


Location Name Retrieval

Gets the GTA V or custom location name (from Dispatch.Locations in config.json) based on player coordinates.

  • Client Side: Call the CR_LocationName export.

Example

-- Client Side
local CR_mdt_location = exports["cr-dispatchMDT"]:CR_LocationName

function getPlayerLocationName()
  local location = CR_mdt_location()
  print(location) -- e.g., "Main Garage" or "Vinewood"
end

Notes

  • Returns custom names (e.g., Main Garage) if within a configured radius.

  • Falls back to GTA V location if no custom match.

  • Ensure Dispatch.Locations has correct coordinates .


Dispatch Alert Event

Triggers server-side dispatch alerts (e.g., robberies) with player coordinates and messages.

  • Client Side: Send alert to server via sriyo-policeMDT:cr-DispatchAlert.

  • Server Side: Processes and forwards alerts to MDT.

Options

  • Message: Alert message (e.g., Store robbery has been triggered).

  • Title: Alert title (e.g., Store Robbery).

  • Type: success, error, info, or warning.

  • Response.x, Response.y, Response.z: Player coordinates.

Example

-- Client Side
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local DispatchAlert = {
  Message = "Store robbery has been triggered",
  Title = "Store Robbery",
  Type = "error",
  Response = {
    x = playerCoords.x,
    y = playerCoords.y,
    z = playerCoords.z
  }
}
TriggerServerEvent("sriyo-policeMDT:cr-DispatchAlert", DispatchAlert)

Notes

  • Use for incidents like robberies or emergencies.

  • Server notifies whitelisted jobs (e.g., police) per config.json.

  • Ensure accurate coordinates for blips or location data.


Best Practices

  • Test: Try features in a staging environment.

  • Performance: Use reasonable duration in notifications and avoid frequent alerts.

  • Icons: Stick to free Font Awesome icons.

  • Locations: Update Dispatch.Locations for new areas.

  • Backup: Save config.json before changes.

PreviousUI ConfigurationNextCR-Loading Screen Configuration

Last updated 1 month ago

icon: (e.g., fa-solid fa-bullhorn).

Use free .

Support: Join for help.

Font Awesome icon
Font Awesome icons
Discord