Jump to content

#♡ ZĂ7Ḟ - TAPL <~ تمت الافاده


iA7bk#

Recommended Posts

شباب ابي احط الزومبي بعالم وهمي رقم 4 وما ابيه يظهر الا فيه بس كيف ؟؟

الله لا يهينكم اذا في احد يعرف يسويه لي او يعطيني الكود ويقولي وين احطه !!

كلنت

myZombies = { } 
helmetzombies = { 27, 51, 52, 99, 27, 137, 153, 167, 205, 260, 277, 278, 279, 284, 285 }
resourceRoot = getResourceRootElement()
 
--FORCES ZOMBIES TO MOVE ALONG AFTER THEIR TARGET PLAYER DIES
function playerdead ()
    setTimer ( Zomb_release, 4000, 1 )
end
addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), playerdead )
 
function Zomb_release ()
    for k, ped in pairs( myZombies ) do
        if (isElement(ped)) then
            if (getElementData (ped, "zombie") == true) then
                setElementData ( ped, "target", nil )
                setElementData ( ped, "status", "idle" )
                table.remove(myZombies,k)
            end
        end
    end
end
 
--REMOVES A ZOMBIE FROM INFLUENCE AFTER ITS KILLED
function pedkilled ( killer, weapon, bodypart )
    if (getElementData (source, "zombie") == true) and (getElementData (source, "status") ~= "dead" ) then
        setElementData ( source, "target", nil )
        setElementData ( source, "status", "dead" )
    end
end
addEventHandler ( "onClientPedWasted", getRootElement(), pedkilled )
 
--THIS CHECKS ALL ZOMBIES EVERY SECOND TO SEE IF THEY ARE IN SIGHT
function zombie_check ()
    if (getElementData (getLocalPlayer (), "zombie") ~= true) and ( isPlayerDead ( getLocalPlayer () ) == false ) then
        local zombies = getElementsByType ( "ped",getRootElement(),true )
        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
                                    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 )
        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) 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
 
 
--INITAL SETUP
 
function clientsetupstarter(startedresource)
    if startedresource == getThisResource() then
        setTimer ( clientsetup, 1234, 1)
        MainClientTimer1 = setTimer ( zombie_check, 1000, 0)  --STARTS THE TIMER TO CHECK FOR ZOMBIES
    end
end
addEventHandler("onClientResourceStart", getRootElement(), clientsetupstarter)
 
function clientsetup()
    oldPx,oldPy,oldPz = getElementPosition( getLocalPlayer () )
    throatcol = createColSphere ( 0, 0, 0, .3)
    woodpic = guiCreateStaticImage( .65, .06, .1, .12, "zombiewood.png", true )
    guiSetVisible ( woodpic, false )
 
--ALL ZOMBIES STFU
    local zombies = getElementsByType ( "ped" )
    for theKey,theZomb in ipairs(zombies) do
        if (isElement(theZomb)) then
            if (getElementData (theZomb, "zombie") == true) then
                setPedVoice(theZomb, "PED_TYPE_DISABLED")
            end
        end
    end
   
--SKIN REPLACEMENTS
    local skin = engineLoadTXD ( "skins/13.txd" ) --bleedin eyes 31 by Slothman
    engineImportTXD ( skin, 13 )
    local skin = engineLoadTXD ( "skins/22.txd" ) -- slashed 12 by Wall-E
    engineImportTXD ( skin, 22 )   
    local skin = engineLoadTXD ( "skins/56.txd" ) --young and blue by Slothman
    engineImportTXD ( skin, 56 )
    local skin = engineLoadTXD ( "skins/67.txd" ) -- slit r* employee
    engineImportTXD ( skin, 67 )
    local skin = engineLoadTXD ( "skins/68.txd" ) -- shredded preist by Deixell
    engineImportTXD ( skin, 68 )
    local skin = engineLoadTXD ( "skins/69.txd" ) --bleedin eyes in denim by Capitanazop
    engineImportTXD ( skin, 69 )
    local skin = engineLoadTXD ( "skins/70.txd" ) --ultra gory scientist by 50p
    engineImportTXD ( skin, 70 )
    local skin = engineLoadTXD ( "skins/84.txd" ) --guitar wolf (nonzombie) by Slothman
    engineImportTXD ( skin, 84 )
    local skin = engineLoadTXD ( "skins/92.txd" ) -- peeled flesh by xbost
    engineImportTXD ( skin, 92 )
    local skin = engineLoadTXD ( "skins/97.txd" ) -- easterboy by Slothman
    engineImportTXD ( skin, 97 )
    local skin = engineLoadTXD ( "skins/105.txd" ) --Scarred Grove Gangster by Wall-E
    engineImportTXD ( skin, 105 )
    local skin = engineLoadTXD ( "skins/107.txd" ) --ripped and slashed grove by Wall-E
    engineImportTXD ( skin, 107 )
    local skin = engineLoadTXD ( "skins/108.txd" ) -- skeleton thug by Deixell
    engineImportTXD ( skin, 108 )
    local skin = engineLoadTXD ( "skins/111.txd" ) --Frank West from dead rising (nonzombie) by Slothman
    engineImportTXD ( skin, 111 )
    local skin = engineLoadTXD ( "skins/126.txd" ) -- bullet ridden wiseguy by Slothman
    engineImportTXD ( skin, 126 )
    local skin = engineLoadTXD ( "skins/127.txd" ) --flyboy from dawn of the dead by Slothman
    engineImportTXD ( skin, 127 )
    local skin = engineLoadTXD ( "skins/128.txd" ) --holy native by Slothman
    engineImportTXD ( skin, 128 )
    local skin = engineLoadTXD ( "skins/152.txd" ) --bitten schoolgirl by Slothman
    engineImportTXD ( skin, 152 )
    local skin = engineLoadTXD ( "skins/162.txd" ) --shirtless redneck by Slothman
    engineImportTXD ( skin, 162 )
    local skin = engineLoadTXD ( "skins/167.txd" ) --dead chickenman by 50p
    engineImportTXD ( skin, 167 )
    local skin = engineLoadTXD ( "skins/188.txd" ) --burnt greenshirt by Slothman
    engineImportTXD ( skin, 188 )
    local skin = engineLoadTXD ( "skins/192.txd" ) --Alice from resident evil (nonzombie) by Slothman
    engineImportTXD ( skin, 192 )
    local skin = engineLoadTXD ( "skins/195.txd" ) --bloody ex by Slothman
    engineImportTXD ( skin, 195 )
    local skin = engineLoadTXD ( "skins/206.txd" ) -- faceless zombie by Slothman
    engineImportTXD ( skin, 206 )
    local skin = engineLoadTXD ( "skins/209.txd" ) --Noodle vendor by 50p
    engineImportTXD ( skin, 209 )
    local skin = engineLoadTXD ( "skins/212.txd" ) --brainy hobo by Slothman
    engineImportTXD ( skin, 212 )
    local skin = engineLoadTXD ( "skins/229.txd" ) --infected tourist by Slothman
    engineImportTXD ( skin, 229 )
    local skin = engineLoadTXD ( "skins/230.txd" ) --will work for brains hobo by Slothman
    engineImportTXD ( skin, 230 )
    local skin = engineLoadTXD ( "skins/258.txd" ) --bloody sided suburbanite by Slothman
    engineImportTXD ( skin, 258 )
    local skin = engineLoadTXD ( "skins/264.txd" ) --scary clown by 50p
    engineImportTXD ( skin, 264 )
    local skin = engineLoadTXD ( "skins/274.txd" ) --Ash Williams (nonzombie) by Slothman
    engineImportTXD ( skin, 274 )
    local skin = engineLoadTXD ( "skins/277.txd" ) -- gutted firefighter by Wall-E
    engineImportTXD ( skin, 277 )
    local skin = engineLoadTXD ( "skins/280.txd" ) --infected cop by Lordy
    engineImportTXD ( skin, 280 )
    local skin = engineLoadTXD ( "skins/287.txd" ) --torn army by Deixell
    engineImportTXD ( skin, 287 )
end
 
--UPDATES PLAYERS COUNT OF AGGRESIVE ZOMBIES
addEventHandler ( "onClientElementDataChange", getRootElement(),
function ( dataName )
    if getElementType ( source ) == "ped" and dataName == "status" then
        local thestatus = (getElementData ( source, "status" ))
        if (thestatus == "idle") or (thestatus == "dead") then     
            for k, ped in pairs( myZombies ) do
                if ped == source and (getElementData (ped, "zombie") == true) then
                    setElementData ( ped, "target", nil )
                    table.remove( myZombies, k)
                    setElementData ( getLocalPlayer(), "dangercount", tonumber(table.getn( myZombies )) )
                end
            end
        end
    end
end )
 
