Jump to content

Help Zombie_respawn


Plate

Recommended Posts

Hi i have a problem whit this script for example

if i have 30 zombies in one spot i kill one and respawn 30 zombies can anyone help me?

function Zomb_respawn (ped) 
    if isElement(ped) then 
        if (getElementData (ped, "zombie") == true) then 
            for theKey,thePed in ipairs(zombiesInSpot) do 
                if ped == thePed then 
                    table.remove( zombiesInSpot, theKey ) 
                    break 
                end 
            end 
            local zombieSkin = getElementModel(ped) 
            local zombieLevel = getElementData(ped,"level") 
            local maxHP = getElementData(ped,"maxhealth") 
            local zombieSpot = getElementData(ped,"zombieSpot") 
            local spotRadius = getElementData(zombieSpot,"radius") 
            local sortZombies = spotRadius/1.2 
            local sx,sy,sz = getElementPosition(zombieSpot) 
            local zom = createZombie (sx+math.random(-sortZombies,sortZombies),sy+math.random(-sortZombies,sortZombies),sz+1.5,math.random(1,360),zombieSkin,0,0,zombieLevel,maxHP) 
            table.insert(zombiesInSpot,zom) 
            setElementData(zom,"zombieSpot",zombieSpot) 
        end 
    end 
end 
  
function respawnZombieWhenDead(dataName) 
    if getElementType ( source ) == "ped" and dataName == "status" then 
        if (getElementData (source, "zombie") == true) then 
            if (getElementData ( source, "status" ) ==  "dead" ) then 
                setTimer ( Zomb_respawn, 9000, 1, source) 
            end 
        end 
    end 
end 
addEventHandler ( "onElementDataChange", getRootElement(),respawnZombieWhenDead ) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...