local Core, CoreName = nil, nil local Opened = false local isInSafeZone = {} local value = 2.236936 if Config.LimitSpeed.type == "mph" then value = 2.236936 else value = 3.6 end if GetResourceState('qb-core') == 'started' then Core = exports['qb-core']:GetCoreObject() while Core == nil do TriggerEvent('QBCore:GetObject', function(obj) Core = obj end) Wait(30) end CoreName = 'qb-core' elseif GetResourceState('es_extended') == 'started' then Core = exports["es_extended"]:getSharedObject() while Core == nil do TriggerEvent('esx:getSharedObject', function(obj) Core = obj end) Wait(30) end CoreName = 'es_extended' else Core = 'not_found' CoreName = 'standlone' end -- Thread's CreateThread(function() if CoreName == 'qb-core' then RegisterNetEvent('QBCore:Client:OnPlayerLoaded') AddEventHandler('QBCore:Client:OnPlayerLoaded', function() TriggerEvent("Jakrino:Client:UpdateSafezone") end) elseif CoreName == 'es_extended' then RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function() TriggerEvent("Jakrino:Client:UpdateSafezone") end) elseif CoreName == 'standlone' then while true do Wait(1000) if NetworkIsSessionStarted() then TriggerEvent("Jakrino:Client:UpdateSafezone") break end end end end) -- Function's local function Interact(bool) if Config.UseUI then if bool then if not Opened then Opened = true SendNUIMessage({type = "open"}) end else if Opened then Opened = false SendNUIMessage({type = "close"}) end end end end local function While(playerCoords, area) local isInAnySafeZone = false for _, v in pairs(isInSafeZone) do if v then isInAnySafeZone = true break end end local playerPed = PlayerPedId() local playerId = PlayerId() CreateThread(function() Interact(isInAnySafeZone) end) if isInAnySafeZone then if Config.DisableDriveBy then SetPlayerCanDoDriveBy(playerId, false) end if Config.DisableVdm then local vehList = GetGamePool('CVehicle') for _, vehicle in ipairs(vehList) do local vehCoords = GetEntityCoords(vehicle) local distance = #(playerCoords - vehCoords) if distance < area.radius then SetEntityNoCollisionEntity(vehicle, playerPed, true) end end end if Config.LimitSpeed.enabled then local limit = Config.LimitSpeed.limit / value SetEntityMaxSpeed(GetVehiclePedIsIn(playerPed, false), limit) end if Config.DisableWeapons then DisablePlayerFiring(playerId) NetworkSetFriendlyFireOption(false) SetCurrentPedWeapon(playerPed, GetHashKey("WEAPON_UNARMED"), true) end if Config.DisableDamage then SetEntityInvincible(playerPed, true) end else if Config.DisableDriveBy then SetPlayerCanDoDriveBy(playerId, true) end if Config.LimitSpeed.enabled then SetEntityMaxSpeed(GetVehiclePedIsIn(playerPed, false), 1000.0) end if Config.DisableWeapons then NetworkSetFriendlyFireOption(true) end if Config.DisableDamage then SetEntityInvincible(playerPed, false) end end end local function IsInsideArea(coords, area) local distance = GetDistanceBetweenCoords(coords, area.coords.x, area.coords.y, area.coords.z, true) return distance <= area.radius end local function Start() local sleep = 1000 while true do if Opened then sleep = 0 else sleep = 1000 end Wait(sleep) local playerPed = PlayerPedId() local playerCoords = GetEntityCoords(playerPed) for index, area in pairs(Config.Areas) do if IsInsideArea(playerCoords, area) then isInSafeZone[index] = true While(playerCoords, area) else isInSafeZone[index] = false While(playerCoords, area) end end end end local function AddBlip() for index, area in pairs(Config.Areas) do if area.blipEnabled then local blip = AddBlipForRadius(area.coords.x, area.coords.y, area.coords.z, area.radius) SetBlipHighDetail(blip, true) SetBlipColour(blip, 2) SetBlipAlpha(blip, 128) end end end -- For Devs.. RegisterNetEvent("onResourceStart") AddEventHandler("onResourceStart", function(resourceName) if (GetCurrentResourceName() == resourceName) then while true do if GetResourceState(GetCurrentResourceName()) == 'started' then TriggerEvent("Jakrino:Client:UpdateSafezone") break; else Wait(100) end end end end) RegisterNetEvent("Jakrino:Client:UpdateSafezone") AddEventHandler("Jakrino:Client:UpdateSafezone", function() SendNUIMessage({ type = "update", locals = Locales[Config.Locales] }) AddBlip() Start() end)