--MAKES A ZOMBIE JUMP
addEvent( "Zomb_Jump", true )
function Zjump ( ped )
    if (isElement(ped)) then
        setPedControlState( ped, "jump", true )
        setTimer ( function (ped) if ( isElement ( ped ) ) then setPedControlState ( ped, "jump", false) end end, 800, 1, ped )
    end
end
Edited by Guest
Link to comment
# ولله , اعتقد من النادر انك تقدر تعدل عليه

: " لأنه ممعقد جدا , ويبي اللي سواه يسوي طلبكـ

طيب ما اقدر اخليه بمنطقه او ساحه انا اصممها وما يخرجون منها ؟؟

غير مود احمد فيف لان مكان االساحه الي بمود احمد فيف ما عجبني

Link to comment
# ولله , اعتقد من النادر انك تقدر تعدل عليه

: " لأنه ممعقد جدا , ويبي اللي سواه يسوي طلبكـ

طيب ما اقدر اخليه بمنطقه او ساحه انا اصممها وما يخرجون منها ؟؟

غير مود احمد فيف لان مكان االساحه الي بمود احمد فيف ما عجبني

# لأ ولله , لأنه المممود معقد جدا

يبي له واحد خبرة عاليةة جدأ , او صاحب المود نفسه يقدر يسوي لك كذا

Link to comment
# ولله , اعتقد من النادر انك تقدر تعدل عليه

: " لأنه ممعقد جدا , ويبي اللي سواه يسوي طلبكـ

طيب ما اقدر اخليه بمنطقه او ساحه انا اصممها وما يخرجون منها ؟؟

غير مود احمد فيف لان مكان االساحه الي بمود احمد فيف ما عجبني

# لأ ولله , لأنه المممود معقد جدا

يبي له واحد خبرة عاليةة جدأ , او صاحب المود نفسه يقدر يسوي لك كذا

اها عموماً يعطيك العافيه على اهتمامك وما قصرت والله

Link to comment

دور عن الفنكشن الي يسوي سباون للزومبي وخله يتأكد يتاكد من ععالم اللاعب الي بيسويهم عنده وعفسه

مابي انا تعب ووجع راس دور انت وتلقاه :D

ورانا اختبارات والكود حق الزومبي طويل وعريض

Link to comment

جرب

سيرفر:

ZombieLimit = get("zombies.MaxZombies")-- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM? 
ZombieStreaming = get("zombies.StreamMethod") -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints
ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
--ZombiePedSkins = {7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,36,37,38,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81,82,83,85,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,156,157,158,159,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,210,211,212,213,214,215,216,217,218,219,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,275,276,277,278,279,280,281,282,283,284,285,286,287,288 }
ZombieSpeed = get("zombies.Speed")
if ZombieSpeed == 0 then --super slow zombies (goofy looking)
    chaseanim = "WALK_drunk"
    checkspeed = 2000
elseif ZombieSpeed == 1 then -- normal speed
    chaseanim = "run_old"
    checkspeed = 1000
elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server)
    chaseanim = "Run_Wuzi"
    checkspeed = 680
else -- defaults back to normal
    chaseanim = "run_old"
    checkspeed = 1000
end
resourceRoot = getResourceRootElement()
moancount =0
moanlimit = 10
everyZombie = { }
 
--IDLE BEHAVIOUR OF A ZOMBIE
function Zomb_Idle (ped)
    if isElement(ped) then
        if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) then
            local action = math.random( 1, 6 )
            if action < 4 then -- walk a random direction
                local rdmangle = math.random( 1, 359 )
                setPedRotation( ped, rdmangle )
                setPedAnimation ( ped, "PED", "Player_Sneak", -1, true, true, true)
                setTimer ( Zomb_Idle, 7000, 1, ped )
            elseif action == 4 then -- get on the ground
                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true)
                setTimer ( Zomb_Idle, 4000, 1, ped )
            elseif action == 5 then -- stand still doing nothing
                setPedAnimation ( ped )
                setTimer ( Zomb_Idle, 4000, 1, ped )
            end
        end
    end
end
 
--BEHAVIOUR WHILE CHASING PLAYERS
function Zomb_chase (ped, Zx, Zy, Zz )
    if isElement(ped) then
        if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) then
            local x, y, z = getElementPosition( ped )
            if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false then        
                local Px = getElementData ( ped, "Tx" )
                local Py = getElementData ( ped, "Ty" )
                local Pz = getElementData ( ped, "Tz" )
                local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, x, y, z ))
                if (Pdistance < 1.5 ) then
                    setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                end
            end
            local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz ))          
            if (distance < 1 ) then -- IF THE PED HASNT MOVED
                if (getElementData ( ped, "target" ) == nil) then
                    local giveup = math.random( 1, 15 )
                    if giveup == 1 then
                        setElementData ( ped, "status", "idle" )
                    else
                        local action = math.random( 1, 2 )
                        if action == 1 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                            setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                        elseif action == 2 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                            setTimer ( Zomb_chase, 3500, 1, ped, x, y, z )
                        end
                    end
                else
                    local Ptarget = (getElementData ( ped, "target" ))
                    if isElement(Ptarget) then
                        local Px, Py, Pz = getElementPosition( Ptarget )
                        local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz ))
                        if (Pdistance < 1.2 ) then -- ATTACK A PLAYER IF THEY ARE CLOSE
                            if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYER
                                setPedAnimation ( ped )
                                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, false)
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 10000, 1, ped )
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 10000, 1, ped )
                                zmoan(ped)
                            else
                                local action = math.random( 1, 6 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                else
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        else
                            if ( isPedDead (Ptarget) ) then
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 1800, 1, ped )
                            else
                                local action = math.random( 1, 2 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                elseif action == 2 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        end
                    else
                        setElementData ( ped, "status", "idle" )
                    end
                end
            else
                setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKING
                setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAIN
            end
        end
    end
end
 
--SET THE DIRECTION OF THE ZOMBIE
function setangle ()
    for theKey,ped in ipairs(everyZombie) do
        if isElement(ped) then
            if ( getElementData ( ped, "status" ) == "chasing" ) then
                local x
                local y
                local z
                local px
                local py
                local pz
                if ( getElementData ( ped, "target" ) ~= nil ) then
                    local ptarget = getElementData ( ped, "target" )
                    if isElement(ptarget) then
                        x, y, z = getElementPosition( ptarget )
                        px, py, pz = getElementPosition( ped )
                    else
                        setElementData ( ped, "status", "idle" )
                        x, y, z = getElementPosition( ped )
                        px, py, pz = getElementPosition( ped )
                    end
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUTS
                    x = getElementData ( ped, "Tx" )
                    y = getElementData ( ped, "Ty" )
                    z = getElementData ( ped, "Tz" )
                    px, py, pz = getElementPosition( ped )
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                end
            end
        end
    end
end
 
--SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES
addEventHandler ( "onElementDataChange", getRootElement(),
function ( dataName )
    if getElementType ( source ) == "ped" and dataName == "status" then
        if (getElementData (source, "zombie") == true) then
            if ( isPedDead ( source ) == false ) then
                if (getElementData ( source, "status" ) ==  "chasing" ) then
                    local Zx, Zy, Zz = getElementPosition( source )
                    setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz )
                    local newtarget = (getElementData ( source, "target" ))
                    if isElement (newtarget) then
                        if getElementType ( newtarget ) == "player" then
                            setElementSyncer ( source, newtarget )
                        end
                    end
                    zmoan(source)
                elseif (getElementData ( source, "status" ) ==  "idle" ) then
                    setTimer ( Zomb_Idle, 1000, 1, source)
                elseif (getElementData ( source, "status" ) ==  "throatslashing" ) then
                    local tx,ty,tz = getElementPosition( source )
                    local ptarget = getElementData ( source, "target" )
                    if isElement(ptarget) then
                        local vx,vy,vz = getElementPosition( ptarget )
                        local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz))
                        if (zombdistance < .-- s8) --> then
                            zmoan(source)
                            setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true)
                            setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true)
                            setTimer ( Playerthroatbitten, 2300, 1, ptarget, source)
                            setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source )
                        else
                            setElementData ( source, "status", "idle" )
                        end
                    else
                        setElementData ( source, "status", "idle" )
                    end
                end
            elseif (getElementData ( source, "status" ) ==  "dead" ) then
                setTimer ( Zomb_delete, 10000, 1, source)
            end
        end
    end
end)
 
--RESOURCE START/INITIAL SETUP
function outbreak(startedResource)
    newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit")
    if newZombieLimit ~= false then
        if newZombieLimit > ZombieLimit then
            newZombieLimit = ZombieLimit
        end
    else
        newZombieLimit = ZombieLimit
    end
    WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIERS
    if startedResource == getThisResource() then
