├── .gitattributes ├── fxmanifest.lua ├── server └── main.lua ├── locales └── en.json ├── README.md ├── config.lua └── client └── main.lua /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | game 'gta5' 3 | lua54 'yes' 4 | 5 | author 'iamlation' 6 | description 'A greenzones script to create controlled areas on the map for FiveM' 7 | version '1.0.1' 8 | 9 | client_scripts { 10 | 'client/*.lua' 11 | } 12 | 13 | server_scripts { 14 | 'server/*.lua' 15 | } 16 | 17 | files { 18 | 'locales/*.json', 19 | } 20 | 21 | shared_scripts { 22 | 'config.lua', 23 | '@ox_lib/init.lua' 24 | } 25 | 26 | ox_libs { 27 | 'locale', 28 | 'math' 29 | } -------------------------------------------------------------------------------- /server/main.lua: -------------------------------------------------------------------------------- 1 | lib.addCommand(Config.GreenzonesCommand, { 2 | help = locale('commands.setzone'), 3 | restricted = 'group.admin' 4 | }, function(source, args, raw) 5 | local source = source 6 | lib.callback('lation_greenzones:adminZone', source, cb) 7 | end) 8 | 9 | lib.addCommand(Config.GreenzonesClearCommand, { 10 | help = locale('commands.deletezone'), 11 | restricted = 'group.admin' 12 | }, function(source, args, raw) 13 | local source = source 14 | lib.callback('lation_greenzones:adminZoneClear', source, cb) 15 | end) 16 | 17 | lib.callback.register('lation_greenzones:data', function(source, zoneCoords, zoneName, textUI, textUIColor, textUIPosition, zoneSize, disarm, invincible, speedLimit, blipID, blipColor) 18 | TriggerClientEvent('lation_greenzones:createAdminZone', -1, zoneCoords, zoneName, textUI, textUIColor, textUIPosition, zoneSize, disarm, invincible, speedLimit, blipID, blipColor) 19 | end) 20 | 21 | lib.callback.register('lation_greenzones:deleteZone', function() 22 | TriggerClientEvent('lation_greenzones:deleteAdminZone', -1) 23 | end) -------------------------------------------------------------------------------- /locales/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "notify": { 3 | "greenzoneTitle": "Green Zone", 4 | "greenzoneEnter": "You have entered a Green Zone and certain actions have been disabled", 5 | "greenzoneExit": "You have exited a Green Zone and all actions have been restored" 6 | }, 7 | "menu": { 8 | "title": "Create Green Zone", 9 | "blipName": "Blip Name", 10 | "blipNameDescription": "The name of the Green Zone on the map", 11 | "blipNamePlaceholder": "Green Zone", 12 | "displayText": "Display Text", 13 | "displayTextDescription": "Text to display on everyone's screen in this zone", 14 | "displayTextPlaceholder": "Green Zone", 15 | "displayTextColor": "Display Text Color", 16 | "displayTextColorDescription": "The HTML color code of the text displayed", 17 | "displayTextPosition": "Display Text Position", 18 | "displayTextPositionDescription": "The position on the screen for the text", 19 | "positionRightCenter": "Right center", 20 | "positionLeftCenter": "Left center", 21 | "positionTopCenter": "Top center", 22 | "size": "Size (radius)", 23 | "disableFiring": "Disable Firing", 24 | "invincible": "Everyone Invincible", 25 | "speedLimit": "Speed Limit (MPH)", 26 | "blipID": "Blip ID", 27 | "blipIDDescription": "The sprite ID to display on the map", 28 | "blipColor": "Blip Color", 29 | "blipColorDescription": "The blip color for the above sprite" 30 | }, 31 | "confirm": { 32 | "title": "Confirm Action", 33 | "content": "Are you sure you want to delete your Green Zone?" 34 | }, 35 | "commands": { 36 | "setzone": "Create a temporary Green Zone", 37 | "deletezone": "Delete a temporary Green Zone" 38 | } 39 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lation's Greenzones 2 | A greenzones script to create controlled areas on the map for FiveM with many features. You can create persistent greenzones that exist all the time for areas like Hopitals, Police Stations, etc and completely customize them individually so each zone has it's own settings. Furthermore you can create (and delete) temporary greenzones on-the-fly while in-game via the /setzone & /clearzone commands with tons of features and customizability there too! 3 | 4 | ## Support, Scripts & More 5 | - [Click here to join our Discord](https://discord.gg/9EbY4nM5uu) 6 | - [Click here to visit our Store](https://lationscripts.com/?utm_source=github&utm_medium=free-script) 7 | 8 | ## Persistent Greenzone Features: 9 | - Create custom greenzones via the config (for places like hospitals, police stations, etc) that exists all the time 10 | - Configure and customize each and every persistent greenzone independently (each zone has its own settings) 11 | - Enable/disable player & vehicle collisions per zone 12 | - Enable/disable enforcing speed limits per zone 13 | - Enable/disable removing weapons from players hand upon entering 14 | - Enable/disable everyone from firing weapons/punching/etc while within zone 15 | - Enable/disable invincibility for everyone while within zone 16 | - Enable/disable displaying an ox_lib showTextUI within zone 17 | - Customize the text, color, icon, position, etc for the showTextUI per zone 18 | - Enable/disable displaying a blip for your greenzone on the map 19 | - Fully configure the blip (choose a radius or normal blip, or both) 20 | - Customize name, sprite, color, scale, transparency, etc of the blip 21 | 22 | ## Temporary (in-game) Greenzone Features 23 | - Create a temporary greenzone at anytime via /setzone 24 | - Customize the map blip (name, sprite, color, size) 25 | - Set any text to display on-screen via ox_lib's showTextUI 26 | - Set the color & position for the textUI 27 | - Customize the greenzone size (1-100) 28 | - Enable/disable players from firing weapons/punching/etc within zone 29 | - Enable/disable invincibility for everyone while within zone 30 | - Set a custom speed limit for the zone if desired 31 | - Clear the zone anytime with the /clearzone command 32 | 33 | ## Dependencies 34 | - [ox_lib](https://github.com/overextended/ox_lib/releases) 35 | 36 | ## Installation 37 | - Ensure you have all dependencies installed 38 | - Add lation_greenzones to your 'resources' directory 39 | - Add 'ensure lation_greenzones' in your 'server.cgf' 40 | 41 | ## Preview 42 | [Streamable - Lation's Greenzones](https://streamable.com/nat0ce) 43 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | 3 | Config.EnableNotifications = false -- Do you want notifications when a player enters and exits the preconfigured greenzones (The Config.GreenZones)? 4 | Config.GreenzonesCommand = 'setzone' -- The command to run in-game to start creating a temporary greenzone 5 | Config.GreenzonesClearCommand = 'clearzone' -- The command to run in-game to clear an existing temporary greenzone 6 | 7 | Config.GreenZones = { -- These are persistent greenzones that exist constantly, at all times - you can create as many as you want here 8 | ['hospital'] = { 9 | coords = vec3(299.2270, -584.6892, 43.2608), -- The center-most location of the greenzone 10 | radius = 100.0, -- The radius (how large or small) the greenzone is (note: this must include the .0 on the end of the number to work) 11 | disablePlayerVehicleCollision = false, -- Do you want to disable players & their vehicles collisions between each other? (true if yes, false if no) 12 | enableSpeedLimits = true, -- Do you want to enforce a speed limit in this zone? (true if yes, false if no) 13 | setSpeedLimit = 30, -- The speed limit (in MPH) that will be enforced in this zone if enableSpeedLimits is true 14 | removeWeapons = true, -- Do you want to remove weapons completely from players hands while in this zone? (true if yes, false if no) 15 | disableFiring = true, -- Do you want to disable everyone from firing weapons/punching/etc in this zone? (true if yes, false if no) 16 | setInvincible = true, -- Do you want everyone to be invincible in this zone? (true if yes, false if no) 17 | displayTextUI = true, -- Do you want textUI to display on everyones screen while in this zone? (true if yes, false if no) 18 | textToDisplay = 'Hospital Green Zone', -- The text to display on everyones screen if displayTextUI is true for this zone 19 | backgroundColorTextUI = '#ff5a47', -- The color of the textUI background to display if displayTextUI is true for this zone 20 | textColor = '#000000', -- The color of the text & icon itself on the textUI if displayTextUI is true for this zone 21 | displayTextPosition = 'top-center', -- The position of the textUI if displayTextUI is true for this zone 22 | displayTextIcon = 'hospital', -- The icon to be displayed on the TextUI in this zone if displayTextUI is true 23 | blip = true, -- Do you want a blip to display on the map here? True for yes, false for no 24 | blipType = 'radius', -- Type can be 'radius' or 'normal' 25 | enableSprite = false, -- Do you want a sprite at the center of the radius blip? (If blipType = 'normal', this don't matter, it will display a sprite) 26 | blipSprite = 621, -- Blip sprite (https://docs.fivem.net/docs/game-references/blips/) (only used if enableSprite = true, otherwise can be ignored) 27 | blipColor = 2, -- Blip color (https://docs.fivem.net/docs/game-references/blips/#blip-colors) 28 | blipScale = 0.7, -- Blip size (0.01 to 1.0) (only used if enableSprite = true, otherwise can be ignored) 29 | blipAlpha = 100, -- The transparency of the radius blip if blipType = 'radius', otherwise not used/can be ignored 30 | blipName = 'Hospital Greenzone' -- Blip name on the map (if enableSprite = true, otherwise can be ignored) 31 | }, 32 | ['policestation'] = { 33 | coords = vec3(432.7403, -982.1954, 30.7105), 34 | radius = 100.0, 35 | disablePlayerVehicleCollision = false, 36 | enableSpeedLimits = true, 37 | setSpeedLimit = 40, 38 | removeWeapons = false, 39 | disableFiring = true, 40 | setInvincible = false, 41 | displayTextUI = true, 42 | textToDisplay = 'Police Green Zone', 43 | backgroundColorTextUI = '#ff5a47', 44 | textColor = '#000000', 45 | displayTextPosition = 'top-center', 46 | displayTextIcon = 'shield-halved', 47 | blip = true, 48 | blipType = 'radius', 49 | enableSprite = false, 50 | blipSprite = 621, 51 | blipColor = 2, 52 | blipScale = 0.7, 53 | blipAlpha = 100, 54 | blipName = 'LSPD Greenzone' 55 | }, 56 | ['examplelocation3'] = { 57 | coords = vec3(-1243.6606, 1348.0383, 212.7915), 58 | radius = 200.0, 59 | disablePlayerVehicleCollision = false, 60 | enableSpeedLimits = false, 61 | setSpeedLimit = 40, 62 | removeWeapons = true, 63 | disableFiring = false, 64 | setInvincible = true, 65 | displayTextUI = true, 66 | textToDisplay = 'Random Green Zone', 67 | backgroundColorTextUI = '#ff5a47', 68 | textColor = '#000000', 69 | displayTextPosition = 'top-center', 70 | displayTextIcon = 'box', 71 | blip = true, 72 | blipType = 'radius', 73 | enableSprite = false, 74 | blipSprite = 621, 75 | blipColor = 2, 76 | blipScale = 0.8, 77 | blipAlpha = 100, 78 | blipName = 'Another Greenzone' 79 | } 80 | -- Create more zones here by following the same format as above 81 | } 82 | 83 | Notifications = { 84 | position = 'top', -- The position for all notifications 85 | greenzoneTitle = locale('notify.greenzoneTitle'), -- Title when entering a greenzone 86 | greenzoneIcon = 'border-all', -- The icon displayed on the notifications 87 | greenzoneEnter = locale('notify.greenzoneEnter'), -- Description when entering a greenzone 88 | greenzoneExit = locale('notify.greenzoneExit'), -- Description when exiting a greenzone 89 | } -------------------------------------------------------------------------------- /client/main.lua: -------------------------------------------------------------------------------- 1 | local greenZone = nil 2 | local vehiclesInZone = nil 3 | local adminZoneMenu = nil 4 | local zone = lib.points.new(vec3(0, 0, 0), 0) 5 | local pedCoords = nil 6 | local radiusBlip = nil 7 | local sprite = nil 8 | local vehicle = nil 9 | local speed = 0 10 | 11 | -- Default greenzones configured beforehand in the config 12 | for k, v in pairs(Config.GreenZones) do 13 | greenZone = lib.points.new(v.coords, v.radius) 14 | function greenZone:onEnter() 15 | if v.disablePlayerVehicleCollision then 16 | for _, player in pairs(GetActivePlayers()) do 17 | if player ~= cache.ped then 18 | local ped = cache.ped 19 | local ped2 = GetPlayerPed(player) 20 | local veh = GetVehiclePedIsIn(ped, false) 21 | local veh2 = GetVehiclePedIsIn(ped2, false) 22 | SetEntityAlpha(ped2, 153, false) 23 | if veh ~= 0 then 24 | SetEntityAlpha(veh, 153, false) 25 | end 26 | if veh2 ~= 0 then 27 | SetEntityAlpha(veh2, 153, false) 28 | end 29 | end 30 | end 31 | end 32 | if v.removeWeapons then 33 | local currentWeapon = GetSelectedPedWeapon(cache.ped) 34 | RemoveWeaponFromPed(cache.ped, currentWeapon) 35 | end 36 | if v.disableFiring then 37 | SetPlayerCanDoDriveBy(cache.ped, false) 38 | end 39 | if v.setInvincible then 40 | SetEntityInvincible(cache.ped, true) 41 | end 42 | if v.enableSpeedLimits then 43 | vehicle = GetVehiclePedIsIn(cache.ped, false) 44 | speed = v.setSpeedLimit * 0.44 45 | end 46 | if v.displayTextUI then 47 | lib.showTextUI(v.textToDisplay, { 48 | position = v.displayTextPosition, 49 | icon = v.displayTextIcon, 50 | style = { 51 | borderRadius = 4, 52 | backgroundColor = v.backgroundColorTextUI, 53 | color = v.textColor 54 | } 55 | }) 56 | end 57 | if Config.EnableNotifications then 58 | lib.notify({ 59 | title = Notifications.greenzoneTitle, 60 | description = Notifications.greenzoneEnter, 61 | type = 'success', 62 | position = Notifications.position, 63 | duration = 6000, 64 | style = { 65 | backgroundColor = '#ff5a47', 66 | color = '#2C2C2C', 67 | ['.description'] = { 68 | color = '#2C2C2C', 69 | } 70 | }, 71 | icon = Notifications.greenzoneIcon, 72 | iconColor = '#2C2C2C' 73 | }) 74 | end 75 | end 76 | function greenZone:onExit() 77 | if v.disablePlayerVehicleCollision then 78 | for _, player in pairs(GetActivePlayers()) do 79 | if player ~= cache.ped then 80 | local ped = cache.ped 81 | local ped2 = GetPlayerPed(player) 82 | local veh = GetVehiclePedIsIn(ped, false) 83 | local veh2 = GetVehiclePedIsIn(ped2, false) 84 | SetEntityAlpha(ped2, 255, false) 85 | if veh ~= 0 then 86 | SetEntityAlpha(veh, 255, false) 87 | end 88 | if veh2 ~= 0 then 89 | SetEntityAlpha(veh2, 255, false) 90 | end 91 | end 92 | end 93 | end 94 | if v.disableFiring then 95 | SetPlayerCanDoDriveBy(cache.ped, true) 96 | end 97 | if v.setInvincible then 98 | SetEntityInvincible(cache.ped, false) 99 | end 100 | if v.enableSpeedLimits then 101 | vehicle = GetVehiclePedIsIn(cache.ped, false) 102 | SetVehicleMaxSpeed(vehicle, 0.0) 103 | end 104 | if v.displayTextUI then 105 | lib.hideTextUI() 106 | end 107 | if Config.EnableNotifications then 108 | lib.notify({ 109 | title = Notifications.greenzoneTitle, 110 | description = Notifications.greenzoneExit, 111 | type = 'error', 112 | position = Notifications.position, 113 | style = { 114 | backgroundColor = '#72E68F', 115 | color = '#2C2C2C', 116 | ['.description'] = { 117 | color = '#2C2C2C', 118 | } 119 | }, 120 | icon = Notifications.greenzoneIcon, 121 | iconColor = '#2C2C2C' 122 | }) 123 | end 124 | end 125 | function greenZone:nearby() 126 | if v.disablePlayerVehicleCollision then 127 | for _, player in pairs(GetActivePlayers()) do 128 | if player ~= PlayerId() then 129 | local ped = PlayerPedId() 130 | local ped2 = GetPlayerPed(player) 131 | local veh = GetVehiclePedIsIn(ped, false) 132 | local veh2 = GetVehiclePedIsIn(ped2, false) 133 | SetEntityAlpha(ped2, 153, false) 134 | if veh2 ~= 0 then 135 | if veh ~= 0 then 136 | SetEntityAlpha(veh, 153, false) 137 | SetEntityNoCollisionEntity(veh, veh2, true) 138 | SetEntityNoCollisionEntity(veh2, veh, true) 139 | end 140 | SetEntityAlpha(veh2, 153, false) 141 | SetEntityNoCollisionEntity(ped, veh2, true) 142 | SetEntityNoCollisionEntity(veh2, ped, true) 143 | else 144 | SetEntityNoCollisionEntity(ped, ped2, true) 145 | SetEntityNoCollisionEntity(ped2, ped, true) 146 | end 147 | end 148 | end 149 | end 150 | if v.disableFiring then 151 | DisablePlayerFiring(cache.ped, true) 152 | end 153 | if v.enableSpeedLimits then 154 | vehicle = GetVehiclePedIsIn(cache.ped, false) -- This isn't 100% needed, could be commented out if performance is impacted too much. Only difference would be if player spawns into this zone, they can drive at any speed until exit/re-enter 155 | SetVehicleMaxSpeed(vehicle, speed) 156 | end 157 | end 158 | end 159 | 160 | -- Blip creation for the default persistent greenzones configured beforehand 161 | for k, v in pairs(Config.GreenZones) do 162 | if v.blip then 163 | if v.blipType == 'radius' then 164 | local blip = AddBlipForRadius(v.coords.x, v.coords.y, v.coords.z, v.radius) 165 | SetBlipColour(blip, v.blipColor) 166 | SetBlipAlpha(blip, v.blipAlpha) 167 | if v.enableSprite then 168 | local blip2 = AddBlipForCoord(v.coords.x, v.coords.y, v.coords.z) 169 | SetBlipSprite(blip2, v.blipSprite) 170 | SetBlipColour(blip2, v.blipColor) 171 | SetBlipScale(blip2, v.blipScale) 172 | SetBlipAsShortRange(blip2, true) 173 | BeginTextCommandSetBlipName("STRING") 174 | AddTextComponentString(v.blipName) 175 | EndTextCommandSetBlipName(blip2) 176 | end 177 | else 178 | local blip = AddBlipForCoord(v.coords.x, v.coords.y, v.coords.z) 179 | SetBlipSprite(blip, v.blipSprite) 180 | SetBlipColour(blip, v.blipColor) 181 | SetBlipScale(blip, v.blipScale) 182 | SetBlipAsShortRange(blip, true) 183 | BeginTextCommandSetBlipName("STRING") 184 | AddTextComponentString(v.blipName) 185 | EndTextCommandSetBlipName(blip) 186 | end 187 | end 188 | end 189 | 190 | -- Start of events for creating Greenzones in-game, this is the menu that takes data, passes it to server 191 | lib.callback.register('lation_greenzones:adminZone', function() 192 | pedCoords = GetEntityCoords(cache.ped) 193 | adminZoneMenu = lib.inputDialog(locale('menu.title'), { 194 | {type = 'input', label = locale('menu.blipName'), description = locale('menu.blipNameDescription'), placeholder = locale('menu.blipNamePlaceholder'), icon = 'quote-left', required = true, min = 4, max = 16}, 195 | {type = 'input', label = locale('menu.displayText'), description = locale('menu.displayTextDescription'), placeholder = locale('menu.displayTextPlaceholder'), icon = 'comment', required = true}, 196 | {type = 'color', label = locale('menu.displayTextColor'), description = locale('menu.displayTextColorDescription'), default = '#ff5a47', icon = 'palette', required = true}, 197 | {type = 'select', label = locale('menu.displayTextPosition'), description = locale('menu.displayTextPositionDescription'), options = { 198 | { value = 'right-center', label = locale('menu.positionRightCenter') }, 199 | { value = 'left-center', label = locale('menu.positionLeftCenter') }, 200 | { value = 'top-center', label = locale('menu.positionTopCenter') } 201 | }, default = 'top-center', clearable = false, required = true}, 202 | {type = 'slider', label = locale('menu.size'), icon = 'sliders', required = true, default = 10, min = 1, max = 100, step = 1}, 203 | {type = 'checkbox', label = locale('menu.disableFiring'), checked = false}, 204 | {type = 'checkbox', label = locale('menu.invincible'), checked = false}, 205 | {type = 'slider', label = locale('menu.speedLimit'), icon = 'sliders', required = false, default = 0, min = 0, max = 100, step = 10}, 206 | {type = 'number', label = locale('menu.blipID'), description = locale('menu.blipIDDescription'), icon = 'map-pin', default = 487, required = true}, 207 | {type = 'number', label = locale('menu.blipColor'), description = locale('menu.blipColorDescription'), icon = 'palette', default = 1, required = true} 208 | }) 209 | if adminZoneMenu == nil then 210 | return 211 | else 212 | zoneName = adminZoneMenu[1] 213 | textUI = adminZoneMenu[2] 214 | textUIColor = adminZoneMenu[3] 215 | textUIPosition = adminZoneMenu[4] 216 | zoneSize = adminZoneMenu[5] 217 | disarm = adminZoneMenu[6] 218 | invincible = adminZoneMenu[7] 219 | speedLimit = adminZoneMenu[8] 220 | blipID = adminZoneMenu[9] 221 | blipColor = adminZoneMenu[10] 222 | lib.callback('lation_greenzones:data', false, cb, pedCoords, zoneName, textUI, textUIColor, textUIPosition, zoneSize, disarm, invincible, speedLimit, blipID, blipColor) 223 | end 224 | end) 225 | 226 | -- The function that creates a temporary greenzone via in-game command for all clients from the data passed 227 | RegisterNetEvent('lation_greenzones:createAdminZone') 228 | AddEventHandler('lation_greenzones:createAdminZone', function(zoneCoords, zoneName, textUI, textUIColor, textUIPosition, zoneSize, disarm, invincible, speedLimit, blipID, blipColor) 229 | vehicle = GetVehiclePedIsIn(cache.ped, false) 230 | zone:remove() -- Removes any existing zones 231 | RemoveBlip(radiusBlip) -- Removes any exisitng radius blips 232 | RemoveBlip(sprite) -- Removes any existing blip sprites 233 | lib.hideTextUI() -- Hides any existing textUI's 234 | SetVehicleMaxSpeed(vehicle, 0.0) -- Ensures no vehicle speed limits are enforced 235 | SetEntityInvincible(cache.ped, false) -- Ensures no one is still invincible anywhere 236 | createBlip(zoneName, zoneCoords, zoneSize, blipID, blipColor) -- Creates the new blip 237 | zone = lib.points.new(zoneCoords, zoneSize) -- Creates a new point 238 | speed = speedLimit * 0.44 -- Converts to MPH (probably not 100% accurate but works enough lul) 239 | function zone:onEnter() 240 | vehicle = GetVehiclePedIsIn(cache.ped, false) 241 | lib.showTextUI(textUI, { 242 | position = textUIPosition, 243 | icon = 'shield-halved', 244 | style = { 245 | borderRadius = 4, 246 | backgroundColor = textUIColor, 247 | color = 'black' 248 | } 249 | }) 250 | if invincible then 251 | SetEntityInvincible(cache.ped, true) 252 | end 253 | end 254 | function zone:onExit() 255 | lib.hideTextUI() 256 | if invincible then 257 | SetEntityInvincible(cache.ped, false) 258 | end 259 | SetVehicleMaxSpeed(vehicle, 0.0) 260 | end 261 | function zone:nearby() 262 | if disarm then 263 | DisablePlayerFiring(cache.ped, true) 264 | end 265 | if speedLimit ~= 0 then 266 | vehicle = GetVehiclePedIsIn(cache.ped, false) 267 | SetVehicleMaxSpeed(vehicle, speed) 268 | end 269 | end 270 | end) 271 | 272 | -- The function that creates blips for Greenzones created in-game 273 | function createBlip(blipName, blipCoords, blipRadius, blipID, blipColor) 274 | local radius = lib.math.round(blipRadius, 1) 275 | radiusBlip = AddBlipForRadius(blipCoords, radius) 276 | SetBlipColour(radiusBlip, blipColor) 277 | SetBlipAlpha(radiusBlip, 100) 278 | sprite = AddBlipForCoord(blipCoords) 279 | SetBlipSprite(sprite, blipID) 280 | SetBlipDisplay(sprite, 4) 281 | SetBlipColour(sprite, blipColor) 282 | SetBlipScale(sprite, 1.0) 283 | SetBlipAsShortRange(sprite, true) 284 | BeginTextCommandSetBlipName("STRING") 285 | AddTextComponentString(blipName) 286 | EndTextCommandSetBlipName(sprite) 287 | end 288 | 289 | -- The actual removal of all tempoary greenzone related things 290 | function deleteZone() 291 | vehicle = GetVehiclePedIsIn(cache.ped, false) 292 | zone:remove() 293 | RemoveBlip(radiusBlip) 294 | RemoveBlip(sprite) 295 | lib.hideTextUI() 296 | SetVehicleMaxSpeed(vehicle, 0.0) 297 | SetEntityInvincible(cache.ped, false) 298 | end 299 | 300 | -- The confirmation for deleting an active temporary greenzone 301 | lib.callback.register('lation_greenzones:adminZoneClear', function() 302 | local confirm = lib.alertDialog({ 303 | header = locale('confirm.title'), 304 | content = locale('confirm.content'), 305 | centered = true, 306 | cancel = true 307 | }) 308 | if confirm == 'confirm' then 309 | lib.callback('lation_greenzones:deleteZone') 310 | else 311 | return 312 | end 313 | end) 314 | 315 | -- The event that gets triggered for all clients when deleting a temporary greenzone 316 | RegisterNetEvent('lation_greenzones:deleteAdminZone') 317 | AddEventHandler('lation_greenzones:deleteAdminZone', function() 318 | deleteZone() 319 | end) --------------------------------------------------------------------------------