[Release] JD_SafeZone

I get the same error

how u did it

notify = false

local function insidePolygon( point)
local oddNodes = false
for i = 1, #Config.Zones do
local Zone = Config.Zones[i]
local j = #Zone
for i = 1, #Zone do
if (Zone[i][2] < point.y and Zone[j][2] >= point.y or Zone[j][2] < point.y and Zone[i][2] >= point.y) then
if (Zone[i][1] + ( point[2] - Zone[i][2] ) / (Zone[j][2] - Zone[i][2]) * (Zone[j][1] - Zone[i][1]) < point.x) then
oddNodes = not oddNodes;
end
end
j = i;
end
end
return oddNodes
end

Citizen.CreateThread(function()
while true do
local iPed = GetPlayerPed(-1)
Citizen.Wait(0)
point = GetEntityCoords(iPed,true)
local inZone = insidePolygon(point)
if Config.ShowBorder then
drawPoly(inZone)
end
if inZone then
if Config.TopLeftInfoBox then
DisplayHelpText("~BLIP_INFO_ICON~ You are in a ~g~SafeZone")
end
NetworkSetFriendlyFireOption(false)
DisablePlayerFiring(iPed, true)
SetCurrentPedWeapon(_source,GetHashKey(“WEAPON_UNARMED”),true)
if IsPedInAnyVehicle(iPed, false) then
veh = GetVehiclePedIsUsing(iPed)
SetEntityCanBeDamaged(veh, false)
end
SetEntityInvincible(iPed, true)
SetPedCanRagdoll(iPed, false)
ClearPedBloodDamage(iPed)
ResetPedVisibleDamage(iPed)
ClearPedLastWeaponDamage(iPed)
for _, players in ipairs(GetActivePlayers()) do
if IsPedInAnyVehicle(GetPlayerPed(players), true) then
veh = GetVehiclePedIsUsing(GetPlayerPed(players))
SetEntityNoCollisionEntity(iPed, veh, true)
else

end
end
else
if Config.TopLeftInfoBox then
DisplayHelpText("~BLIP_INFO_ICON~ You are ~r~NOT ~w~in a ~g~SafeZone")
end
NetworkSetFriendlyFireOption(true)
SetEntityCanBeDamaged(iPed, true)
if IsPedInAnyVehicle(iPed, true) then
veh = GetVehiclePedIsUsing(iPed)
SetEntityCanBeDamaged(veh, true)
end
end
end
end)

function DisplayHelpText(text)
BeginTextCommandDisplayHelp(“STRING”)
AddTextComponentSubstringKeyboardDisplay(text)
EndTextCommandDisplayHelp(0, 0, 1, -1)
end

function drawPoly(isEntityZone)
local iPed = GetPlayerPed(-1)
for i = 1, #Config.Zones do
local Zone = Config.Zones[i]
local j = #Zone
for i = 1, #Zone do

        local zone = Zone[i]
        if i < #Zone then
            local p2 = Zone[i+1]
            _drawWall(zone, p2)
        end
    end

    if #Zone > 2 then
        local firstPoint = Zone[1]
        local lastPoint = Zone[#Zone]
        _drawWall(firstPoint, lastPoint)
    end
end

end

function _drawWall(p1, p2)
local bottomLeft = vector3(p1[1], p1[2], p1[3] - 1.5)
local topLeft = vector3(p1[1], p1[2], p1[3] + Config.BorderHight)
local bottomRight = vector3(p2[1], p2[2], p2[3] - 1.5)
local topRight = vector3(p2[1], p2[2], p2[3] + Config.BorderHight)

DrawPoly(bottomLeft,topLeft,bottomRight,0,255,0,48)
DrawPoly(topLeft,topRight,bottomRight,0,255,0,48)
DrawPoly(bottomRight,topRight,topLeft,0,255,0,48)
DrawPoly(bottomRight,topLeft,bottomLeft,0,255,0,48)

end

Replace the
Client.Lua

i want to make it so npc’s (zombies in my case) despawn or die instantly when entering the zone. I can not seem to work it out :S is there someone who can help me out?

Citizen.CreateThread(function()
while (true) do
ClearAreaOfPeds(470.00, -990.00, 25.00, 50.0, 1)
Citizen.Wait(0)
end
end)

Change the coords tho

Hi, my config looks way different than yours, and I cant see if I need the polyzones. I really tried to read the carefully, hope you can help me!

What version are you using?

The passenger seat of the car can use weapons
Trouble you to improve

how can i add emergency vehicles so they dont have to slow down in the safezone?

Is it possible that de poly starts in the air?
So i want a safezone on top of my tower, but not on the bottom…
Now it always starts on the entire thing.

Just wondering if it is possible to change the the height of the Safe Zone range. Some of the Safe Zones are around Police stations and Hospitals and when flying over the top of them in a plane or helicopter you come to a massive halt lol.

Or
Is there a way to add in vehicles classes that can over-ride the speedlimit.
For e.g.

Vehicle Classes
15 (Helicopters)
16 (Planes)
18 (Emergency)
19 (Military)

Great script though, very helpful
Cheers.

1 Like

TY for the script ! I have a little bug. When i m in the zonesafe, i can’t use my Radio whit F1. I have the sound of spaming a wrong key and i don’t have the radio menu. Same problem at Benny’s, when i m in the zone for custom the spaming sound begin and i have it meanwhile the custom. If someone have an idea, i 'll aprecied that :grinning:

Any one have the config for all the Police departments, medical cents and fire stations

@JokeDevil Thank you for pushing this update! 10/10 awesome script. Cheers.

1 Like

How I can add marker for the safezones? so that it shows on the map