TWH-Scripts
  • ๐Ÿ‘‹Welcome!
  • About us
    • ๐Ÿš€Vision, Mission & Focus
      • Vision
      • Mission
      • Focus
    • ๐Ÿ’–Values
  • Team
    • ๐Ÿ‘‹Meet the Team!
  • Collaborating
    • ๐ŸคHow we Work Together
  • Resources
    • ๐Ÿ“„Script-Documentations
      • Addiction
      • Bankrob
      • BodyStatusText
      • Calendar-Rewards
      • Collect
      • Lumber & Mining Essentials
      • Collector's Conquest Bundle
        • Tradingcards
        • Boosterpacks
        • Tradingcard Upgrades
      • Custom Dates
      • Dispatch-System
      • Lawmen
      • Mapmarker
      • NPC-Guides
      • Oilcorp.
      • Processing
      • Promotion-Pass
      • Social-Level System
      • Social-Pass
      • Storage
    • ๐Ÿ“‚Open Source
    • ๐Ÿ“Useful Snippets and Info
      • Addiction and Metabolism
  • Services
    • ๐Ÿ› ๏ธCustom Orders and Personalized Development Services
    • ๐Ÿ“–Advanced Logging System
Powered by GitBook
On this page
  • Instruction manual
  • Installation
  • Config
  1. Resources
  2. Script-Documentations

Dispatch-System

Frameworks: VORP

PreviousCustom DatesNextLawmen

Last updated 2 years ago

Introducing the twh_dispatch script, a versatile and adaptable dispatch tool designed primarily for doctors, but easily extendable for other dispatch types and alerts. This innovative tool enables you to configure a wide range of dispatch options and settings, catering to the unique requirements of your RedM RP server.

Key Features:

  1. Customizable Dispatch Configuration: Set up the command and other variables to tailor your dispatch system to your specific needs.

  2. Player Death Options: Enable or disable hover messages when a player is dead, or require player death for using the dispatch command.

  3. Location-based Alerts: Create sound and text alerts near specified locations, and allow players to switch between active dispatches using prompts.

  4. NPC Medic Integration: Utilize an NPC medic with voice lines for an immersive dispatch experience.

  5. Compatibility with : Apply level restrictions for dispatch usage, ensuring balanced gameplay.

  6. Webhook Integration: Stay informed with webhook notifications that provide real-time updates on dispatch events and activities.

The twh_dispatch script offers a comprehensive dispatch solution that can be adapted to suit various dispatch types and alerts. From location-based alerts to compatibility with other scripts, twh_dispatch ensures an engaging and immersive in-game experience.

Initialization

local dispatchAPI = exports['twh_dispatch'].dispatchAPI()

Usage

dispatchAPI.triggerDispatch(alertType) --triggers a dispatch with alertType from sender
dispatchAPI.getActiveDispatchs() --returns a table with all active dispatchs of the player with player id from sender as key and alertType and coords as values
dispatchAPI.AcceptDispatch(alertKey, userId, location) --accepts a dispatch with alertKey from sender

Instruction manual

Installation

Add following line to your server.cfg or ressource.cfg:

  • ensure twh_dispatch

Config

Config = {}


Config.adminGroups = {"admin"}

--Webhook
Config.Logs         = true 
Config.webhook      = ""
Config.webhookColor = 16711680 
Config.name         = "twh_dispatch" 
Config.logo         = "https://via.placeholder.com/30x30" -- Header
Config.footerLogo   = "https://via.placeholder.com/30x30" -- Footer
Config.Avatar       = "https://via.placeholder.com/30x30" -- Avatar


Config.twh_social = true --set to true if you use twh_social


Config.debug = false --enable/disable debug mode e.g. allow you to create multiple dispatch alerts with the same user - may produce some errors when accepting alerts

