@Fledr I am still a beginner but as they said it is missing ,to define newX newY newZ
I have an example but I am not good enough to succeed , to make it correctly
newX = x + math.random(-100, 100)
newY = y + math.random(-100 , 100)
_,newZ = GetGroundZFor_3dCoord(newX+.0,newY+.0,z+999.0, 1)
for _, player in pairs(players) do
Wait(1)
playerX, playerY = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
if newX > playerX - 60 and newX < playerX + 60 or newY > playerY - 60 and newY < playerY + 60 then
break
else
canSpawn = true
end
end
until canSpawn
to put some part here , but how… good question …???
local peds = {}
local pedWeps = {
"WEAPON_BAT",
"WEAPON_CROWBAR"
}
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
ped = CreatePed(4, 0xAC4B4506, newX, newY, z - 500, 0.0, true, true)
SetPedArmour(ped, 100)
SetPedAccuracy(ped, 25)
SetPedSeeingRange(ped, 1000000.0)
SetPedHearingRange(ped, 1000000.0)
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 16, 1)
SetPedCombatAttributes(ped, 46, 1)
SetAmbientVoiceName(ped, "ALIENS")
SetPedEnableWeaponBlocking(ped, true)
SetPedRelationshipGroupHash(ped, GetHashKey("zombeez"))
DisablePedPainAudio(ped, true)
SetPedDiesInWater(ped, false)
SetPedDiesWhenInjured(ped, false)
SetPedIsDrunk(ped, true)
RequestAnimSet("move_m@drunk@verydrunk")
while not HasAnimSetLoaded("move_m@drunk@verydrunk") do
Wait(1)
end
SetPedMovementClipset(ped, "move_m@drunk@verydrunk", 1.0)
--TaskCombatPed(ped, GetPlayerPed(-1), 0, 16)
x, y, z = table.unpack(GetEntityCoords(ped, true))
TaskWanderStandard(ped, 1.0, 10)
chance = math.random(150)
if chance == 50 then
randomWep = math.random(1, #pedWeps)
GiveWeaponToPed(ped, GetHashKey(pedWeps[randomWep]), 9999, true, true)
Citizen.Trace("Spawned zombie with weapon " .. pedWeps[randomWep] .. "\n")
else
Citizen.Trace("Spawned zombie with no weapon\n")
end
table.insert(peds, ped)
end
for i, ped in pairs(peds) do
if not DoesEntityExist(ped) then
table.remove(peds, i)
TriggerEvent('"Z:playerUpdate"')
isInArea = true
elseif (Vdist2(area.x, area.y, area.z, pedX, pedY, pedZ) > area.radius and isInArea == true) then
--stop zombies
Citizen.InvokeNative(0xB736A491E64A32CF, Citizen.PointerValueIntInitialized(ped))
table.remove(peds, i)
else
playerX, playerY = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
pedX, pedY = table.unpack(GetEntityCoords(ped, true))
if pedX < playerX - 400 or pedX > playerX + 400 or pedY < playerY - 400 or pedY > playerY + 400 then
-- Set ped as no longer needed for despawning
Citizen.InvokeNative(0xB736A491E64A32CF, Citizen.PointerValueIntInitialized(ped))
table.remove(peds, i)
TriggerEvent('Z:cleanup')
isInArea = false
end
end
end
end
end)
maybe in 10 years we will have the answer, knowing fivem for beginners it’s not their cup of tea,
if I can give you a piece of advice give up. I lost 2 days for nothing …
shame, the idea was good , well done to @SuisseGames