I edited this a bit more and have been running it on my development server. There are a few things you should implement if you have no already done so just to make sure and rule these out.
1.) server.cfg file: Make sure you have pNotify starting before zone.
start pNotify
start zone
2.) __resource.lua file: set dependency to pNotify
resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'
dependency "pNotify"
client_script "client.lua"
3.) I moved your local player = GetPlayerPed(-1) to inside your looping thread. The id can change over time and if it’s only being collected once at the first run time then it can stop working once this happens. I also removed friendly fire, this shouldn’t be needed. I moved your god mode up inside of the statements so they only get set once when the notification is going to pNotify.
local inzone = 0
local notifIn = false
local notifOut = false
Citizen.CreateThread(function()
while not NetworkIsPlayerActive(PlayerId()) do
Citizen.Wait(0)
end
while true do
Citizen.Wait(0)
local player = GetPlayerPed(-1)
local x,y,z = table.unpack(GetEntityCoords(player, true))
local dist = GetDistanceBetweenCoords(x,y,z,1847.916015625,3675.8190917968,33.767009735108,true)
if dist <= 50.0 then
if not notifIn then
SetEntityInvincible(player,true)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>You are in a SafeZone</b>",
type = "success",
timeout = (3000),
layout = "bottomcenter",
queue = "global"
})
notifIn = true
notifOut = false
end
else
if not notifOut then
SetEntityInvincible(player,false)
TriggerEvent("pNotify:SendNotification",{
text = "<b style='color:#1E90FF'>You are in NO LONGER a SafeZone</b>",
type = "error",
timeout = (3000),
layout = "bottomcenter",
queue = "global"
})
notifOut = true
notifIn = false
end
end
end
end)