شباب محتاج مساعدة
لدي مود الزومبي ( الكود مذكور اسفل المقال ) لكن اريد ان اعدل عليه ليظهر الزومبي في كل مكان ماعدا داخل مدينة لوس سانتوس
هل يمكنكم مساعدتي ؟
I need a create a safezone
I need a modification to the zombie mod, code at the bottom of the article I want to put all the zombies on the map, except for Los Santos I want Los Santos to be a protected area without zombies, as for all the other areas outside the borders there are many zombies
Server code :
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 spawnpoint
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 = 200
elseif ZombieSpeed == 1 then -- normal spee
chaseanim = "run_old
checkspeed = 100
elseif ZombieSpeed == 2 then -- rocket zombies (possibly stressful on server
chaseanim = "Run_Wuzi
checkspeed = 68
else -- defaults back to norma
chaseanim = "run_old
checkspeed = 100
en
resourceRoot = getResourceRootElement(
moancount =
moanlimit = 1
everyZombie = {
--IDLE BEHAVIOUR OF A ZOMB
function Zomb_Idle (ped
if isElement(ped) the
if ( getElementData ( ped, "status" ) == "idle" ) and ( isPedDead ( ped ) == false ) and (getElementData (ped, "zombie") == true) the
local action = math.random( 1, 6
if action < 4 then -- walk a random directio
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 groun
setPedAnimation ( ped, "MEDIC", "cpr", -1, false, true, true
setTimer ( Zomb_Idle, 4000, 1, ped
elseif action == 5 then -- stand still doing nothin
setPedAnimation ( ped
setTimer ( Zomb_Idle, 4000, 1, ped
en
en
en
en
--BEHAVIOUR WHILE CHASING PLAYE
function Zomb_chase (ped, Zx, Zy, Zz
if isElement(ped) the
if (getElementData ( ped, "status" ) == "chasing") and (getElementData (ped, "zombie") == true) the
local x, y, z = getElementPosition( ped
if (getElementData ( ped, "target" ) == nil) and getElementData ( ped, "Tx" ) ~= false the
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 ) the
setTimer ( function (ped) if ( isElement ( ped ) ) then setElementData ( ped, "status", "idle" ) end end, 2000, 1, ped
en
en
local distance = (getDistanceBetweenPoints3D( x, y, z, Zx, Zy, Zz )
if (distance < 1 ) then -- IF THE PED HASNT MOVE
if (getElementData ( ped, "target" ) == nil) the
local giveup = math.random( 1, 15
if giveup == 1 the
setElementData ( ped, "status", "idle"
els
local action = math.random( 1, 2
if action == 1 the
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 the
setPedAnimation ( ped
triggerClientEvent ( "Zomb_Jump", getRootElement(), ped
setTimer ( Zomb_chase, 3500, 1, ped, x, y, z
en
en
els
local Ptarget = (getElementData ( ped, "target" )
if isElement(Ptarget) the
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 CLOS
if ( isPedDead ( Ptarget ) ) then --EAT A DEAD PLAYE
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
els
local action = math.random( 1, 6
if action == 1 the
setPedAnimation ( ped
triggerClientEvent ( "Zomb_Jump", getRootElement(), ped
setTimer ( Zomb_chase, 2000, 1, ped, x, y, z
els
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
en
en
els
if ( isPedDead (Ptarget) ) the
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
els
local action = math.random( 1, 2
if action == 1 the
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 the
setPedAnimation ( ped
triggerClientEvent ( "Zomb_Jump", getRootElement(), ped
setTimer ( Zomb_chase, 2000, 1, ped, x, y, z
en
en
en
els
setElementData ( ped, "status", "idle"
en
en
els
setPedAnimation ( ped, "ped", chaseanim, -1, true, true, true) --KEEP WALKIN
setTimer ( Zomb_chase, checkspeed, 1, ped, x, y, z ) --CHECK AGAI
en
en
en
en
--SET THE DIRECTION OF THE ZOMB
function setangle (
for theKey,ped in ipairs(everyZombie) d
if isElement(ped) the
if ( getElementData ( ped, "status" ) == "chasing" ) the
local
local
local
local p
local p
local p
if ( getElementData ( ped, "target" ) ~= nil ) the
local ptarget = getElementData ( ped, "target"
if isElement(ptarget) the
x, y, z = getElementPosition( ptarget
px, py, pz = getElementPosition( ped
els
setElementData ( ped, "status", "idle"
x, y, z = getElementPosition( ped
px, py, pz = getElementPosition( ped
en
zombangle = ( 360 - math.deg ( math.atan2 ( ( x - px ), ( y - py ) ) ) ) % 360 --MAGIC SPELL TO MAKE PEDS LOOK AT YO
setPedRotation( ped, zombangle
elseif ( getElementData ( ped, "target" ) == nil ) and (getElementData ( ped, "Tx" ) ~= false) then --IF THE PED IS AFTER THE PLAYERS LAST KNOWN WHEREABOUT
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 YO
setPedRotation( ped, zombangle
en
en
en
en
en
--SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANG
addEventHandler ( "onElementDataChange", getRootElement()
function ( dataName
if getElementType ( source ) == "ped" and dataName == "status" the
if (getElementData (source, "zombie") == true) the
if ( isPedDead ( source ) == false ) the
if (getElementData ( source, "status" ) == "chasing" ) the
local Zx, Zy, Zz = getElementPosition( source
setTimer ( Zomb_chase, 1000, 1, source, Zx, Zy, Zz
local newtarget = (getElementData ( source, "target" )
if isElement (newtarget) the
if getElementType ( newtarget ) == "player" the
setElementSyncer ( source, newtarget
en
en
zmoan(source
elseif (getElementData ( source, "status" ) == "idle" ) the
setTimer ( Zomb_Idle, 1000, 1, source
elseif (getElementData ( source, "status" ) == "throatslashing" ) the
local tx,ty,tz = getElementPosition( source
local ptarget = getElementData ( source, "target"
if isElement(ptarget) the
local vx,vy,vz = getElementPosition( ptarget
local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz)
if (zombdistance < .8) the
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
els
setElementData ( source, "status", "idle"
en
els
setElementData ( source, "status", "idle"
en
en
elseif (getElementData ( source, "status" ) == "dead" ) the
setTimer ( Zomb_delete, 10000, 1, source
en
en
en
end
--RESOURCE START/INITIAL SET
function outbreak(startedResource
newZombieLimit = get("" .. getResourceName(startedResource) .. ".Zlimit"
if newZombieLimit ~= false the
if newZombieLimit > ZombieLimit the
newZombieLimit = ZombieLimi
en
els
newZombieLimit = ZombieLimi
en
WoodTimer = setTimer ( WoodSetup, 2000, 1) -- CHECKS FOR BARRIER
if startedResource == getThisResource() the
-- call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") --ADDS TO SCOREBOAR
local allplayers = getElementsByType ( "player"
for pKey,thep in ipairs(allplayers) d
setElementData ( thep, "dangercount", 0
en
local alivePlayers = getAlivePlayers (
for playerKey, playerValue in ipairs(alivePlayers) d
setElementData ( playerValue, "alreadyspawned", true
en
if ZombieSpeed == 2 the
MainTimer1 = setTimer ( setangle, 200, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION (fast
els
MainTimer1 = setTimer ( setangle, 400, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTIO
en
MainTimer3 = setTimer ( clearFarZombies, 3000, 0) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYER
if ZombieStreaming == 1 the
MainTimer2 = setTimer ( SpawnZombie, 2500, 0 ) --Spawns zombies in random location
elseif ZombieStreaming == 2 the
MainTimer2 = setTimer ( SpawnpointZombie, 2500, 0 ) --spawns zombies in zombie spawnpoint
en
en
en
addEventHandler("onResourceStart", getRootElement(), outbreak
function player_Connect
setElementData ( source, "dangercount", 0
en
addEventHandler ( "onPlayerConnect", getRootElement(), player_Connect
function WoodSetup
local allcols = getElementsByType ( "colshape" ) --clears off old wood col
for colKey, colValue in ipairs(allcols) d
if ( getElementData ( colValue, "purpose" ) =="zombiewood" ) the
destroyElement(colValue
en
en
local allobjects = getElementsByType ( "object" ) --SETS UP ALL THE WOOD BARRIER
for objectKey, objectValue in ipairs(allobjects) d
if ( getElementData ( objectValue, "purpose" ) =="zombiewood" ) the
setElementDimension ( objectValue, 26
local x,y,z = getElementPosition( objectValue
local thecol = createColSphere ( x, y, z, 1.6
setElementData ( thecol, "purpose", "zombiewood"
setElementParent ( thecol, objectValue
en
en
en
function ReduceMoancount
moancount = moancount-
en
function zmoan(zombi
if moancount < moanlimit the
moancount = moancount+
local randnum = math.random( 1, 10
triggerClientEvent ( "Zomb_Moan", getRootElement(), zombie, randnum
setTimer ( ReduceMoancount, 800, 1
en
en
--CLEARS A DEAD ZOMB
function Zomb_delete (ped
if isElement(ped) the
if (getElementData (ped, "zombie") == true) the
for theKey,thePed in ipairs(everyZombie) d
if ped == thePed the
table.remove( everyZombie, theKey
brea
en
en
destroyElement ( ped
en
en
en
--HEADSHO
addEvent( "headboom", true
function Zheadhit ( ped,attacker, weapon, bodypart
if (getElementData (ped, "zombie") == true) the
killPed ( ped, attacker, weapon, bodypart
setPedHeadless ( ped, true
en
en
addEventHandler( "headboom", getRootElement(), Zheadhit
--KILL FROM ZOMBIE ATTA
addEvent( "playereaten", true
function Playerinfected ( player, attacker, weapon, bodypart
killPed ( player, attacker, weapon, bodypart
en
addEventHandler( "playereaten", getRootElement(), Playerinfected
--CHECKS FOR ZOMBIE GRABBING FROM BEHI
function Playerthroatbitten ( player, attacker
local Zx, Zy, Zz = getElementPosition( attacker
local Px, Py, Pz = getElementPosition( player
local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )
if (distance < 1) the
killPed ( player, attacker, weapon, bodypart
els
setPedAnimation (player
en
en
--ADJUSTS PLAYERS ZOMBIE KILL SCO
function deanimated( ammo, attacker, weapon, bodypart
if (attacker) the
if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") the
if (getElementData (source, "zombie") == true) the
local oldZcount = getElementData ( attacker, "Zombie kills"
if oldZcount ~= false the
setElementData ( attacker, "Zombie kills", oldZcount+1
triggerEvent ( "onZombieWasted", source, attacker, weapon, bodypart
els
setElementData ( attacker, "Zombie kills", 1
triggerEvent ( "onZombieWasted", source, attacker, weapon, bodypart
en
en
en
en
en
addEventHandler("onPedWasted", resourceRoot, deanimated
--STUFF TO ALLOW PLAYERS TO PLACE BOAR
function boarditup( player, key, keyState
local rightspot =
local allcols = getElementsByType ( "colshape"
for ColKey,theCol in ipairs(allcols) d
if (getElementData ( theCol, "purpose" ) == "zombiewood" ) the
if (isElementWithinColShape ( player, theCol )) the
local rightcol = theCo
local Cx, Cy, Cz = getElementPosition( rightcol
local Bx, By, Bz = getElementPosition( player
woodangle = ( 360 - math.deg ( math.atan2 ( ( Cx - Bx ), ( Cy - By ) ) ) ) % 36
setPedRotation( player, woodangle
setPedAnimation(player, "riot", "RIOT_PUNCHES", 3000, true, true, true
local wx, wy, wz = getElementPosition( player
setTimer( doneboarding, 2000, 1, player, rightcol, wx, wy, wz
en
en
en
en
addCommandHandler ( "construct", boarditup
function doneboarding(player, rightcol, wx, wy, w
setPedAnimation(player
local newx, newy, newz = getElementPosition( player
local distance = (getDistanceBetweenPoints3D( wx, wy, wz, newx, newy, newz )
if (distance < .7 ) the
newwood = getElementParent ( rightcol
setElementDimension ( newwood, 25
setTimer( setElementDimension, 50, 1, newwood, 0
en
en
--SPAWN ZOMBIE (now can be cancelle
addEvent( "onZombieSpawn", true
function RanSpawn_Z ( gx, gy, gz, rot
local safezone =
local allradars = getElementsByType("radararea"
for theKey,theradar in ipairs(allradars) d
if getElementData(theradar, "zombieProof") == true the
if isInsideRadarArea ( theradar, gx, gy ) the
safezone =
en
en
en
if safezone == 0 the
if table.getn ( everyZombie ) < newZombieLimit the
if not rot the
rot = math.random (1,359
en
randomZskin = math.random ( 1, table.getn ( ZombiePedSkins )
local zomb = createPed( tonumber( ZombiePedSkins[randomZskin] ), gx, gy, gz
if zomb ~= false the
setElementData ( zomb, "zombie", true
table.insert( everyZombie, zomb
setTimer ( function (zomb, rot) if ( isElement ( zomb ) ) then setPedRotation ( zomb, rot ) end end, 500, 1, zomb, rot
setTimer ( function (zomb) if ( isElement ( zomb ) ) then setPedAnimation ( zomb, "ped", chaseanim, -1, true, true, true ) end end, 1000, 1, zomb
setTimer ( function (zomb) if ( isElement ( zomb ) ) then setElementData ( zomb, "status", "idle" ) end end, 2000, 1, zomb
triggerClientEvent ( "Zomb_STFU", getRootElement(), zomb
en
en
en
en
addEventHandler( "onZombieSpawn", getRootElement(), RanSpawn_Z
--SPAWNS ZOMBIES RANDOMLY NEAR PLAY
function SpawnZombie (
local pacecount =
while pacecount < 5 do --4 ZOMBIES AT A TIME TO PREVENT FPS DRO
if (table.getn( everyZombie )+pacecount < newZombieLimit ) and (ZombieStreaming == 1) the
local xcoord =
local ycoord =
local xdirection = math.random(1,2
if xdirection == 1 the
xcoord = math.random(15,40
els
xcoord = math.random(-40,-15
en
local ydirection = math.random(1,2
if ydirection == 1 the
ycoord = math.random(15,40
els
ycoord = math.random(-40,-15
en
local liveplayers = getAlivePlayers (
if (table.getn( liveplayers ) > 0 ) the
local lowestcount = 9999
local lowestguy = ni
for PKey,thePlayer in ipairs(liveplayers) d
if isElement(thePlayer) the
if (getElementData (thePlayer, "dangercount")) and (getElementData(thePlayer, "zombieProof") ~= true) and (getElementData(thePlayer, "alreadyspawned" ) == true) the
if (getElementData (thePlayer, "dangercount") < lowestcount) the
local safezone =
local gx, gy, gz = getElementPosition( thePlayer
local allradars = getElementsByType("radararea"
for theKey,theradar in ipairs(allradars) d
if getElementData(theradar, "zombieProof") == true the
if isInsideRadarArea ( theradar, gx, gy ) the
safezone =
en
en
en
if safezone == 0 the
lowestguy = thePlaye
lowestcount = getElementData (thePlayer, "dangercount"
en
en
en
en
en
pacecount = pacecount+
if isElement(lowestguy) the
triggerClientEvent ( "Spawn_Placement", lowestguy, ycoord, xcoord
els
pacecount = pacecount+
en
els
pacecount = pacecount+
en
els
pacecount = pacecount+
en
en
en
--SPAWNS ZOMBIES IN SPAWNPOINTS NEAR PLAYE
function SpawnpointZombie (
local pacecount =
while pacecount < 6 do --5 ZOMBIES AT A TIME TO PREVENT FPS DRO
if (table.getn( everyZombie )+pacecount < newZombieLimit ) and (ZombieStreaming == 2) the
local liveplayers = getAlivePlayers (
if (table.getn( liveplayers ) > 0 ) the
local lowestcount = 9999
local lowestguy = ni
for PKey,thePlayer in ipairs(liveplayers) do --THIS PART GETS THE PLAYER WITH THE LEAST ZOMBIES ATTACKIN
if (getElementData (thePlayer, "dangercount")) and (getElementData(thePlayer, "zombieProof") ~= true) the
if (getElementData (thePlayer, "dangercount") < lowestcount) the
lowestguy = thePlaye
lowestcount = getElementData (thePlayer, "dangercount"
en
en
en
if isElement(lowestguy) the
local zombiespawns = {
local possiblezombies = getElementsByType ( "Zombie_spawn"
local Px, Py, Pz = getElementPosition( lowestguy
for ZombKey,theZomb in ipairs(possiblezombies) d
local Zx, Zy, Zz = getElementPosition( theZomb
local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )
if (distance < 8) the
table.remove( possiblezombies, ZombKey) --IF SPAWN IS TOO CLOSE TO ANY PLAYE
en
en
local Px, Py, Pz = getElementPosition( lowestguy
for ZombKey2,theZomb2 in ipairs(possiblezombies) d
local Zx, Zy, Zz = getElementPosition( theZomb2
local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )
if (distance < 60) then --AS LONG AS THE SPAWN IS CLOSE ENOUGH TO A PLAYE
table.insert( zombiespawns, theZomb2
en
en
if (table.getn( zombiespawns ) >0 ) then--IF THE LOWEST PLAYER HAS ANY CLOSE SPAWNS,USE ON
local random = math.random ( 1, table.getn ( zombiespawns )
local posX = getElementData(zombiespawns[random], "posX"
local posY = getElementData(zombiespawns[random], "posY"
local posZ = getElementData(zombiespawns[random], "posZ"
local rot = getElementData(zombiespawns[random], "rotZ"
pacecount = pacecount+
triggerEvent ( "onZombieSpawn",zombiespawns[random], posX, posY, posZ, rot
else--IF THE LOWEST PLAYERS DOESNT HAVE ANY SPAWNS, THEN SEE IF ANYONE HAS AN
local zombiespawns = {
local possiblezombies = getElementsByType ( "Zombie_spawn"
local allplayers = getAlivePlayers (
for theKey,thePlayer in ipairs(allplayers) d
local Px, Py, Pz = getElementPosition( thePlayer
for ZombKey,theZomb in ipairs(possiblezombies) d
local Zx, Zy, Zz = getElementPosition( theZomb
local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )
if (distance < 8) the
table.remove( possiblezombies, ZombKey) --IF SPAWN IS TOO CLOSE TO ANY PLAYE
en
en
en
for theKey,thePlayer in ipairs(allplayers) d
local Px, Py, Pz = getElementPosition( thePlayer
for ZombKey2,theZomb2 in ipairs(possiblezombies) d
local Zx, Zy, Zz = getElementPosition( theZomb2
local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )
if (distance < 60) then --AS LONG AS THE SPAWN IS CLOSE ENOUGH TO A PLAYE
table.insert( zombiespawns, theZomb2
en
en
en
if (table.getn( zombiespawns ) >1 ) the
local random = math.random ( 1, table.getn ( zombiespawns )
local posX = getElementData(zombiespawns[random], "posX"
local posY = getElementData(zombiespawns[random], "posY"
local posZ = getElementData(zombiespawns[random], "posZ"
local rot = getElementData(zombiespawns[random], "rotZ"
pacecount = pacecount+
triggerEvent ( "onZombieSpawn",zombiespawns[random], posX, posY, posZ, rot
els
pacecount = pacecount+
en
en
els
pacecount = pacecount+
en
els
pacecount = pacecount+
en
els
pacecount = pacecount+
en
en
en
--DELETES ZOMBIES THAT ARE TOO FAR FROM ANY PLAYERS TO KEEP THEM MORE CONCENTRATED WHILE STREAMING ZOMBI
function clearFarZombies (
if newZombieLimit ~= false the
local toofarzombies = {
local allplayers = getElementsByType ( "player"
for ZombKey,theZomb in ipairs(everyZombie) d
if isElement(theZomb) the
if (getElementData (theZomb, "zombie") == true) the
far =
local Zx, Zy, Zz = getElementPosition( theZomb
for theKey,thePlayer in ipairs(allplayers) d
local Px, Py, Pz = getElementPosition( thePlayer
local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )
if (distance < 75) the
far =
en
en
if far == 1 the
table.insert( toofarzombies, theZomb
en
en
els
table.remove( everyZombie, ZombKey
en
en
if (table.getn( toofarzombies ) >1 ) the
for ZombKey,theZomb in ipairs(toofarzombies) d
if (getElementData (theZomb, "zombie") == true) and ( getElementData ( theZomb, "forcedtoexist" ) ~= true) the
Zomb_delete (theZomb
en
en
en
en
en
-- DESTROYS UP TO 13 ZOMBIES THAT ARE IDLE WHEN A PLAYER SPAWNS (TO FORCE NEW ZOMBIES TO SPAWN NEAR THE NEW GU
function player_Spawn (
if ZombieStreaming == 1 or ZombieStreaming == 2 the
local relocatecount =
for ZombKey,theZomb in ipairs(everyZombie) d
if relocatecount < 14 the
if ( getElementData ( theZomb, "forcedtoexist" ) ~= true) the
if ( getElementData ( theZomb, "status" ) == "idle" ) and ( isPedDead ( theZomb ) == false ) and (getElementData (theZomb, "zombie") == true) the
relocatecount = relocatecount+
Zomb_delete (theZomb
en
en
en
en
en
if ( getElementData ( source, "alreadyspawned" ) ~= true) the
setElementData ( source, "alreadyspawned", true
en
en
addEventHandler ( "onPlayerSpawn", getRootElement(), player_Spawn
--EXPORTED FUNCTIONS!!!!!!!!!!!!
function createZombie ( x, y, z, rot, skin, interior, dimension
if (table.getn( everyZombie ) < newZombieLimit ) the
--this part handles the arg
if not x then return false en
if not y then return false en
if not z then return false en
if not rot the
rot = math.random (1,359
en
if not skin the
randomZskin = math.random ( 1, table.getn ( ZombiePedSkins )
skin = ZombiePedSkins[randomZskin
en
if not interior then interior = 0 en
if not dimension then dimension = 0 en
--this part spawns the pe
local zomb = createPed (tonumber(skin),tonumber(x),tonumber(y),tonumber(z))--spawns the pe
--if successful, this part applies the zombie settings/arg
if (zomb ~= false) the
setTimer ( setElementInterior, 100, 1, zomb, tonumber(interior)) --sets interio
setTimer ( setElementDimension, 100, 1, zomb, tonumber(dimension)) --sets dimensio
setElementData ( zomb, "zombie", true
setElementData ( zomb, "forcedtoexist", true
setTimer ( function (zomb, rot) if ( isElement ( zomb ) ) then setPedRotation ( zomb, rot ) end end, 500, 1, zomb, rot
setTimer ( function (zomb) if ( isElement ( zomb ) ) then setElementData ( zomb, "status", "idle" ) end end, 2000, 1, zomb
setTimer ( function (zomb) if ( isElement ( zomb ) ) then setElementData ( zomb, "forcedtoexist", true ) end end, 1000, 1, zomb
setTimer ( function (zomb) if ( isElement ( zomb ) ) then table.insert( everyZombie, zomb ) end end, 1000, 1, zomb
triggerClientEvent ( "Zomb_STFU", getRootElement(), zomb
return zomb --returns the zombie elemen
els
return false --returns false if there was a proble
en
els
return false --returns false if there was a proble
en
en
--check if a ped is a zombie or n
function isPedZombie(ped
if (isElement(ped)) the
if (getElementData (ped, "zombie") == true) the
return tru
els
return fals
en
els
return fals
en
en
addEvent( "onZombieLostPlayer", true
function ZombieTargetCoords ( x,y,z
setElementData ( source, "Tx", x, false
setElementData ( source, "Ty", y, false
setElementData ( source, "Tz", z, false
en
addEventHandler( "onZombieLostPlayer", getRootElement(), ZombieTargetCoords
)d)))) )ddeedeeenn)otddmedmet)))))))nrnsddddd])nd)ndddsn)!!)dd)nddddd)1nnno0n)Y)ddddd)nondd)edd)ndd0n))o)1nno)}n)ESddd1ed1ed1edd1e)1)))))nddd)R))o)odddRn))o)o))}Y)1)))))Edd)R))o)ddRn))o))}nddd)rnnGl9n)nP0)RSddd1ed1ed1e)n1ddddd)rnddd1nno))0nnnol9n)d)e)n)d)e)n)00nP0)ERS)dddd))))))n))d)nnnddd1nno)0) )d!)dd)))n)))z))dddd))))0))lnno)0)DS)ddddd))e))n)nnn)REdd)e)n))))ND)d)))CK)dd))n))TSddd)ddk)nonn)IEdd)))1ne)d1()ddd)))))noSdd)nos())d)())dddsnsnSdNe)nd)o)d)o)DnSdtedtnn))UP)ddd)ndd)ed)e)))))n))n))n)n)dd)nn)))nnnn),ESddddd)U))))S)Ud)))e))n)nzyxzyxnno)IEddddNGedd)eddd)))n))))n)e))nedd))))e)))n)e)))))RE))n)edd)))n))))n)e)n)nD)dd)n))))n)nn)RSdddd))g))d))))n)nn)IE}00)d0"l0")0"d0"))})s
else
return false --returns false if there was a problem
end
else
return false --returns false if there was a problem
end
end
--check if a ped is a zombie or not
function isPedZombie(ped)
if (isElement(ped)) then
if (getElementData (ped, "zombie") == true) then
return true
else
return false
end
else
return false
end
end
addEvent( "onZombieLostPlayer", true )
function ZombieTargetCoords ( x,y,z )
setElementData ( source, "Tx", x, false )
setElementData ( source, "Ty", y, false )
setElementData ( source, "Tz", z, false )
end
addEventHandler( "onZombieLostPlayer", getRootElement(), ZombieTargetCoords )
Client code : 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 ( isPedDead ( 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
addEventHandler( "Zomb_Jump", getRootElement(), Zjump )
--MAKES A ZOMBIE PUNCH
addEvent( "Zomb_Punch", true )
function Zpunch ( ped )
if (isElement(ped)) then
setPedControlState( ped, "fire", true )
setTimer ( function (ped) if ( isElement ( ped ) ) then setPedControlState ( ped, "fire", false) end end, 800, 1, ped )
end
end
addEventHandler( "Zomb_Punch", getRootElement(), Zpunch )
--MAKES A ZOMBIE STFU
addEvent( "Zomb_STFU", true )
function Zstfu ( ped )
if (isElement(ped)) then
setPedVoice(ped, "PED_TYPE_DISABLED")
end
end
addEventHandler( "Zomb_STFU", getRootElement(), Zstfu )
--MAKES A ZOMBIE MOAN
addEvent( "Zomb_Moan", true )
function Zmoan ( ped, randnum )
if (isElement(ped)) then
local Zx,Zy,Zz = getElementPosition( ped )
local sound = playSound3D("sounds/mgroan"..randnum..".ogg", Zx, Zy, Zz, false)
setSoundMaxDistance(sound, 20)
end
end
addEventHandler( "Zomb_Moan", getRootElement(), Zmoan )
--ZOMBIE HEADSHOTS TO ALL BUT HELMETED ZOMBIES
function zombiedamaged ( attacker, weapon, bodypart )
if getElementType ( source ) == "ped" then
if (getElementData (source, "zombie") == true) then
if ( bodypart == 9 ) then
helmeted = "no"
local zskin = getElementModel ( source )
for k, skin in pairs( helmetzombies ) do
if skin == zskin then
helmeted = "yes"
end
end
if helmeted == "no" then
triggerServerEvent ("headboom", source, source, attacker, weapon, bodypart )
end
end
end
end
end
addEventHandler ( "onClientPedDamage", getRootElement(), zombiedamaged )
function zombiedkilled(killer, weapon, bodypart)
if getElementType ( source ) == "ped" then
if (getElementData (source, "zombie") == true) then
setElementCollisionsEnabled(source, false)
end
end
end
addEventHandler ( "onClientPedWasted", getRootElement(), zombiedkilled )
--CAUSES MORE DAMAGE TO PLAYER WHEN ATTACKED BY A ZOMBIE
function zombieattack ( attacker, weapon, bodypart )
if (attacker) then
if getElementType ( attacker ) == "ped" then
if (getElementData (attacker, "zombie") == true) then
local playerHealth = getElementHealth ( getLocalPlayer() )
if playerHealth > 15 then
setElementHealth ( source, playerHealth - 15 )
else
triggerServerEvent ("playereaten", source, source, attacker, weapon, bodypart )
end
end
end
end
end
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), zombieattack )
--WOOD GUI
function showwoodpic ( theElement, matchingDimension )
if ( theElement == getLocalPlayer() ) and (getElementData ( source, "purpose" ) == "zombiewood" ) then
guiSetVisible ( woodpic, true )
end
end
addEventHandler ( "onClientColShapeHit", getRootElement(), showwoodpic )
function hidewoodpic ( theElement, matchingDimension )
if ( theElement == getLocalPlayer() ) and (getElementData ( source, "purpose" ) == "zombiewood" ) then
guiSetVisible ( woodpic, false )
end
end
addEventHandler ( "onClientColShapeLeave", getRootElement(), hidewoodpic )
--ZOMBIES ATTACK FROM BEHIND AND GUI STUFF
function movethroatcol ()
local screenWidth, screenHeight = guiGetScreenSize()
local dcount = tostring(table.getn( myZombies ))
dxDrawText( dcount, screenWidth-40, screenHeight -50, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.44, "pricedown" )
dxDrawText( dcount, screenWidth-42, screenHeight -52, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1.4, "pricedown" )
if isElement(throatcol) then
local playerrot = getPedRotation ( getLocalPlayer () )
local radRot = math.rad ( playerrot )
local radius = 1
local px,py,pz = getElementPosition( getLocalPlayer () )
local tx = px + radius * math.sin(radRot)
local ty = py + -(radius) * math.cos(radRot)
local tz = pz
setElementPosition ( throatcol, tx, ty, tz )
end
end
addEventHandler ( "onClientRender", getRootElement(), movethroatcol )
function choketheplayer ( theElement, matchingDimension )
if getElementType ( theElement ) == "ped" and ( isPedDead ( getLocalPlayer () ) == false ) then
if ( getElementData ( theElement, "target" ) == getLocalPlayer () ) and (getElementData (theElement, "zombie") == true) then
local px,py,pz = getElementPosition( getLocalPlayer () )
setTimer ( checkplayermoved, 600, 1, theElement, px, py, pz)
end
end
end
addEventHandler ( "onClientColShapeHit", getRootElement(), choketheplayer )
function checkplayermoved (zomb, px, py, pz)
if (isElement(zomb)) then
local nx,ny,nz = getElementPosition( getLocalPlayer () )
local distance = (getDistanceBetweenPoints3D (px, py, pz, nx, ny, nz))
if (distance < .7) and ( isPedDead ( getLocalPlayer () ) == false ) then
setElementData ( zomb, "status", "throatslashing" )
end
end
end
--ALERTS ANY IDLE ZOMBIES WITHIN A RADIUS OF 10 WHEN GUNSHOTS OCCUR OR OTHER ZOMBIES GET ALERTED
function zombieradiusalert (theElement)
local Px,Py,Pz = getElementPosition( theElement )
local zombies = getElementsByType ( "ped" )
for theKey,theZomb in ipairs(zombies) do
if (isElement(theZomb)) then
if (getElementData (theZomb, "zombie") == true) then
if ( getElementData ( theZomb, "status" ) == "idle" ) then
local Zx,Zy,Zz = getElementPosition( theZomb )
local distance = (getDistanceBetweenPoints3D (Px, Py, Pz, Zx, Zy, Zz))
if (distance < 10) and ( isPedDead ( getLocalPlayer () ) == false ) then
isthere = "no"
for k, ped in pairs( myZombies ) do
if ped == theZomb then
isthere = "yes"
end
end
if isthere == "no" and (getElementData (getLocalPlayer (), "zombie") ~= true) then
if (getElementType ( theElement ) == "ped") then
local isclear = isLineOfSightClear (Px, Py, Pz, Zx, Zy, Zz, 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
end
else
setElementData ( theZomb, "status", "chasing" )
setElementData ( theZomb, "target", getLocalPlayer () )
table.insert( myZombies, theZomb ) --ADDS ZOMBIE TO PLAYERS COLLECTION
end
end
end
end
end
end
end
end
function shootingnoise ( weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement)
if alertspacer ~= 1 then
if (weapon == 9) then
alertspacer = 1
setTimer ( resetalertspacer, 5000, 1 )
zombieradiusalert(getLocalPlayer ())
elseif (weapon > 21) and (weapon ~= 23) then
alertspacer = 1
setTimer ( resetalertspacer, 5000, 1 )
zombieradiusalert(getLocalPlayer ())
end
end
if hitElement then
if (getElementType ( hitElement ) == "ped") then
if (getElementData (hitElement, "zombie") == true) then
isthere = "no"
for k, ped in pairs( myZombies ) do
if ped == hitElement then
isthere = "yes"
end
end
if isthere == "no" and (getElementData (getLocalPlayer (), "zombie") ~= true) then
setElementData ( hitElement, "status", "chasing" )
setElementData ( hitElement, "target", getLocalPlayer () )
table.insert( myZombies, hitElement ) --ADDS ZOMBIE TO PLAYERS COLLECTION
zombieradiusalert (hitElement)
end
end
end
end
end
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer (), shootingnoise )
function resetalertspacer ()
alertspacer = nil
end
function choketheplayer ( theElement, matchingDimension )
if getElementType ( theElement ) == "ped" and ( isPedDead ( getLocalPlayer () ) == false ) and (getElementData (theElement , "zombie") == true) then
if ( getElementData ( theElement, "target" ) == getLocalPlayer () ) then
local px,py,pz = getElementPosition( getLocalPlayer () )
setTimer ( checkplayermoved, 600, 1, theElement, px, py, pz)
end
end
end
addEvent( "Spawn_Placement", true )
function Spawn_Place(xcoord, ycoord)
local x,y,z = getElementPosition( getLocalPlayer() )
local posx = x+xcoord
local posy = y+ycoord
local gz = getGroundPosition ( posx, posy, z+500 )
triggerServerEvent ("onZombieSpawn", getLocalPlayer(), posx, posy, gz+1 )
end
addEventHandler("Spawn_Placement", getRootElement(), Spawn_Place)