☰ All guides
ESXQB-Core

6-sperrzone

Restricted zones for police and other factions: one command, every player gets a notification and sees the zone on the map.

Resource folder

six_sperrzonen

01Requirements

  • ESX (1.1, 1.2 or Legacy) or QB-Core
  • No database, no items.

02Installation

  1. 01Sign in to the Cfx Portal with the account you bought with and download the script under Granted Assets.
  2. 02Unzip the download and move the folder six_sperrzonen into the resources folder of your server. Keep the folder name and upload every file, including the hidden .fxap.
  3. 03QB-Core only: open fxmanifest.lua and remove the line '@es_extended/imports.lua'. That file does not exist on a QB server and causes an error at start.
  4. 04Open config.lua, set Config.framework and enter your jobs in Config.JobAccess and Config.JobNames.
  5. 05Add ensure six_sperrzonen to your server.cfg, below your framework.
  6. 06Restart the server (or run refresh and then ensure with the folder name in the server console).

03Commands

Command

/addzone [radius]
Declares a zone at your position. The radius must be between DistanceMinimum and DistanceMaximum (125 to 500 metres by default). Only for jobs in Config.JobAccess.
/removezone
Lifts the zone you are standing in.

Both command names can be changed in the config (AddZone, RemoveZone).

04Configuration

Option

Config.framework
"esx" or "qb".
Config.newESX
true for ESX Legacy (1.2 and newer, shared object via export). false for old ESX 1.1 (shared object via event). Ignored on QB.
Sperrzone.Language
"de" or "en".
Sperrzone.DistanceMinimum / DistanceMaximum
Allowed radius in metres.
Sperrzone.AddZone / RemoveZone
Command names.
Config.JobAccess
Jobs that may declare and lift zones.
Config.JobNames
One entry per job from JobAccess: sender name of the notification (jobname), picture (img), blip name and the look of icon and radius circle.
notify()
Function for short notifications. A line for mythic_notify is prepared as a comment.

Careful

Every job in Config.JobAccess needs its own entry in Config.JobNames. Without it the command throws an error for that job.

›config.luaComplete file · 95 lines
config.lua
Config = {}

Config.framework = "esx" -- esx or qb
Config.newESX = true

Config.Sperrzone = {
    Language = "de",

    -- Radius Blip
    DistanceMinimum = 125,
    DistanceMaximum = 500,

    -- Commands Create/Delete Zone
    AddZone = "addzone",
    RemoveZone = "removezone",
}

Config.JobAccess = {
    'police',
    'fib'
}

Config.JobNames = {
    ['police'] = {
        jobname = "LS Police Department",
        img = "CHAR_CALL911",
        blipname = "Sperrzone LSPD",
        blip = { -- PD Icon
            Sprite = 60,
            Display = 4,
            Scale = 0.8,
            Colour = 3,
        },
        blip2 = { -- Circle radius colour | Blue/Red
            Colour = 4,
            Colour2 = 38,
        }
    },
    ['fib'] = {
        jobname = "Federal Investigation Bureau",
        img = "CHAR_CALL911",
        blipname = "Sperrzone FIB",
        blip = { -- FIB Icon
            Sprite = 60,
            Display = 4,
            Scale = 0.8,
            Colour = 39,
        },
        blip2 = { -- Circle radius colour | Blue/Red
            Colour = 4,
            Colour2 = 38,
        }
    },
    -- More Jobs here | Copy and paste one of the top Jobs
}

Config.Locales = {
    ['de'] = {
        ['notify_subject'] = '~r~SPERRZONE~s~',

        ['notify_message_addZone'] = 'Eine Sperrzone an der ~r~%s~s~ wurde ausgerufen. ~y~Umkreis: %sM~s~',
        ['notify_message_approach'] = 'Wer sich dennoch nähert, muss mit ~r~härteren Maßnahmen~s~ rechnen',
        ['notify_message_removeZone'] = 'Die Sperrzone an der ~r~%s~s~ wurde aufgehoben!',

        ['radius_invalid'] = 'Radius: %s-%s',
        ['player_cuffed'] = 'Du bist gefesselt!',
    },
    ['en'] = {
        ['notify_subject'] = '~r~Exclusion Zone~s~',

        ['notify_message_addZone'] = 'A exclusion zone has been declared at ~r~%s~s~. ~y~Radius: %sM~s~',
        ['notify_message_approach'] = 'Anyone who approaches will have to expect ~r~tougher measures~s~',
        ['notify_message_removeZone'] = 'The exclusion zone at ~r~%s~s~ has been lifted!',

        ['radius_invalid'] = 'Radius: %s-%s',
        ['player_cuffed'] = 'You are handcuffed!',
    }
}

function notify(type, msg, server)
    if server then
        TriggerClientEvent('esx:showNotification', source, msg) -- ESX
        -- exports['mythic_notify']:SendAlert(type, msg) -- Mythic Notify
    else
        ESX.ShowNotification(msg) -- ESX
        -- exports['mythic_notify']:SendAlert(type, msg) -- Mythic Notify
    end
end

function ShowAdvancedNotification(title, subject, msg, icon, iconType)
    SetNotificationTextEntry("STRING")
    AddTextComponentString(msg)
    SetNotificationMessage(icon, icon, true, iconType, title, subject)
    DrawNotification(false, true)
end

Good to know

Modified framework? Every framework call of this script sits in client/esx.lua, client/qb.lua, server/esx.lua and server/qb.lua. Adapt those files if your server uses renamed events or a custom inventory. They stay editable in the Locked version too.

05Still stuck?

Open a ticket on our Discord. Send the script name, your framework and version, and the full error from the server console (F8 for client errors). That saves a round of questions.