--alert commands
Config.alerts = {
    medicAlert = {
        command = "alertdoctor",
        active = "Verletzte: ", -- language for active dispatches shown in prompt
        playerMustBeDead = true, --if player must be dead to use command
        playersNear = 0, --command can only be used when amount of players not near. Example: 0 = no players near | -1 ignore player limit 
        ignoreDeadPlayersNearby = true, --ignore dead players when checking for playersNear
        playersNearRange = 50, --range in which players are counted
        informCallerWhenDispatchAccepted = true, --inform caller when dispatch is accepted with message yourDispatchWasAccepted
        informCallerWhenDispatchAcceptedShowTime = 30000, --time in ticks how long message yourDispatchWasAccepted is shown
        jobsThatCanSendThisAlert = {}, --jobs that can send this alert
        jobs = {"medic"}, --jobs that can see the alert and have access to locations
        blipSprite = -695368421, --blip sprite
        blipStyle = GetHashKey("BLIP_STYLE_DEBUG_RED"), --blip style possible options for color: BLIP_STYLE_DEBUG_BLUE, BLIP_STYLE_DEBUG_GREEN, BLIP_STYLE_DEBUG_PINK, BLIP_STYLE_DEBUG_RED, BLIP_STYLE_DEBUG_YELLOW
        blipText = "Verletzte Person", --blip text
        costToUse = 1.0, --cost to use command
        delayedAlertDependingOnDistance = true, --delay alert depending on location distances
        delayedAlertMaxTime = 120000, --max time for delayed alert (delayedAlertMaxTime/1000) seconds - e.g. max time an alert needs to get send from a calling person in tumbleweed to arrive at annesburg
        locations= {
            SaintDenis = {
                name = "Saint Denis",
                center = {x = 2726.7299804688 , y = -1232.0983886719 , z = 51.0}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = 2728.8937988281 , y = -1229.8458251953 , z = 50.320301055908}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Valentine = {
                name = "Valentine",
                center = {x = -284.51480102539 , y = 807.51458740234 , z = 120.38590240479}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -284.37896728516 , y = 807.53784179688 , z = 119.38590240479}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Rhodes = {
                name = "Rhodes",
                center = {x = 1371.3581542969 , y = -1307.6119384766 , z = 78.970977783203}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = 1374.0935058594 , y = -1307.1138916016 , z = 77.970977783203}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Strawberry = {
                name = "Strawberry",
                center = {x = -1804.923828125 , y = -430.77267456055 , z = 159.83192443848}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -1803.0139160156 , y = -431.37149047852 , z = 158.82983398438}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Blackwater_surgery = {
                name = "Blackwater Surgery",
                center = {x = -788.34893798828 , y = -1306.7858886719 , z = 45.79613494873}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -785.23510742188 , y = -1302.544921875 , z = 44.226848602295}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Blackwater = {
                name = "Blackwater",
                center = {x = -783.12084960938 , y = -1574.5261230469 , z = 60.644886016846}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -788.06384277344 , y = -1575.3327636719 , z = 59.59493637085}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Tumbleweed = {
                name = "Tumbleweed",
                center = {x = -5513.4594726563 , y = -2971.7221679688 , z = 3.1743547916412}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -5512.9970703125 , y = -2973.0378417969 , z = 2.1706414222717}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            }
            
        },

        --if you use twh_social
        levelRestriction = {min = 0,max=-1} --min is the minimum level player need to use the command. max is the maximum level player can have, after reaching max level he wont be able to use command anymore [put in -1 in max to ignore limitation]
        
        
    },
    sheriffAlert = {
        command = "alertlaw",
        active = "Aktiv: ", -- language for active dispatches shown in prompt
        playerMustBeDead = false, --if player must be dead to use command
        playersNear = -1, --command can only be used when amount of players not near. Example: 0 = no players near | -1 ignore player limit 
        ignoreDeadPlayersNearby = true, --ignore dead players when checking for playersNear
        playersNearRange = 50, --range in which players are counted
        informCallerWhenDispatchAccepted = true, --inform caller when dispatch is accepted with message yourDispatchWasAccepted
        informCallerWhenDispatchAcceptedShowTime = 30000, --time in ticks how long message yourDispatchWasAccepted is shown
        jobs = {"police","sheriff","sheriff_val","sheriff_bw","sheriff_sb","sheriff_tw","sheriff_rd","sheriff_an","sheriff_ad"}, --jobs that can see the alert and have access to locations
        jobsThatCanSendThisAlert = {"police","sheriff","sheriff_val","sheriff_bw","sheriff_sb","sheriff_tw","sheriff_rd","sheriff_an","sheriff_ad"}, --jobs that can send this alert
        blipSprite = -695368421, --blip sprite
        blipStyle = 1664425300, --blip style possible options for color: BLIP_STYLE_DEBUG_BLUE, BLIP_STYLE_DEBUG_GREEN, BLIP_STYLE_DEBUG_PINK, BLIP_STYLE_DEBUG_RED, BLIP_STYLE_DEBUG_YELLOW
        blipText = "Notfall", --blip text
        costToUse = 0.0, --cost to use command
        delayedAlertDependingOnDistance = true, --delay alert depending on location distances
        delayedAlertMaxTime = 240000, --max time for delayed alert (delayedAlertMaxTime/1000) seconds - e.g. max time an alert needs to get send from a calling person in tumbleweed to arrive at annesburg
        locations= {
            SaintDenis = {
                name = "Saint Denis",
                center = {x = 2512.0004882813 , y = -1308.7916259766 , z = 49.953674316406}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = 2512.0004882813 , y = -1308.7916259766 , z = 48.953674316406}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Valentine = {
                name = "Valentine",
                center = {x = -277.07299804688 , y = 806.7353515625 , z = 120.28171539307}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -277.07299804688 , y = 806.7353515625 , z = 119.28171539307}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Rhodes = {
                name = "Rhodes",
                center = {x = 1362.0754394531 , y = -1301.9765625 , z = 78.767959594727}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = 1362.0754394531 , y = -1301.9765625 , z = 77.767959594727}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Strawberry = {
                name = "Strawberry",
                center = {x = -1808.3740234375 , y = -349.65765380859 , z = 165.65881347656}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -1811.244140625 , y = -350.28970336914 , z = 164.65746765137}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Blackwater = {
                name = "Blackwater",
                center = {x = -762.1435546875 , y = -1268.2268066406 , z = 45.041347503662}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -762.1435546875 , y = -1268.2268066406 , z = 44.041347503662}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Tumbleweed = {
                name = "Tumbleweed",
                center = {x = -5529.3388671875 , y = -2929.8325195313 , z = 0.4609249830246}, --center of the location where alert is played
                radius = 50, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -5529.3388671875 , y = -2929.8325195313 , z = -1.4609249830246}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            },
            Limpany = {
                name = "Tumbleweed",
                center = {x = -345.30276489258 , y = -155.77430725098 , z = 50.7522315979}, --center of the location where alert is played
                radius = 70, --radius alert is played
                newDispatchArrivedNotifyConfig = {titel = "Dispatch", text = "Neuer Dispatch eingegangen", textureDict = "menu_textures", textureName = "menu_icon_alert", notifyTimeInTicks = 5000, color = "COLOR_WHITE"},
                confirmLoc = {x = -343.70669555664 , y = -153.55773925781 , z = 50.711585998535}, --location where alert can be confirmed
                confirmRadius = 1, --radius where alert can be confirmed
                alertVolume = 1, --can be add up to 99, put in 0 if no audio alert should be played
                alertTime = 500, -- how long audio alert should last
            }
            
        },

        --if you use twh_social
        levelRestriction = {min = 0,max=-1} --min is the minimum level player need to use the command. max is the maximum level player can have, after reaching max level he wont be able to use command anymore [put in -1 in max to ignore limitation]
        
        
    }
}

