How to set delete Ped come in area this script

zombiespawner.lua (11.2 KB)

please help me.
i want to set multi location area. Thank you.

i have …

local isInArea = false
local area = { x = 1.0, y = 1.0, z = 1.0, radius = 10.0 }

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)

local playerPed = GetPlayerPed(-1)
local pedX, pedY, pedZ = table.unpack(GetEntityCoords(playerPed, true))

if (Vdist2(area.x, area.y, area.z, pedX, pedY, pedZ) <= area.radius and isInArea == false) then
	--spawn zombies
    TriggerEvent('yourevent')
	isInArea = true
elseif  (Vdist2(area.x, area.y, area.z, pedX, pedY, pedZ) > area.radius and isInArea == true) then 
	--stop zombies
	TriggerEvent('yourotherevent')
	isInArea = false
end

end
end)

set it in a for loop

you can show me?

Just something like this… am on my phone so it might not be good but test

local isInArea = false
local area = { x = 1.0, y = 1.0, z = 1.0, radius = 10.0 }

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)

local playerPed = GetPlayerPed(-1)
local pedX, pedY, pedZ = table.unpack(GetEntityCoords(playerPed, true))

for i=1, #area, 1 do
area = area[i]
if (Vdist2(area.x, area.y, area.z, pedX, pedY, pedZ) <= area.radius and isInArea == false) then
	--spawn zombies
    TriggerEvent('yourevent')
	isInArea = true
elseif  (Vdist2(area.x, area.y, area.z, pedX, pedY, pedZ) > area.radius and isInArea == true) then 
	--stop zombies
	TriggerEvent('yourotherevent')
	isInArea = false
end
end

end
end)

Thank you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.