--      call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOARD
        local allplayers = getElementsByType ( "player" )
        for pKey,thep in ipairs(allplayers) do
            setElementData ( thep, "dangercount", 0 )
        end
        local alivePlayers = getAlivePlayers ()
        for playerKey, playerValue in ipairs(alivePlayers) do
            setElementData ( playerValue, "alreadyspawned", true  )
        end
        if ZombieSpeed == 2 then
            MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast)
        else
            MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION
        end
        MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS
        if ZombieStreaming == 1 then
            MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random locations
        elseif ZombieStreaming == 2 then
            MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoints
        end
    end
end
addEventHandler("onResourceStart", getRootElement(), outbreak)
 
function player_Connect()
    setElementData ( source, "dangercount", 0 )
end
Link to comment
جرب

سيرفر:

ZombieLimit = get("zombies.MaxZombies")-- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM? 
ZombieStreaming = get("zombies.StreamMethod") -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints
ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
--ZombiePedSkins = {7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,36,37,38,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81,82,83,85,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,156,157,158,159,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,210,211,212,213,214,215,216,217,218,219,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,275,276,277,278,279,280,281,282,283,284,285,286,287,288 }
ZombieSpeed = get("zombies.Speed")
if ZombieSpeed == 0 then --super slow zombies (goofy looking)
    chaseanim = "WALK_drunk"
    checkspeed = 2000
elseif ZombieSpeed == 1 then -- normal speed
    chaseanim = "run_old"
    checkspeed = 1000
elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server)
    chaseanim = "Run_Wuzi"
    checkspeed = 680
else -- defaults back to normal
    chaseanim = "run_old"
    checkspeed = 1000
end
resourceRoot = getResourceRootElement()
moancount =0
moanlimit = 10
everyZombie = { }
 
--IDLE BEHAVIOUR OF A ZOMBIE
function Zomb_Idle (ped)
    if isElement(ped) then
        if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) then
            local action = math.random( 1, 6 )
            if action < 4 then -- walk a random direction
                local rdmangle = math.random( 1, 359 )
                setPedRotation( ped, rdmangle )
                setPedAnimation ( ped, "PED", "Player_Sneak", -1, true, true, true)
                setTimer ( Zomb_Idle, 7000, 1, ped )
            elseif action == 4 then -- get on the ground
                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true)
                setTimer ( Zomb_Idle, 4000, 1, ped )
            elseif action == 5 then -- stand still doing nothing
                setPedAnimation ( ped )
                setTimer ( Zomb_Idle, 4000, 1, ped )
            end
        end
    end
end
 
--BEHAVIOUR WHILE CHASING PLAYERS
function Zomb_chase (ped, Zx, Zy, Zz )
    if isElement(ped) then
        if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) then
            local x, y, z = getElementPosition( ped )
            if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false then        
                local Px = getElementData ( ped, "Tx" )
                local Py = getElementData ( ped, "Ty" )
                local Pz = getElementData ( ped, "Tz" )
                local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, x, y, z ))
                if (Pdistance < 1.5 ) then
                    setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                end
            end
            local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz ))          
            if (distance < 1 ) then -- IF THE PED HASNT MOVED
                if (getElementData ( ped, "target" ) == nil) then
                    local giveup = math.random( 1, 15 )
                    if giveup == 1 then
                        setElementData ( ped, "status", "idle" )
                    else
                        local action = math.random( 1, 2 )
                        if action == 1 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                            setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                        elseif action == 2 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                            setTimer ( Zomb_chase, 3500, 1, ped, x, y, z )
                        end
                    end
                else
                    local Ptarget = (getElementData ( ped, "target" ))
                    if isElement(Ptarget) then
                        local Px, Py, Pz = getElementPosition( Ptarget )
                        local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz ))
                        if (Pdistance < 1.2 ) then -- ATTACK A PLAYER IF THEY ARE CLOSE
                            if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYER
                                setPedAnimation ( ped )
                                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, false)
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 10000, 1, ped )
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 10000, 1, ped )
                                zmoan(ped)
                            else
                                local action = math.random( 1, 6 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                else
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        else
                            if ( isPedDead (Ptarget) ) then
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 1800, 1, ped )
                            else
                                local action = math.random( 1, 2 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                elseif action == 2 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        end
                    else
                        setElementData ( ped, "status", "idle" )
                    end
                end
            else
                setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKING
                setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAIN
            end
        end
    end
end
 
--SET THE DIRECTION OF THE ZOMBIE
function setangle ()
    for theKey,ped in ipairs(everyZombie) do
        if isElement(ped) then
            if ( getElementData ( ped, "status" ) == "chasing" ) then
                local x
                local y
                local z
                local px
                local py
                local pz
                if ( getElementData ( ped, "target" ) ~= nil ) then
                    local ptarget = getElementData ( ped, "target" )
                    if isElement(ptarget) then
                        x, y, z = getElementPosition( ptarget )
                        px, py, pz = getElementPosition( ped )
                    else
                        setElementData ( ped, "status", "idle" )
                        x, y, z = getElementPosition( ped )
                        px, py, pz = getElementPosition( ped )
                    end
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUTS
                    x = getElementData ( ped, "Tx" )
                    y = getElementData ( ped, "Ty" )
                    z = getElementData ( ped, "Tz" )
                    px, py, pz = getElementPosition( ped )
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                end
            end
        end
    end
end
 
--SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES
addEventHandler ( "onElementDataChange", getRootElement(),
function ( dataName )
    if getElementType ( source ) == "ped" and dataName == "status" then
        if (getElementData (source, "zombie") == true) then
            if ( isPedDead ( source ) == false ) then
                if (getElementData ( source, "status" ) ==  "chasing" ) then
                    local Zx, Zy, Zz = getElementPosition( source )
                    setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz )
                    local newtarget = (getElementData ( source, "target" ))
                    if isElement (newtarget) then
                        if getElementType ( newtarget ) == "player" then
                            setElementSyncer ( source, newtarget )
                        end
                    end
                    zmoan(source)
                elseif (getElementData ( source, "status" ) ==  "idle" ) then
                    setTimer ( Zomb_Idle, 1000, 1, source)
                elseif (getElementData ( source, "status" ) ==  "throatslashing" ) then
                    local tx,ty,tz = getElementPosition( source )
                    local ptarget = getElementData ( source, "target" )
                    if isElement(ptarget) then
                        local vx,vy,vz = getElementPosition( ptarget )
                        local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz))
                        if (zombdistance < .-- s8) --> then
                            zmoan(source)
                            setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true)
                            setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true)
                            setTimer ( Playerthroatbitten, 2300, 1, ptarget, source)
                            setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source )
                        else
                            setElementData ( source, "status", "idle" )
                        end
                    else
                        setElementData ( source, "status", "idle" )
                    end
                end
            elseif (getElementData ( source, "status" ) ==  "dead" ) then
                setTimer ( Zomb_delete, 10000, 1, source)
            end
        end
    end
end)
 
--RESOURCE START/INITIAL SETUP
function outbreak(startedResource)
    newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit")
    if newZombieLimit ~= false then
        if newZombieLimit > ZombieLimit then
            newZombieLimit = ZombieLimit
        end
    else
        newZombieLimit = ZombieLimit
    end
    WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIERS
    if startedResource == getThisResource() then
--      call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOARD
        local allplayers = getElementsByType ( "player" )
        for pKey,thep in ipairs(allplayers) do
            setElementData ( thep, "dangercount", 0 )
        end
        local alivePlayers = getAlivePlayers ()
        for playerKey, playerValue in ipairs(alivePlayers) do
            setElementData ( playerValue, "alreadyspawned", true  )
        end
        if ZombieSpeed == 2 then
            MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast)
        else
            MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION
        end
        MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS
        if ZombieStreaming == 1 then
            MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random locations
        elseif ZombieStreaming == 2 then
            MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoints
        end
    end
end
addEventHandler("onResourceStart", getRootElement(), outbreak)
 
function player_Connect()
   
Link to comment

جرب :D

  
ZombieLimit = get("zombies.MaxZombies")-- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM?
ZombieStreaming = get("zombies.StreamMethod") -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints
ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
--ZombiePedSkins = {7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,36,37,38,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81,82,83,85,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,156,157,158,159,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,210,211,212,213,214,215,216,217,218,219,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,275,276,277,278,279,280,281,282,283,284,285,286,287,288 }
ZombieSpeed = get("zombies.Speed")
if ZombieSpeed == 0 then --super slow zombies (goofy looking)
    chaseanim = "WALK_drunk"
    checkspeed = 2000
elseif ZombieSpeed == 1 then -- normal speed
    chaseanim = "run_old"
    checkspeed = 1000
elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server)
    chaseanim = "Run_Wuzi"
    checkspeed = 680