Config.generalNotifyStyle = {
    levelRestrictionLow = {textureDict = "menu_textures", textureName = "cross", notifyTimeInTicks = 4000, color = "COLOR_WHITE" },   -- textureDict - Name of texture dictionary to load texture from ----- textureName - Name of texture to load from texture dictionary
    levelRestrictionHigh = {textureDict = "menu_textures", textureName = "cross", notifyTimeInTicks = 4000, color = "COLOR_WHITE"},
    playerIsNotDeadAndCantAcceptDispatch = {textureDict = "menu_textures", textureName = "cross", notifyTimeInTicks = 4000, color = "COLOR_WHITE"}, 
    dispatchAcceptedByAStation = {textureDict = "generic_textures", textureName = "tick", notifyTimeInTicks = 4000, color = "COLOR_WHITE"},
    playerAcceptedDispatch = {textureDict = "generic_textures", textureName = "tick", notifyTimeInTicks = 4000, color = "COLOR_WHITE"},
    playerHasNotEnoughMoneyToTriggerDispatch = {notifyTimeInTicks = 120}, -- when using "dontUseVorpNotifyForTypicallyPlayerDeadMessages = true" it is not realy in ticks but more in milliseconds or maybe even more, you have to just test the right amount 
    dispatchWasAcceptedButPlayerIsOffline = {textureDict = "menu_textures", textureName = "cross", notifyTimeInTicks = 4000, color = "COLOR_WHITE"},
    dispatchWasSent = {notifyTimeInTicks = 300}, -- when using "dontUseVorpNotifyForTypicallyPlayerDeadMessages = true" it is not realy in ticks but more in milliseconds or maybe even more, you have to just test the right amount 
    notAllowedToTrigger = {textureDict = "menu_textures", textureName = "cross", notifyTimeInTicks = 8000, color = "COLOR_WHITE"},
}

