help, i want zombies not chasing local player with the skin id = 293
--THIS CHECKS ALL ZOMBIES EVERY SECOND TO SEE IF THEY ARE IN SIGHT
function zombie_check ()
if (getElementData (getLocalPlayer (), "zombie") ~= true) and ( isPedDead ( getLocalPlayer () ) == false ) then
local zombies = getElementsByType ( "ped",getRootElement(),true )
local id = getElementModel (localPlayer)
local Px,Py,Pz = getElementPosition( getLocalPlayer () )
if isPedDucked ( getLocalPlayer ()) then
local Pz = Pz-1
end
for theKey,theZomb in ipairs(zombies) do
if (isElement(theZomb)) then
local Zx,Zy,Zz = getElementPosition( theZomb )
if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
if (getElementData (theZomb, "zombie") == true) then
if ( getElementData ( theZomb, "status" ) == "idle" ) then --CHECKS IF AN IDLE ZOMBIE IS IN SIGHT
local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false)
if (isclear == true) then
setElementData ( theZomb, "status", "chasing" )
setElementData ( theZomb, "target", getLocalPlayer() )
table.insert( myZombies, theZomb ) --ADDS ZOMBIE TO PLAYERS COLLECTION
table.remove( zombies, theKey)
zombieradiusalert (theZomb)
end
elseif (getElementData(theZomb,"status") == "chasing") and (getElementData(theZomb,"target") == nil) then --CHECKS IF AN AGGRESSIVE LOST ZOMBIE IS IN SIGHT
local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false)
if (isclear == true) then
setElementData ( theZomb, "target", getLocalPlayer() )
isthere = "no"
for k, ped in pairs( myZombies ) do
if ped == theZomb then
isthere = "yes"
end
end
if isthere == "no" then
table.insert( myZombies, theZomb ) --ADDS THE WAYWARD ZOMBIE TO THE PLAYERS COLLECTION
if id = 293 then
table.insert( myZombies, id )
end
table.remove( zombies, theKey)
end
end
elseif ( getElementData ( theZomb, "target" ) == getLocalPlayer() ) then --CHECKS IF AN ALREADY AGGRESSIVE ZOMBIE IS IN SIGHT
local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false)
if (isclear == false) then --IF YOUR ZOMBIE LOST YOU, MAKES IT REMEMBER YOUR LAST COORDS
setElementData ( theZomb, "target", nil )
triggerServerEvent ("onZombieLostPlayer", theZomb, oldPx, oldPy, oldPz)
end
end
end
end
end
end
--this second half is for checking peds and zombies
local nonzombies = getElementsByType ( "ped",getRootElement(),true )
local id = getElementModel (localPlayer)
for theKey,theZomb in ipairs(zombies) do
if (isElement(theZomb)) then
if (getElementData (theZomb, "zombie") == true) then
local Zx,Zy,Zz = getElementPosition( theZomb )
for theKey,theNonZomb in ipairs(nonzombies) do
if (getElementData (theNonZomb, "zombie") ~= true) and (id ~= 293) then -- if the ped isnt a zombie
local Px,Py,Pz = getElementPosition( theNonZomb )
if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false )
if (isclear == true) and ( getElementHealth ( theNonZomb ) > 0) then
if ( getElementData ( theZomb, "status" ) == "idle" ) then --CHECKS IF AN IDLE ZOMBIE IS IN SIGHT
triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)
setElementData ( theZomb, "status", "chasing" )
setElementData ( theZomb, "target", theNonZomb )
zombieradiusalert (theZomb)
elseif ( getElementData ( theZomb, "status" ) == "chasing" ) and ( getElementData ( theZomb, "target" ) == nil) then
triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)
setElementData ( theZomb, "target", theNonZomb )
end
end
end
if ( getElementData ( theZomb, "target" ) == theNonZomb ) then --CHECKS IF AN ALREADY AGGRESSIVE ZOMBIE IS IN SIGHT OF THE PED
local Px,Py,Pz = getElementPosition( theNonZomb )
if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz+1, true, false, false, true, false, false, false)
if (isclear == false) then --IF YOUR ZOMBIE LOST THE PED, MAKES IT REMEMBER the peds LAST COORDS
triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)
setElementData ( theZomb, "target", nil )
end
end
end
end
end
end
end
end
end
for k, ped in pairs( myZombies ) do
if (isElement(ped) == false) then
table.remove( myZombies, k)
end
end
oldPx,oldPy,oldPz = getElementPosition( getLocalPlayer () )
end
i ve insert the id on table array, but the zombies still chase me