else -- defaults back to normal
    chaseanim = "run_old"
    checkspeed = 1000
end
resourceRoot = getResourceRootElement()
moancount =0
moanlimit = 10
everyZombie = { }
 
--IDLE BEHAVIOUR OF A ZOMBIE
function Zomb_Idle (ped)
    if isElement(ped) then
        if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) then
            local action = math.random( 1, 6 )
            if action < 4 then -- walk a random direction
                local rdmangle = math.random( 1, 359 )
                setPedRotation( ped, rdmangle )
                setPedAnimation ( ped, "PED", "Player_Sneak", -1, true, true, true)
                setTimer ( Zomb_Idle, 7000, 1, ped )
            elseif action == 4 then -- get on the ground
                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true)
                setTimer ( Zomb_Idle, 4000, 1, ped )
            elseif action == 5 then -- stand still doing nothing
                setPedAnimation ( ped )
                setTimer ( Zomb_Idle, 4000, 1, ped )
            end
        end
    end
end
 
--BEHAVIOUR WHILE CHASING PLAYERS
function Zomb_chase (ped, Zx, Zy, Zz )
    if isElement(ped) then
        if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) then
            local x, y, z = getElementPosition( ped )
            if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false then        
                local Px = getElementData ( ped, "Tx" )
                local Py = getElementData ( ped, "Ty" )
                local Pz = getElementData ( ped, "Tz" )
                local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, x, y, z ))
                if (Pdistance < 1.5 ) then
                    setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                end
            end
            local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz ))          
            if (distance < 1 ) then -- IF THE PED HASNT MOVED
                if (getElementData ( ped, "target" ) == nil) then
                    local giveup = math.random( 1, 15 )
                    if giveup == 1 then
                        setElementData ( ped, "status", "idle" )
                    else
                        local action = math.random( 1, 2 )
                        if action == 1 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                            setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                        elseif action == 2 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                            setTimer ( Zomb_chase, 3500, 1, ped, x, y, z )
                        end
                    end
                else
                    local Ptarget = (getElementData ( ped, "target" ))
                    if isElement(Ptarget) then
                        local Px, Py, Pz = getElementPosition( Ptarget )
                        local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz ))
                        if (Pdistance < 1.2 ) then -- ATTACK A PLAYER IF THEY ARE CLOSE
                            if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYER
                                setPedAnimation ( ped )
                                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, false)
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 10000, 1, ped )
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 10000, 1, ped )
                                zmoan(ped)
                            else
                                local action = math.random( 1, 6 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                else
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        else
                            if ( isPedDead (Ptarget) ) then
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 1800, 1, ped )
                            else
                                local action = math.random( 1, 2 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                elseif action == 2 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        end
                    else
                        setElementData ( ped, "status", "idle" )
                    end
                end
            else
                setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKING
                setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAIN
            end
        end
    end
end
 
--SET THE DIRECTION OF THE ZOMBIE
function setangle ()
    for theKey,ped in ipairs(everyZombie) do
        if isElement(ped) then
            if ( getElementData ( ped, "status" ) == "chasing" ) then
                local x
                local y
                local z
                local px
                local py
                local pz
                if ( getElementData ( ped, "target" ) ~= nil ) then
                    local ptarget = getElementData ( ped, "target" )
                    if isElement(ptarget) then
                        x, y, z = getElementPosition( ptarget )
                        px, py, pz = getElementPosition( ped )
                    else
                        setElementData ( ped, "status", "idle" )
                        x, y, z = getElementPosition( ped )
                        px, py, pz = getElementPosition( ped )
                    end
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUTS
                    x = getElementData ( ped, "Tx" )
                    y = getElementData ( ped, "Ty" )
                    z = getElementData ( ped, "Tz" )
                    px, py, pz = getElementPosition( ped )
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                end
            end
        end
    end
end
 
--SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES
addEventHandler ( "onElementDataChange", getRootElement(),
function ( dataName )
    if getElementType ( source ) == "ped" and dataName == "status" then
        if (getElementData (source, "zombie") == true) then
            if ( isPedDead ( source ) == false ) then
                if (getElementData ( source, "status" ) ==  "chasing" ) then
                    local Zx, Zy, Zz = getElementPosition( source )
                    setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz )
                    local newtarget = (getElementData ( source, "target" ))
                    if isElement (newtarget) then
                        if getElementType ( newtarget ) == "player" then
                            setElementSyncer ( source, newtarget )
                        end
                    end
                    zmoan(source)
                elseif (getElementData ( source, "status" ) ==  "idle" ) then
                    setTimer ( Zomb_Idle, 1000, 1, source)
                elseif (getElementData ( source, "status" ) ==  "throatslashing" ) then
                    local tx,ty,tz = getElementPosition( source )
                    local ptarget = getElementData ( source, "target" )
                    if isElement(ptarget) then
                        local vx,vy,vz = getElementPosition( ptarget )
                        local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz))
                        if (zombdistance < .-- s8) --> then
                            zmoan(source)
                            setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true)
                            setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true)
                            setTimer ( Playerthroatbitten, 2300, 1, ptarget, source)
                            setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source )
                        else
                            setElementData ( source, "status", "idle" )
                        end
                    else
                        setElementData ( source, "status", "idle" )
                    end
                end
            elseif (getElementData ( source, "status" ) ==  "dead" ) then
                setTimer ( Zomb_delete, 10000, 1, source)
            end
        end
    end
end)
 
--RESOURCE START/INITIAL SETUP
function outbreak(startedResource)
    newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit")
    if newZombieLimit ~= false then
        if newZombieLimit > ZombieLimit then
            newZombieLimit = ZombieLimit
        end
    else
        newZombieLimit = ZombieLimit
    end
    WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIERS
    if startedResource == getThisResource() then
--      call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOARD
        local allplayers = getElementsByType ( "player" )
        for pKey,thep in ipairs(allplayers) do
            setElementData ( thep, "dangercount", 0 )
        end
        local alivePlayers = getAlivePlayers ()
        for playerKey, playerValue in ipairs(alivePlayers) do
            setElementData ( playerValue, "alreadyspawned", true  )
        end
        if ZombieSpeed == 2 then
            MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast)
        else
            MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION
        end
        MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS
        if ZombieStreaming == 1 then
            MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random locations
        elseif ZombieStreaming == 2 then
            MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoints
        end
    end
end
addEventHandler("onResourceStart", getRootElement(), outbreak)
 
function player_Connect()
   
Link to comment

جرب :D

  
ZombieLimit = get("zombies.MaxZombies")-- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM?
ZombieStreaming = get("zombies.StreamMethod") -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints
ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
--ZombiePedSkins = {7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,36,37,38,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81,82,83,85,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,156,157,158,159,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,210,211,212,213,214,215,216,217,218,219,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,275,276,277,278,279,280,281,282,283,284,285,286,287,288 }
ZombieSpeed = get("zombies.Speed")
if ZombieSpeed == 0 then --super slow zombies (goofy looking)
    chaseanim = "WALK_drunk"
    checkspeed = 2000
elseif ZombieSpeed == 1 then -- normal speed
    chaseanim = "run_old"
    checkspeed = 1000
elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server)
    chaseanim = "Run_Wuzi"
    checkspeed = 680
else -- defaults back to normal
    chaseanim = "run_old"
    checkspeed = 1000
end
resourceRoot = getResourceRootElement()
moancount =0
moanlimit = 10
everyZombie = { }
 
--IDLE BEHAVIOUR OF A ZOMBIE
function Zomb_Idle (ped)
    if isElement(ped) then
        if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) then
            local action = math.random( 1, 6 )
            if action < 4 then -- walk a random direction
                local rdmangle = math.random( 1, 359 )
                setPedRotation( ped, rdmangle )
                setPedAnimation ( ped, "PED", "Player_Sneak", -1, true, true, true)
                setTimer ( Zomb_Idle, 7000, 1, ped )
            elseif action == 4 then -- get on the ground
                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true)
                setTimer ( Zomb_Idle, 4000, 1, ped )
            elseif action == 5 then -- stand still doing nothing
                setPedAnimation ( ped )
                setTimer ( Zomb_Idle, 4000, 1, ped )
            end
        end
    end
end
 
