Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function zombie_check ()
- if (getElementData (getLocalPlayer (), "zombie") ~= true) and ( isPedDead ( getLocalPlayer () ) == false ) and (getElementModel(getLocalPlayer()) ~= 293) 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
- 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 )
- table.remove( zombies, theKey)
- zombieradiusalert (theZomb)
- end
- elseif (getElementData(theZomb,"status") == "chasing") and (getElementData(theZomb,"target") == nil) then --
- 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 )
- if id = 293 then
- table.insert( myZombies, id )
- end
- table.remove( zombies, theKey)
- end
- end
- elseif ( getElementData ( theZomb, "target" ) == getLocalPlayer() ) then
- local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false)
- if (isclear == false) then
- setElementData ( theZomb, "target", nil )
- triggerServerEvent ("onZombieLostPlayer", theZomb, oldPx, oldPy, oldPz)
- end
- end
- end
- end
- end
- end
- 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
- 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
- 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
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement