Hi bro,
I have a Spanish server of zombies and I have also installed the CorruptSnail, what I need is that when a player is in a safe area, the zombies that enter die instantly or disappear. Here I leave the whole code of the zombiespawner of CorruptSnail
-- CODE --
players = {}
RegisterNetEvent("Z:playerUpdate")
AddEventHandler("Z:playerUpdate", function(mPlayers)
players = mPlayers
end)
peds = {}
Citizen.CreateThread(function()
AddRelationshipGroup("zombeez")
SetRelationshipBetweenGroups(5, GetHashKey("zombeez"), GetHashKey("PLAYER"))
SetRelationshipBetweenGroups(5, GetHashKey("zombeez"), GetHashKey("bandit"))
SetRelationshipBetweenGroups(5, GetHashKey("PLAYER"), GetHashKey("zombeez"))
SetAiMeleeWeaponDamageModifier(2.0)
while true do
Wait(1)
if #peds < 15 then
x, y, z = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
choosenPed = pedModels[math.random(1, #pedModels)]
choosenPed = string.upper(choosenPed)
RequestModel(GetHashKey(choosenPed))
while not HasModelLoaded(GetHashKey(choosenPed)) or not HasCollisionForModelLoaded(GetHashKey(choosenPed)) do
Wait(1)
end
local newX = x
local newY = y
local newZ = z + 999.0
repeat
Wait(1)
newX = x + math.random(-50, 50)
newY = y + math.random(-50 , 50)
_,newZ = GetGroundZFor_3dCoord(newX+.0,newY+.0,z, 1)
for _, player in pairs(players) do
Wait(1)
playerX, playerY = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
if newX > playerX - 35 and newX < playerX + 35 or newY > playerY - 35 and newY < playerY + 35 then
canSpawn = false
break
else
canSpawn = true
end
end
until canSpawn
ped = CreatePed(4, GetHashKey(choosenPed), newX, newY, newZ, 0.0, true, true)
SetPedArmour(ped, 100)
SetPedAccuracy(ped, 25)
SetPedSeeingRange(ped, 100.0)
SetPedHearingRange(ped, 80.0)
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 16, 1)
SetPedCombatAttributes(ped, 17, 0)
SetPedCombatAttributes(ped, 46, 1)
SetPedCombatAttributes(ped, 1424, 0)
SetPedCombatAttributes(ped, 5, 1)
SetPedCombatRange(ped,2)
SetPedAlertness(ped,3)
SetAmbientVoiceName(ped, "ALIENS")
SetPedEnableWeaponBlocking(ped, true)
SetPedRelationshipGroupHash(ped, GetHashKey("zombeez"))
DisablePedPainAudio(ped, true)
SetPedDiesInWater(ped, false)
SetPedDiesWhenInjured(ped, false)
-- PlaceObjectOnGroundProperly(ped)
SetPedDiesInstantlyInWater(ped,true)
SetPedIsDrunk(ped, true)
SetPedConfigFlag(ped,100,1)
RequestAnimSet("move_m@drunk@verydrunk")
while not HasAnimSetLoaded("move_m@drunk@verydrunk") do
Wait(1)
end
SetPedMovementClipset(ped, "move_m@drunk@verydrunk", 1.0)
ApplyPedDamagePack(ped,"BigHitByVehicle", 0.0, 9.0)
ApplyPedDamagePack(ped,"SCR_Dumpster", 0.0, 9.0)
ApplyPedDamagePack(ped,"SCR_Torture", 0.0, 9.0)
StopPedSpeaking(ped,true)
TaskWanderStandard(ped, 1.0, 10)
local pspeed = math.random(20,70)
local pspeed = pspeed/10
local pspeed = pspeed+0.01
SetEntityMaxSpeed(ped, 5.0)
if not NetworkGetEntityIsNetworked(ped) then
NetworkRegisterEntityAsNetworked(ped)
end
table.insert(peds, ped)
end
for i, ped in pairs(peds) do
if DoesEntityExist(ped) == false then
table.remove(peds, i)
end
pedX, pedY, pedZ = table.unpack(GetEntityCoords(ped, true))
if IsPedDeadOrDying(ped, 1) == 1 then
-- Set ped as no longer needed for despawning
local dropChance = math.random(0,100)
if GetPedSourceOfDeath(ped) == PlayerPedId() then
if dropChance >= 95 then
ForceCreateFoodPickupAtCoord(pedX,pedY,pedZ)
end
zombiekillsthislife = zombiekillsthislife+1
zombiekills = zombiekills+1
end
Citizen.InvokeNative(0xB736A491E64A32CF, Citizen.PointerValueIntInitialized(ped))
table.remove(peds, i)
else
playerX, playerY = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
SetPedArmour(ped, 100)
SetPedAccuracy(ped, 25)
SetPedSeeingRange(ped, 300.0)
SetPedHearingRange(ped, 300.0)
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 16, 1)
SetPedCombatAttributes(ped, 17, 0)
SetPedCombatAttributes(ped, 46, 1)
SetPedCombatAttributes(ped, 1424, 0)
SetPedCombatAttributes(ped, 5, 1)
SetPedCombatRange(ped,2)
SetAmbientVoiceName(ped, "ALIENS")
SetPedEnableWeaponBlocking(ped, true)
SetPedRelationshipGroupHash(ped, GetHashKey("zombeez"))
DisablePedPainAudio(ped, true)
SetPedDiesInWater(ped, false)
SetPedDiesWhenInjured(ped, false)
if pedX < playerX - 70 or pedX > playerX + 70 or pedY < playerY - 70 or pedY > playerY + 70 then
-- Set ped as no longer needed for despawning
local model = GetEntityModel(ped)
SetEntityAsNoLongerNeeded(ped)
SetModelAsNoLongerNeeded(model)
table.remove(peds, i)
end
end
end
end
end)
RegisterNetEvent("Z:cleanup")
AddEventHandler("Z:cleanup", function()
for i, ped in pairs(peds) do
-- Set ped as no longer needed for despawning
local model = GetEntityModel(ped)
SetEntityAsNoLongerNeeded(ped)
SetModelAsNoLongerNeeded(model)
table.remove(peds, i)
end
end)