--BEHAVIOUR WHILE CHASING PLAYERS
function Zomb_chase (ped, Zx, Zy, Zz )
    if isElement(ped) then
        if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) then
            local x, y, z = getElementPosition( ped )
            if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false then        
                local Px = getElementData ( ped, "Tx" )
                local Py = getElementData ( ped, "Ty" )
                local Pz = getElementData ( ped, "Tz" )
                local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, x, y, z ))
                if (Pdistance < 1.5 ) then
                    setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                end
            end
            local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz ))          
            if (distance < 1 ) then -- IF THE PED HASNT MOVED
                if (getElementData ( ped, "target" ) == nil) then
                    local giveup = math.random( 1, 15 )
                    if giveup == 1 then
                        setElementData ( ped, "status", "idle" )
                    else
                        local action = math.random( 1, 2 )
                        if action == 1 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                            setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                        elseif action == 2 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                            setTimer ( Zomb_chase, 3500, 1, ped, x, y, z )
                        end
                    end
                else
                    local Ptarget = (getElementData ( ped, "target" ))
                    if isElement(Ptarget) then
                        local Px, Py, Pz = getElementPosition( Ptarget )
                        local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz ))
                        if (Pdistance < 1.2 ) then -- ATTACK A PLAYER IF THEY ARE CLOSE
                            if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYER
                                setPedAnimation ( ped )
                                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, false)
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 10000, 1, ped )
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 10000, 1, ped )
                                zmoan(ped)
                            else
                                local action = math.random( 1, 6 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                else
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        else
                            if ( isPedDead (Ptarget) ) then
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 1800, 1, ped )
                            else
                                local action = math.random( 1, 2 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                elseif action == 2 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        end
                    else
                        setElementData ( ped, "status", "idle" )
                    end
                end
            else
                setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKING
                setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAIN
            end
        end
    end
end
 
--SET THE DIRECTION OF THE ZOMBIE
function setangle ()
    for theKey,ped in ipairs(everyZombie) do
        if isElement(ped) then
            if ( getElementData ( ped, "status" ) == "chasing" ) then
                local x
                local y
                local z
                local px
                local py
                local pz
                if ( getElementData ( ped, "target" ) ~= nil ) then
                    local ptarget = getElementData ( ped, "target" )
                    if isElement(ptarget) then
                        x, y, z = getElementPosition( ptarget )
                        px, py, pz = getElementPosition( ped )
                    else
                        setElementData ( ped, "status", "idle" )
                        x, y, z = getElementPosition( ped )
                        px, py, pz = getElementPosition( ped )
                    end
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUTS
                    x = getElementData ( ped, "Tx" )
                    y = getElementData ( ped, "Ty" )
                    z = getElementData ( ped, "Tz" )
                    px, py, pz = getElementPosition( ped )
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                end
            end
        end
    end
end
 
--SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES
addEventHandler ( "onElementDataChange", getRootElement(),
function ( dataName )
    if getElementType ( source ) == "ped" and dataName == "status" then
        if (getElementData (source, "zombie") == true) then
            if ( isPedDead ( source ) == false ) then
                if (getElementData ( source, "status" ) ==  "chasing" ) then
                    local Zx, Zy, Zz = getElementPosition( source )
                    setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz )
                    local newtarget = (getElementData ( source, "target" ))
                    if isElement (newtarget) then
                        if getElementType ( newtarget ) == "player" then
                            setElementSyncer ( source, newtarget )
                        end
                    end
                    zmoan(source)
                elseif (getElementData ( source, "status" ) ==  "idle" ) then
                    setTimer ( Zomb_Idle, 1000, 1, source)
                elseif (getElementData ( source, "status" ) ==  "throatslashing" ) then
                    local tx,ty,tz = getElementPosition( source )
                    local ptarget = getElementData ( source, "target" )
                    if isElement(ptarget) then
                        local vx,vy,vz = getElementPosition( ptarget )
                        local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz))
                        if (zombdistance < .-- s8) --> then
                            zmoan(source)
                            setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true)
                            setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true)
                            setTimer ( Playerthroatbitten, 2300, 1, ptarget, source)
                            setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source )
                        else
                            setElementData ( source, "status", "idle" )
                        end
                    else
                        setElementData ( source, "status", "idle" )
                    end
                end
            elseif (getElementData ( source, "status" ) ==  "dead" ) then
                setTimer ( Zomb_delete, 10000, 1, source)
            end
        end
    end
end)
 
--RESOURCE START/INITIAL SETUP
function outbreak(startedResource)
    newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit")
    if newZombieLimit ~= false then
        if newZombieLimit > ZombieLimit then
            newZombieLimit = ZombieLimit
        end
    else
        newZombieLimit = ZombieLimit
    end
    WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIERS
    if startedResource == getThisResource() then
--      call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOARD
        local allplayers = getElementsByType ( "player" )
        for pKey,thep in ipairs(allplayers) do
            setElementData ( thep, "dangercount", 0 )
        end
        local alivePlayers = getAlivePlayers ()
        for playerKey, playerValue in ipairs(alivePlayers) do
            setElementData ( playerValue, "alreadyspawned", true  )
        end
        if ZombieSpeed == 2 then
            MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast)
        else
            MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION
        end
        MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS
        if ZombieStreaming == 1 then
            MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random locations
        elseif ZombieStreaming == 2 then
            MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoints
        end
    end
end
addEventHandler("onResourceStart", getRootElement(), outbreak)
 
Link to comment

اهااا

المشكلة من المنتدى

رقم 8 يصير ايقونه و يخرب الكود

.-- s8) --> then 

جرب الحين

ZombieLimit = get("zombies.MaxZombies")-- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM? 
ZombieStreaming = get("zombies.StreamMethod") -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints
ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
--ZombiePedSkins = {7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,36,37,38,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81,82,83,85,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,156,157,158,159,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,210,211,212,213,214,215,216,217,218,219,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,275,276,277,278,279,280,281,282,283,284,285,286,287,288 }
ZombieSpeed = get("zombies.Speed")
if ZombieSpeed == 0 then --super slow zombies (goofy looking)
    chaseanim = "WALK_drunk"
    checkspeed = 2000
elseif ZombieSpeed == 1 then -- normal speed
    chaseanim = "run_old"
    checkspeed = 1000
elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server)
    chaseanim = "Run_Wuzi"
    checkspeed = 680
else -- defaults back to normal
    chaseanim = "run_old"
    checkspeed = 1000
end
resourceRoot = getResourceRootElement()
moancount =0
moanlimit = 10
everyZombie = { }
 
--IDLE BEHAVIOUR OF A ZOMBIE
function Zomb_Idle (ped)
    if isElement(ped) then
        if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) then
            local action = math.random( 1, 6 )
            if action < 4 then -- walk a random direction
                local rdmangle = math.random( 1, 359 )
                setPedRotation( ped, rdmangle )
                setPedAnimation ( ped, "PED", "Player_Sneak", -1, true, true, true)
                setTimer ( Zomb_Idle, 7000, 1, ped )
            elseif action == 4 then -- get on the ground
                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true)
                setTimer ( Zomb_Idle, 4000, 1, ped )
            elseif action == 5 then -- stand still doing nothing
                setPedAnimation ( ped )
                setTimer ( Zomb_Idle, 4000, 1, ped )
            end
        end
    end
end
 
--BEHAVIOUR WHILE CHASING PLAYERS
function Zomb_chase (ped, Zx, Zy, Zz )
    if isElement(ped) then
        if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) then
            local x, y, z = getElementPosition( ped )
            if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false then        
                local Px = getElementData ( ped, "Tx" )
                local Py = getElementData ( ped, "Ty" )
                local Pz = getElementData ( ped, "Tz" )
                local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, x, y, z ))
                if (Pdistance < 1.5 ) then
                    setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                end
            end
            local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz ))           
            if (distance < 1 ) then -- IF THE PED HASNT MOVED
                if (getElementData ( ped, "target" ) == nil) then
                    local giveup = math.random( 1, 15 )
                    if giveup == 1 then
                        setElementData ( ped, "status", "idle" )
                    else
                        local action = math.random( 1, 2 )
                        if action == 1 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                            setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                        elseif action == 2 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                            setTimer ( Zomb_chase, 3500, 1, ped, x, y, z )
                        end
                    end
                else
                    local Ptarget = (getElementData ( ped, "target" ))
                    if isElement(Ptarget) then
                        local Px, Py, Pz = getElementPosition( Ptarget )
                        local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz ))
                        if (Pdistance < 1.2 ) then -- ATTACK A PLAYER IF THEY ARE CLOSE
                            if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYER
                                setPedAnimation ( ped )
                                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, false)
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 10000, 1, ped )
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 10000, 1, ped )
                                zmoan(ped)
                            else
                                local action = math.random( 1, 6 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                else
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        else
                            if ( isPedDead (Ptarget) ) then
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 1800, 1, ped )
                            else
                                local action = math.random( 1, 2 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                elseif action == 2 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        end
                    else
                        setElementData ( ped, "status", "idle" )
                    end
                end
            else
                setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKING
                setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAIN
            end
        end
    end
end
 
--SET THE DIRECTION OF THE ZOMBIE
function setangle ()
    for theKey,ped in ipairs(everyZombie) do
        if isElement(ped) then
            if ( getElementData ( ped, "status" ) == "chasing" ) then
                local x
                local y
                local z
                local px
                local py
                local pz
                if ( getElementData ( ped, "target" ) ~= nil ) then
                    local ptarget = getElementData ( ped, "target" )
                    if isElement(ptarget) then
                        x, y, z = getElementPosition( ptarget )
                        px, py, pz = getElementPosition( ped )
                    else
                        setElementData ( ped, "status", "idle" )
                        x, y, z = getElementPosition( ped )
                        px, py, pz = getElementPosition( ped )
                    end
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUTS
                    x = getElementData ( ped, "Tx" )
                    y = getElementData ( ped, "Ty" )
                    z = getElementData ( ped, "Tz" )
                    px, py, pz = getElementPosition( ped )
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                end
            end
        end
    end
end
 
--SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES
addEventHandler ( "onElementDataChange", getRootElement(),
function ( dataName )
    if getElementType ( source ) == "ped" and dataName == "status" then
        if (getElementData (source, "zombie") == true) then
            if ( isPedDead ( source ) == false ) then
                if (getElementData ( source, "status" ) ==  "chasing" ) then
                    local Zx, Zy, Zz = getElementPosition( source )
                    setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz )
                    local newtarget = (getElementData ( source, "target" ))
                    if isElement (newtarget) then
                        if getElementType ( newtarget ) == "player" then
                            setElementSyncer ( source, newtarget )
                        end
                    end
                    zmoan(source)
                elseif (getElementData ( source, "status" ) ==  "idle" ) then
                    setTimer ( Zomb_Idle, 1000, 1, source)
                elseif (getElementData ( source, "status" ) ==  "throatslashing" ) then
                    local tx,ty,tz = getElementPosition( source )
                    local ptarget = getElementData ( source, "target" )
                    if isElement(ptarget) then
                        local vx,vy,vz = getElementPosition( ptarget )
                        local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz))
                        if (zombdistance < . then
                            zmoan(source)
                            setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true)
                            setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true)
                            setTimer ( Playerthroatbitten, 2300, 1, ptarget, source)
                            setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source )
                        else
                            setElementData ( source, "status", "idle" )
                        end
                    else
                        setElementData ( source, "status", "idle" )
                    end
                end
            elseif (getElementData ( source, "status" ) ==  "dead" ) then
                setTimer ( Zomb_delete, 10000, 1, source)
            end
        end
    end
end)
 
--RESOURCE START/INITIAL SETUP
function outbreak(startedResource)
    newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit")
    if newZombieLimit ~= false then
        if newZombieLimit > ZombieLimit then
            newZombieLimit = ZombieLimit
        end
    else
        newZombieLimit = ZombieLimit
    end
    WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIERS
    if startedResource == getThisResource() then
--      call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOARD
        local allplayers = getElementsByType ( "player" )
        for pKey,thep in ipairs(allplayers) do
            setElementData ( thep, "dangercount", 0 )
        end 
        local alivePlayers = getAlivePlayers ()
        for playerKey, playerValue in ipairs(alivePlayers) do
            setElementData ( playerValue, "alreadyspawned", true  )
        end
        if ZombieSpeed == 2 then
            MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast)
        else
            MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION
        end
        MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS 
        if ZombieStreaming == 1 then
            MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random locations
        elseif ZombieStreaming == 2 then
            MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoints
        end
    end
end
addEventHandler("onResourceStart", getRootElement(), outbreak)
 
function player_Connect()
    setElementData ( source, "dangercount", 0 )
end
addEventHandler ( "onPlayerConnect", getRootElement(), player_Connect )
Link to comment
اهااا

المشكلة من المنتدى

رقم 8 يصير ايقونه و يخرب الكود

.-- s8) --> then 

جرب الحين

ZombieLimit = get("zombies.MaxZombies")-- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM? 
ZombieStreaming = get("zombies.StreamMethod") -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints
ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
--ZombiePedSkins = {7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,36,37,38,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81,82,83,85,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,156,157,158,159,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,210,211,212,213,214,215,216,217,218,219,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,275,276,277,278,279,280,281,282,283,284,285,286,287,288 }
ZombieSpeed = get("zombies.Speed")
if ZombieSpeed == 0 then --super slow zombies (goofy looking)
    chaseanim = "WALK_drunk"
    checkspeed = 2000
elseif ZombieSpeed == 1 then -- normal speed
    chaseanim = "run_old"
    checkspeed = 1000
elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server)
    chaseanim = "Run_Wuzi"
    checkspeed = 680
else -- defaults back to normal
    chaseanim = "run_old"
    checkspeed = 1000
end
resourceRoot = getResourceRootElement()
moancount =0
moanlimit = 10
everyZombie = { }
 
--IDLE BEHAVIOUR OF A ZOMBIE
function Zomb_Idle (ped)
    if isElement(ped) then
        if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) then
            local action = math.random( 1, 6 )
            if action < 4 then -- walk a random direction
                local rdmangle = math.random( 1, 359 )
                setPedRotation( ped, rdmangle )
                setPedAnimation ( ped, "PED", "Player_Sneak", -1, true, true, true)
                setTimer ( Zomb_Idle, 7000, 1, ped )
            elseif action == 4 then -- get on the ground
                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true)
                setTimer ( Zomb_Idle, 4000, 1, ped )
            elseif action == 5 then -- stand still doing nothing
                setPedAnimation ( ped )
                setTimer ( Zomb_Idle, 4000, 1, ped )
            end
        end
    end
end
 
--BEHAVIOUR WHILE CHASING PLAYERS
function Zomb_chase (ped, Zx, Zy, Zz )
    if isElement(ped) then
        if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) then
            local x, y, z = getElementPosition( ped )
            if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false then        
                local Px = getElementData ( ped, "Tx" )
                local Py = getElementData ( ped, "Ty" )
                local Pz = getElementData ( ped, "Tz" )
                local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, x, y, z ))
                if (Pdistance < 1.5 ) then
                    setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                end
            end
            local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz ))           
            if (distance < 1 ) then -- IF THE PED HASNT MOVED
                if (getElementData ( ped, "target" ) == nil) then
                    local giveup = math.random( 1, 15 )
                    if giveup == 1 then
                        setElementData ( ped, "status", "idle" )
                    else
                        local action = math.random( 1, 2 )
                        if action == 1 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                            setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                        elseif action == 2 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                            setTimer ( Zomb_chase, 3500, 1, ped, x, y, z )
                        end
                    end
                else
                    local Ptarget = (getElementData ( ped, "target" ))
                    if isElement(Ptarget) then
                        local Px, Py, Pz = getElementPosition( Ptarget )
                        local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz ))
                        if (Pdistance < 1.2 ) then -- ATTACK A PLAYER IF THEY ARE CLOSE
                            if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYER
                                setPedAnimation ( ped )
                                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, false)
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 10000, 1, ped )
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 10000, 1, ped )
                                zmoan(ped)
                            else
                                local action = math.random( 1, 6 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                else
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        else
                            if ( isPedDead (Ptarget) ) then
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 1800, 1, ped )
                            else
                                local action = math.random( 1, 2 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                elseif action == 2 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        end
                    else
                        setElementData ( ped, "status", "idle" )
                    end
                end
            else
                setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKING
                setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAIN
            end
        end
    end
end
 
--SET THE DIRECTION OF THE ZOMBIE
function setangle ()
    for theKey,ped in ipairs(everyZombie) do
        if isElement(ped) then
            if ( getElementData ( ped, "status" ) == "chasing" ) then
                local x
                local y
                local z
                local px
                local py
                local pz
                if ( getElementData ( ped, "target" ) ~= nil ) then
                    local ptarget = getElementData ( ped, "target" )
                    if isElement(ptarget) then
                        x, y, z = getElementPosition( ptarget )
                        px, py, pz = getElementPosition( ped )
                    else
                        setElementData ( ped, "status", "idle" )
                        x, y, z = getElementPosition( ped )
                        px, py, pz = getElementPosition( ped )
                    end
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUTS
                    x = getElementData ( ped, "Tx" )
                    y = getElementData ( ped, "Ty" )
                    z = getElementData ( ped, "Tz" )
                    px, py, pz = getElementPosition( ped )
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                end
            end
        end
    end
end
 
--SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES
addEventHandler ( "onElementDataChange", getRootElement(),
function ( dataName )
    if getElementType ( source ) == "ped" and dataName == "status" then
        if (getElementData (source, "zombie") == true) then
            if ( isPedDead ( source ) == false ) then
                if (getElementData ( source, "status" ) ==  "chasing" ) then
                    local Zx, Zy, Zz = getElementPosition( source )
                    setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz )
                    local newtarget = (getElementData ( source, "target" ))
                    if isElement (newtarget) then
                        if getElementType ( newtarget ) == "player" then
                            setElementSyncer ( source, newtarget )
                        end
                    end
                    zmoan(source)
                elseif (getElementData ( source, "status" ) ==  "idle" ) then
                    setTimer ( Zomb_Idle, 1000, 1, source)
                elseif (getElementData ( source, "status" ) ==  "throatslashing" ) then
                    local tx,ty,tz = getElementPosition( source )
                    local ptarget = getElementData ( source, "target" )
                    if isElement(ptarget) then
                        local vx,vy,vz = getElementPosition( ptarget )
                        local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz))
                        if (zombdistance < . then
                            zmoan(source)
                            setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true)
                            setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true)
                            setTimer ( Playerthroatbitten, 2300, 1, ptarget, source)
                            setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source )
                        else
                            setElementData ( source, "status", "idle" )
                        end
                    else
                        setElementData ( source, "status", "idle" )
                    end
                end
            elseif (getElementData ( source, "status" ) ==  "dead" ) then
                setTimer ( Zomb_delete, 10000, 1, source)
            end
        end
    end