Config.dontUseVorpNotifyForTypicallyPlayerDeadMessages = false --if true, then player dead messages will be displayed using hovering 3D Text, if false then player dead messages will be displayed using vorp notify. For some people vorp notify messages are not correctly displayed when player is in detached death state

Config.playerDeadMessage = {
    showHintTextWhenDead = false, --show hint text over dead player how to use the command 
    hintTextWhenDead = "Verstรคndige mittels 'alertdoctor' einen Arzt fรผr 1$",
}

Config.npcMedic = {
    enabled = true,                 --enable/disable npc medic
    command = "sendhelp",           --command to call npc medic
    price = 5.0,                    --price to call npc medic
    npcModel = "A_M_M_BiVFancyTravellers_01",   --model of npc medic
    medicsOnline = 1,               --how many medics max online until command cannot be used anymore
    medicJobs = {"medic"},
    levelRestriction = {min = 0,max=-1} --min is the minimum level player need to use the command. max is the maximum level player can have, after reaching max level he wont be able to use command anymore [put in -1 in max to ignore limitation]
}

Config.language = {
    dispatch = "Dispatch",
    dispatchPrompt = "Dispatch annehmen",
    notDead = "Du bist nicht bewusstlos und kannst diesen Befehl nicht benutzen",
    tooManyPlayers = "Zu viele Spieler in der Nรคhe!",
    notAllowedToTrigger = "Du bist nicht berechtigt diesen Befehl zu benutzen",
    dispatchSend = "Du hast erfolgreich einen Dispatch gesendet.",
    dispatchAcceptedByStation = "Ein Dispatch wurde von folgender Station angenommen: ",
    dispatchAccepted = "Du hast einen Dispatch angenommen. Er wird auf deiner Karte angezeigt.",
    dispatchFailed = "Der Spieler konnte nicht mehr gefunden werden.",
    notEnoughMoney = "Du hast nicht genug Geld um diesen Befehl zu benutzen",
    yourDispatchWasAccepted = "Dein Dispatch wurde angenommen",	
    district = "Distrikt: ", -- discrict
    unknownDistrict = "Unbekannt", -- unknown discrict
    distance = "Entfernung: ", -- distance
    distanceUnit = "", -- distance unit
    acceptPrompt = "Annehmen",
    nextPrompt = "Weiter",

    --npc medic
    npcMedic = "NPC Medic",
    tooManyMedics = "Zu viele ร„rzte sind momentan online!",
    revived = "Du wurdest verarztet",

    --if twh_social is used
    levelRestrictionLow = "Deine Sozialstufe ist zu niedrig",
    levelRestrictionHigh = "Deine Sozialstufe ist bereits zu hoch"
}

Config.districtNames = {
    ["3782438103"] = 'GUARMAD',
    ["2025841068"] = 'BAYOU NWA',
    ["822658194"] = 'BIG VALLEY',
    ["1308232528"] = 'BLUEWATER MARSH',
    ["-108848014"] = 'CHOLLA SPRINGS',
    ["1835499550"] = 'CUMBERLAND FOREST',
    ["426773653"] = 'DIEZCORONAS',
    ["-2066240242"] = 'GAPTOOTH RIDGE',--ADDED
    ["476637847"] = 'GREAT PLAINS',
    ["-120156735"] = 'GRIZZLIES EAST',
    ["1645618177"] = 'GRIZZLIES WEST',
    ["892930832"] = 'HENNIGAN`S STEAD',
    ["2975011176"] = 'PERDIDO',
    ["1453836102"] = 'PUNTAORGULLO',
    ["-2145992129"] = 'RIO BRAVO', --ADDED
    ["178647645"] = 'ROANOKE RIDGE',
    ["-864275692"] = 'SCARLETT MEADOWS',
    ["1684533001"] = 'TALL TREES',
    ["131399519"] = 'THE HEARTLANDS',
}

Config.keys = {
    dispatchPrompt = 0x760A9C6F, --G
}
๐Ÿ“„
twh_social
TWH-Scripts | twh_dispatch
Logo