end)
 
--RESOURCE START/INITIAL SETUP
function outbreak(startedResource)
    newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit")
    if newZombieLimit ~= false then
        if newZombieLimit > ZombieLimit then
            newZombieLimit = ZombieLimit
        end
    else
        newZombieLimit = ZombieLimit
    end
    WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIERS
    if startedResource == getThisResource() then
--      call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOARD
        local allplayers = getElementsByType ( "player" )
        for pKey,thep in ipairs(allplayers) do
            setElementData ( thep, "dangercount", 0 )
        end 
        local alivePlayers = getAlivePlayers ()
        for playerKey, playerValue in ipairs(alivePlayers) do
            setElementData ( playerValue, "alreadyspawned", true  )
        end
        if ZombieSpeed == 2 then
            MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast)
        else
            MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION
        end
        MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS 
        if ZombieStreaming == 1 then
            MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random locations
        elseif ZombieStreaming == 2 then
            MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoints
        end
    end
end
addEventHandler("onResourceStart", getRootElement(), outbreak)
 
function player_Connect()
    setElementData ( source, "dangercount", 0 )
Link to comment
ZombieLimit = get("zombies.MaxZombies")-- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM? 
ZombieStreaming = get("zombies.StreamMethod") -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints
ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
--ZombiePedSkins = {7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,36,37,38,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81,82,83,85,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,156,157,158,159,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,210,211,212,213,214,215,216,217,218,219,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,275,276,277,278,279,280,281,282,283,284,285,286,287,288 }
ZombieSpeed = get("zombies.Speed")
if ZombieSpeed == 0 then --super slow zombies (goofy looking)
    chaseanim = "WALK_drunk"
    checkspeed = 2000
elseif ZombieSpeed == 1 then -- normal speed
    chaseanim = "run_old"
    checkspeed = 1000
elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server)
    chaseanim = "Run_Wuzi"
    checkspeed = 680
else -- defaults back to normal
    chaseanim = "run_old"
    checkspeed = 1000
end
resourceRoot = getResourceRootElement()
moancount =0
moanlimit = 10
everyZombie = { }
 
--IDLE BEHAVIOUR OF A ZOMBIE
function Zomb_Idle (ped)
    if isElement(ped) then
        if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) then
            local action = math.random( 1, 6 )
            if action < 4 then -- walk a random direction
                local rdmangle = math.random( 1, 359 )
                setPedRotation( ped, rdmangle )
                setPedAnimation ( ped, "PED", "Player_Sneak", -1, true, true, true)
                setTimer ( Zomb_Idle, 7000, 1, ped )
            elseif action == 4 then -- get on the ground
                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true)
                setTimer ( Zomb_Idle, 4000, 1, ped )
            elseif action == 5 then -- stand still doing nothing
                setPedAnimation ( ped )
                setTimer ( Zomb_Idle, 4000, 1, ped )
            end
        end
    end
end
 
--BEHAVIOUR WHILE CHASING PLAYERS
function Zomb_chase (ped, Zx, Zy, Zz )
    if isElement(ped) then
        if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) then
            local x, y, z = getElementPosition( ped )
            if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false then        
                local Px = getElementData ( ped, "Tx" )
                local Py = getElementData ( ped, "Ty" )
                local Pz = getElementData ( ped, "Tz" )
                local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, x, y, z ))
                if (Pdistance < 1.5 ) then
                    setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                end
            end
            local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz ))          
            if (distance < 1 ) then -- IF THE PED HASNT MOVED
                if (getElementData ( ped, "target" ) == nil) then
                    local giveup = math.random( 1, 15 )
                    if giveup == 1 then
                        setElementData ( ped, "status", "idle" )
                    else
                        local action = math.random( 1, 2 )
                        if action == 1 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                            setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                        elseif action == 2 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                            setTimer ( Zomb_chase, 3500, 1, ped, x, y, z )
                        end
                    end
                else
                    local Ptarget = (getElementData ( ped, "target" ))
                    if isElement(Ptarget) then
                        local Px, Py, Pz = getElementPosition( Ptarget )
                        local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz ))
                        if (Pdistance < 1.2 ) then -- ATTACK A PLAYER IF THEY ARE CLOSE
                            if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYER
                                setPedAnimation ( ped )
                                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, false)
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 10000, 1, ped )
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 10000, 1, ped )
                                zmoan(ped)
                            else
                                local action = math.random( 1, 6 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                else
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        else
                            if ( isPedDead (Ptarget) ) then
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 1800, 1, ped )
                            else
                                local action = math.random( 1, 2 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                elseif action == 2 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        end
                    else
                        setElementData ( ped, "status", "idle" )
                    end
                end
            else
                setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKING
                setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAIN
            end
        end
    end
end
 
--SET THE DIRECTION OF THE ZOMBIE
function setangle ()
    for theKey,ped in ipairs(everyZombie) do
        if isElement(ped) then
            if ( getElementData ( ped, "status" ) == "chasing" ) then
                local x
                local y
                local z
                local px
                local py
                local pz
                if ( getElementData ( ped, "target" ) ~= nil ) then
                    local ptarget = getElementData ( ped, "target" )
                    if isElement(ptarget) then
                        x, y, z = getElementPosition( ptarget )
                        px, py, pz = getElementPosition( ped )
                    else
                        setElementData ( ped, "status", "idle" )
                        x, y, z = getElementPosition( ped )
                        px, py, pz = getElementPosition( ped )
                    end
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUTS
                    x = getElementData ( ped, "Tx" )
                    y = getElementData ( ped, "Ty" )
                    z = getElementData ( ped, "Tz" )
                    px, py, pz = getElementPosition( ped )
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                end
            end
        end
    end
end
 
--SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES
addEventHandler ( "onElementDataChange", getRootElement(),
function ( dataName )
    if getElementType ( source ) == "ped" and dataName == "status" then
        if (getElementData (source, "zombie") == true) then
            if ( isPedDead ( source ) == false ) then
                if (getElementData ( source, "status" ) ==  "chasing" ) then
                    local Zx, Zy, Zz = getElementPosition( source )
                    setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz )
                    local newtarget = (getElementData ( source, "target" ))
                    if isElement (newtarget) then
                        if getElementType ( newtarget ) == "player" then
                            setElementSyncer ( source, newtarget )
                        end
                    end
                    zmoan(source)
                elseif (getElementData ( source, "status" ) ==  "idle" ) then
                    setTimer ( Zomb_Idle, 1000, 1, source)
                elseif (getElementData ( source, "status" ) ==  "throatslashing" ) then
                    local tx,ty,tz = getElementPosition( source )
                    local ptarget = getElementData ( source, "target" )
                    if isElement(ptarget) then
                        local vx,vy,vz = getElementPosition( ptarget )
                        local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz))
                        if (zombdistance < . then
                            zmoan(source)
                            setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true)
                            setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true)
                            setTimer ( Playerthroatbitten, 2300, 1, ptarget, source)
                            setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source )
                        else
                            setElementData ( source, "status", "idle" )
                        end
                    else
                        setElementData ( source, "status", "idle" )
                    end
                end
            elseif (getElementData ( source, "status" ) ==  "dead" ) then
                setTimer ( Zomb_delete, 10000, 1, source)
            end
        end
    end
end)
 
--RESOURCE START/INITIAL SETUP
function outbreak(startedResource)
    newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit")
    if newZombieLimit ~= false then
        if newZombieLimit > ZombieLimit then
            newZombieLimit = ZombieLimit
        end
    else
        newZombieLimit = ZombieLimit
    end
    WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIERS
    if startedResource == getThisResource() then
--      call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOARD
        local allplayers = getElementsByType ( "player" )
        for pKey,thep in ipairs(allplayers) do
            setElementData ( thep, "dangercount", 0 )
        end
        local alivePlayers = getAlivePlayers ()
        for playerKey, playerValue in ipairs(alivePlayers) do
            setElementData ( playerValue, "alreadyspawned", true  )
        end
        if ZombieSpeed == 2 then
            MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast)
        else
            MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION
        end
        MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS
        if ZombieStreaming == 1 then
            MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random locations
        elseif ZombieStreaming == 2 then
            MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoints
        end
    end
end
addEventHandler("onResourceStart", getRootElement(), outbreak)
 
function player_Connect()
    setElementData ( source, "dangercount", 0 )
end
addEventHandler ( "onPlayerConnect", getRootElement(), player_Connect )
Link to comment
ZombieLimit = get("zombies.MaxZombies")-- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM? 
ZombieStreaming = get("zombies.StreamMethod") -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints
ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,188,195,206,209,212,229,230,258,264,277,280,287 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
--ZombiePedSkins = {7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,36,37,38,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,70,71,72,73,75,76,77,78,79,80,81,82,83,85,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,150,151,152,153,154,155,156,157,158,159,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,209,210,211,212,213,214,215,216,217,218,219,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,275,276,277,278,279,280,281,282,283,284,285,286,287,288 }
ZombieSpeed = get("zombies.Speed")
if ZombieSpeed == 0 then --super slow zombies (goofy looking)
    chaseanim = "WALK_drunk"
    checkspeed = 2000
elseif ZombieSpeed == 1 then -- normal speed
    chaseanim = "run_old"
    checkspeed = 1000
elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server)
    chaseanim = "Run_Wuzi"
    checkspeed = 680
else -- defaults back to normal
    chaseanim = "run_old"
    checkspeed = 1000
end
resourceRoot = getResourceRootElement()
moancount =0
moanlimit = 10
everyZombie = { }
 
--IDLE BEHAVIOUR OF A ZOMBIE
function Zomb_Idle (ped)
    if isElement(ped) then
        if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) then
            local action = math.random( 1, 6 )
            if action < 4 then -- walk a random direction
                local rdmangle = math.random( 1, 359 )
                setPedRotation( ped, rdmangle )
                setPedAnimation ( ped, "PED", "Player_Sneak", -1, true, true, true)
                setTimer ( Zomb_Idle, 7000, 1, ped )
            elseif action == 4 then -- get on the ground
                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true)
                setTimer ( Zomb_Idle, 4000, 1, ped )
            elseif action == 5 then -- stand still doing nothing
                setPedAnimation ( ped )
                setTimer ( Zomb_Idle, 4000, 1, ped )
            end
        end
    end
end
 
--BEHAVIOUR WHILE CHASING PLAYERS
function Zomb_chase (ped, Zx, Zy, Zz )
    if isElement(ped) then
        if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) then
            local x, y, z = getElementPosition( ped )
            if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false then        
                local Px = getElementData ( ped, "Tx" )
                local Py = getElementData ( ped, "Ty" )
                local Pz = getElementData ( ped, "Tz" )
                local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, x, y, z ))
                if (Pdistance < 1.5 ) then
                    setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                end
            end
            local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz ))          
            if (distance < 1 ) then -- IF THE PED HASNT MOVED
                if (getElementData ( ped, "target" ) == nil) then
                    local giveup = math.random( 1, 15 )
                    if giveup == 1 then
                        setElementData ( ped, "status", "idle" )
                    else
                        local action = math.random( 1, 2 )
                        if action == 1 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                            setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                        elseif action == 2 then
                            setPedAnimation ( ped )
                            triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                            setTimer ( Zomb_chase, 3500, 1, ped, x, y, z )
                        end
                    end
                else
                    local Ptarget = (getElementData ( ped, "target" ))
                    if isElement(Ptarget) then
                        local Px, Py, Pz = getElementPosition( Ptarget )
                        local Pdistance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz ))
                        if (Pdistance < 1.2 ) then -- ATTACK A PLAYER IF THEY ARE CLOSE
                            if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYER
                                setPedAnimation ( ped )
                                setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, false)
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 10000, 1, ped )
                                setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 10000, 1, ped )
                                zmoan(ped)
                            else
                                local action = math.random( 1, 6 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                else
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        else
                            if ( isPedDead (Ptarget) ) then
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped )
                            setTimer ( function (ped) if ( isElement ( ped ) ) then setPedRotation ( ped, getPedRotation(ped)-180) end end, 1800, 1, ped )
                            else
                                local action = math.random( 1, 2 )
                                if action == 1 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Punch", getRootElement(), ped )
                                    setTimer ( function (ped) if ( isElement ( ped ) ) then setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true ) end end, 800, 1, ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                elseif action == 2 then
                                    setPedAnimation ( ped)
                                    triggerClientEvent ( "Zomb_Jump", getRootElement(), ped )
                                    setTimer ( Zomb_chase, 2000, 1, ped, x, y, z )
                                end
                            end
                        end
                    else
                        setElementData ( ped, "status", "idle" )
                    end
                end
            else
                setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKING
                setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAIN
            end
        end
    end
end
 
--SET THE DIRECTION OF THE ZOMBIE
function setangle ()
    for theKey,ped in ipairs(everyZombie) do
        if isElement(ped) then
            if ( getElementData ( ped, "status" ) == "chasing" ) then
                local x
                local y
                local z
                local px
                local py
                local pz
                if ( getElementData ( ped, "target" ) ~= nil ) then
                    local ptarget = getElementData ( ped, "target" )
                    if isElement(ptarget) then
                        x, y, z = getElementPosition( ptarget )
                        px, py, pz = getElementPosition( ped )
                    else
                        setElementData ( ped, "status", "idle" )
                        x, y, z = getElementPosition( ped )
                        px, py, pz = getElementPosition( ped )
                    end
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUTS
                    x = getElementData ( ped, "Tx" )
                    y = getElementData ( ped, "Ty" )
                    z = getElementData ( ped, "Tz" )
                    px, py, pz = getElementPosition( ped )
                    zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YOU
                    setPedRotation( ped, zombangle )
                end
            end
        end
    end
end
 
--SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES
addEventHandler ( "onElementDataChange", getRootElement(),
function ( dataName )
    if getElementType ( source ) == "ped" and dataName == "status" then
        if (getElementData (source, "zombie") == true) then
            if ( isPedDead ( source ) == false ) then
                if (getElementData ( source, "status" ) ==  "chasing" ) then
                    local Zx, Zy, Zz = getElementPosition( source )
                    setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz )
                    local newtarget = (getElementData ( source, "target" ))
                    if isElement (newtarget) then
                        if getElementType ( newtarget ) == "player" then
                            setElementSyncer ( source, newtarget )
                        end
                    end
                    zmoan(source)
                elseif (getElementData ( source, "status" ) ==  "idle" ) then
                    setTimer ( Zomb_Idle, 1000, 1, source)
                elseif (getElementData ( source, "status" ) ==  "throatslashing" ) then
                    local tx,ty,tz = getElementPosition( source )
                    local ptarget = getElementData ( source, "target" )
                    if isElement(ptarget) then
                        local vx,vy,vz = getElementPosition( ptarget )
                        local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz))
                        if (zombdistance < . then
                            zmoan(source)
                            setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true)
                            setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true)
                            setTimer ( Playerthroatbitten, 2300, 1, ptarget, source)
                            setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source )
                        else
                            setElementData ( source, "status", "idle" )
                        end
                    else
                        setElementData ( source, "status", "idle" )
                    end
                end
            elseif (getElementData ( source, "status" ) ==  "dead" ) then
                setTimer ( Zomb_delete, 10000, 1, source)
            end
        end
    end
end)
 
--RESOURCE START/INITIAL SETUP
function outbreak(startedResource)
    newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit")
    if newZombieLimit ~= false then
        if newZombieLimit > ZombieLimit then
            newZombieLimit = ZombieLimit
        end
    else
        newZombieLimit = ZombieLimit
    end
    WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIERS
    if startedResource == getThisResource() then
--      call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOARD
        local allplayers = getElementsByType ( "player" )
        for pKey,thep in ipairs(allplayers) do
            setElementData ( thep, "dangercount", 0 )
        end
        local alivePlayers = getAlivePlayers ()
        for playerKey, playerValue in ipairs(alivePlayers) do
            setElementData ( playerValue, "alreadyspawned", true  )
        end
        if ZombieSpeed == 2 then
            MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast)
        else
            MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION
        end
        MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS
        if ZombieStreaming == 1 then
            MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random locations
        elseif ZombieStreaming == 2 then
            MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoints
        end
    end
end
addEventHandler("onResourceStart", getRootElement(), outbreak)
 
function player_Connect()
    setElementData ( source, "dangercount", 0 )
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...