Guest User

client side

a guest
Jan 24th, 2012
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.87 KB | None | 0 0
  1. myZombies = { }
  2. helmetzombies = { 27, 51, 52, 99, 27, 137, 153, 167, 205, 260, 277, 278, 279, 284, 285 }
  3. resourceRoot = getResourceRootElement()
  4.  
  5. --FORCES ZOMBIES TO MOVE ALONG AFTER THEIR TARGET PLAYER DIES
  6. function playerdead ()
  7.     setTimer ( Zomb_release, 4000, 1 )
  8. end
  9. addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), playerdead )
  10.  
  11. function Zomb_release ()
  12.     for k, ped in pairs( myZombies ) do
  13.         if (isElement(ped)) then
  14.             if (getElementData (ped, "zombie") == true) then
  15.                 setElementData ( ped, "target", nil )
  16.                 setElementData ( ped, "status", "idle" )
  17.                 table.remove(myZombies,k)
  18.             end
  19.         end
  20.     end
  21. end
  22.  
  23. --REMOVES A ZOMBIE FROM INFLUENCE AFTER ITS KILLED
  24. function pedkilled ( killer, weapon, bodypart )
  25.     if (getElementData (source, "zombie") == true) and (getElementData (source, "status") ~= "dead" ) then
  26.         setElementData ( source, "target", nil )
  27.         setElementData ( source, "status", "dead" )
  28.     end
  29. end
  30. addEventHandler ( "onClientPedWasted", getRootElement(), pedkilled )
  31.  
  32. --THIS CHECKS ALL ZOMBIES EVERY SECOND TO SEE IF THEY ARE IN SIGHT
  33. function zombie_check ()
  34.     if (getElementData (getLocalPlayer (), "zombie") ~= true) and ( isPlayerDead ( getLocalPlayer () ) == false ) then
  35.         local zombies = getElementsByType ( "ped",getRootElement(),true )
  36.         local Px,Py,Pz = getElementPosition( getLocalPlayer () )
  37.         if isPedDucked ( getLocalPlayer ()) then
  38.             local Pz = Pz-1
  39.         end    
  40.         for theKey,theZomb in ipairs(zombies) do
  41.             if (isElement(theZomb)) then
  42.                 local Zx,Zy,Zz = getElementPosition( theZomb )
  43.                 if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
  44.                     if (getElementData (theZomb, "zombie") == true) then
  45.                         if ( getElementData ( theZomb, "status" ) == "idle" ) then --CHECKS IF AN IDLE ZOMBIE IS IN SIGHT
  46.                             local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false)
  47.                             if (isclear == true) then
  48.                                 setElementData ( theZomb, "status", "chasing" )
  49.                                 setElementData ( theZomb, "target", getLocalPlayer() )
  50.                                 table.insert( myZombies, theZomb ) --ADDS ZOMBIE TO PLAYERS COLLECTION
  51.                                 table.remove( zombies, theKey)
  52.                                 zombieradiusalert (theZomb)
  53.                             end
  54.                         elseif (getElementData(theZomb,"status") == "chasing") and (getElementData(theZomb,"target") == nil) then --CHECKS IF AN AGGRESSIVE LOST ZOMBIE IS IN SIGHT
  55.                             local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false)
  56.                             if (isclear == true) then
  57.                                 setElementData ( theZomb, "target", getLocalPlayer() )
  58.                                 isthere = "no"
  59.                                 for k, ped in pairs( myZombies ) do
  60.                                     if ped == theZomb then
  61.                                         isthere = "yes"
  62.                                     end
  63.                                 end
  64.                                 if isthere == "no" then
  65.                                     table.insert( myZombies, theZomb ) --ADDS THE WAYWARD ZOMBIE TO THE PLAYERS COLLECTION
  66.                                     table.remove( zombies, theKey)
  67.                                 end
  68.                             end
  69.                         elseif ( getElementData ( theZomb, "target" ) == getLocalPlayer() ) then --CHECKS IF AN ALREADY AGGRESSIVE ZOMBIE IS IN SIGHT
  70.                             local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false)
  71.                             if (isclear == false) then --IF YOUR ZOMBIE LOST YOU, MAKES IT REMEMBER YOUR LAST COORDS
  72.                                 setElementData ( theZomb, "target", nil )
  73.                                 triggerServerEvent ("onZombieLostPlayer", theZomb, oldPx, oldPy, oldPz)
  74.                             end
  75.                         end
  76.                     end
  77.                 end
  78.             end
  79.         end
  80.     --this second half is for checking peds and zombies
  81.    
  82.         local nonzombies = getElementsByType ( "ped",getRootElement(),true )
  83.         for theKey,theZomb in ipairs(zombies) do
  84.             if (isElement(theZomb)) then
  85.                 if (getElementData (theZomb, "zombie") == true) then
  86.                     local Zx,Zy,Zz = getElementPosition( theZomb )
  87.                     for theKey,theNonZomb in ipairs(nonzombies) do
  88.                         if (getElementData (theNonZomb, "zombie") ~= true) then -- if the ped isnt a zombie
  89.                             local Px,Py,Pz = getElementPosition( theNonZomb )
  90.                             if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
  91.                                 local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz +1, true, false, false, true, false, false, false )
  92.                                 if (isclear == true) and ( getElementHealth ( theNonZomb ) > 0) then
  93.                                     if ( getElementData ( theZomb, "status" ) == "idle" ) then --CHECKS IF AN IDLE ZOMBIE IS IN SIGHT
  94.                                         triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)                                 
  95.                                         setElementData ( theZomb, "status", "chasing" )
  96.                                         setElementData ( theZomb, "target", theNonZomb )
  97.                                         zombieradiusalert (theZomb)
  98.                                     elseif ( getElementData ( theZomb, "status" ) == "chasing" ) and ( getElementData ( theZomb, "target" ) == nil) then
  99.                                         triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)
  100.                                         setElementData ( theZomb, "target", theNonZomb )                                   
  101.                                     end
  102.                                 end                
  103.                             end    
  104.                             if ( getElementData ( theZomb, "target" ) == theNonZomb ) then --CHECKS IF AN ALREADY AGGRESSIVE ZOMBIE IS IN SIGHT OF THE PED
  105.                                 local Px,Py,Pz = getElementPosition( theNonZomb )
  106.                                 if (getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) < 45 ) then
  107.                                     local isclear = isLineOfSightClear (Px, Py, Pz+1, Zx, Zy, Zz+1, true, false, false, true, false, false, false)
  108.                                     if (isclear == false) then --IF YOUR ZOMBIE LOST THE PED, MAKES IT REMEMBER the peds LAST COORDS
  109.                                         triggerServerEvent ("onZombieLostPlayer", theZomb, Px, Py, Pz)                         
  110.                                         setElementData ( theZomb, "target", nil )
  111.                                     end
  112.                                 end
  113.                             end
  114.                         end
  115.                     end
  116.                 end
  117.             end
  118.         end
  119.     end
  120.     for k, ped in pairs( myZombies ) do
  121.         if (isElement(ped) == false) then
  122.             table.remove( myZombies, k)
  123.         end
  124.     end
  125.     oldPx,oldPy,oldPz = getElementPosition( getLocalPlayer () )
  126. end
  127.  
  128.  
  129. --INITAL SETUP
  130.  
  131. function clientsetupstarter(startedresource)
  132. if startedresource == getThisResource() then
  133. setTimer ( clientsetup, 1234, 1)
  134. MainClientTimer1 = setTimer ( zombie_check, 1000, 0) --STARTS THE TIMER TO CHECK FOR ZOMBIES
  135. expLabel = guiCreateLabel(0.777,0.22,0.1708,0.0963,"EXP gained: ??\nTotal EXP: ??\nLevel: Unknown",true) -- Start EXP and level system
  136. guiLabelSetColor(expLabel,0,255,0)
  137. guiLabelSetVerticalAlign(expLabel,"top")
  138. guiLabelSetHorizontalAlign(expLabel,"left",false)
  139. guiSetFont(expLabel,"clear-normal")
  140. end
  141. end
  142.  
  143. local ttlgnd = 0
  144. function expChange(expr,gained)
  145. ttlgnd = ttlgnd+gained
  146. guiSetText(expLabel,"")
  147. local level,levelnum = "#0 - Newbie",0
  148. if expr >= 10 then level = "#1 - Novice" levelnum = 1 end
  149. if expr >= 20 then level = "#2 - Average" levelnum = 2 end
  150. if expr >= 100 then level = "#3 - Good" levelnum = 3 end
  151. if expr >= 200 then level = "#4 - Killer" levelnum = 4 end
  152. if expr >= 500 then level = "#5 - Skilled" levelnum = 5 end
  153. if expr >= 1000 then level = "#6 - Elite" levelnum = 6 end
  154. if expr >= 2000 then level = "#7 - Senior" levelnum = 7 end
  155. if expr >= 3000 then level = "#8 - Amazing" levelnum = 8 end
  156. if expr >= 5000 then level = "#9 - Pro" levelnum = 9 end
  157. if expr >= 10000 then level = "#10 - Godlike" levelnum = 10 end
  158. if expr >= 20000 then level = "#11 - God" levelnum = 11 end
  159. guiSetText(expLabel,"EXP gained: "..ttlgnd.." (+"..gained..")\nTotal EXP: "..expr.."\nLevel: "..level)
  160. setElementData(getLocalPlayer(),"Level",level)
  161. setElementData(getLocalPlayer(),"levelnum",levelnum)
  162. end
  163. addEvent( "expOnChange", true )
  164. addEventHandler( "expOnChange", getRootElement(), expChange )
  165. addEventHandler("onClientResourceStart", getRootElement(), clientsetupstarter)
  166.  
  167. function clientsetup()
  168.     oldPx,oldPy,oldPz = getElementPosition( getLocalPlayer () )
  169.     throatcol = createColSphere ( 0, 0, 0, .3)
  170.     woodpic = guiCreateStaticImage( .65, .06, .1, .12, "zombiewood.png", true )
  171.     guiSetVisible ( woodpic, false )
  172.  
  173. --ALL ZOMBIES STFU
  174.     local zombies = getElementsByType ( "ped" )
  175.     for theKey,theZomb in ipairs(zombies) do
  176.         if (isElement(theZomb)) then
  177.             if (getElementData (theZomb, "zombie") == true) then
  178.                 setPedVoice(theZomb, "PED_TYPE_DISABLED")
  179.             end
  180.         end
  181.     end
  182.    
  183. --SKIN REPLACEMENTS
  184.     local skin = engineLoadTXD ( "skins/13.txd" ) --bleedin eyes 31 by Slothman
  185.     engineImportTXD ( skin, 13 )
  186.     local skin = engineLoadTXD ( "skins/22.txd" ) -- slashed 12 by Wall-E
  187.     engineImportTXD ( skin, 22 )   
  188.     local skin = engineLoadTXD ( "skins/56.txd" ) --young and blue by Slothman
  189.     engineImportTXD ( skin, 56 )
  190.     local skin = engineLoadTXD ( "skins/67.txd" ) -- slit r* employee
  191.     engineImportTXD ( skin, 67 )
  192.     local skin = engineLoadTXD ( "skins/68.txd" ) -- shredded preist by Deixell
  193.     engineImportTXD ( skin, 68 )
  194.     local skin = engineLoadTXD ( "skins/69.txd" ) --bleedin eyes in denim by Capitanazop
  195.     engineImportTXD ( skin, 69 )
  196.     local skin = engineLoadTXD ( "skins/70.txd" ) --ultra gory scientist by 50p
  197.     engineImportTXD ( skin, 70 )
  198.     local skin = engineLoadTXD ( "skins/84.txd" ) --guitar wolf (nonzombie) by Slothman
  199.     engineImportTXD ( skin, 84 )
  200.     local skin = engineLoadTXD ( "skins/92.txd" ) -- peeled flesh by xbost
  201.     engineImportTXD ( skin, 92 )
  202.     local skin = engineLoadTXD ( "skins/97.txd" ) -- easterboy by Slothman
  203.     engineImportTXD ( skin, 97 )
  204.     local skin = engineLoadTXD ( "skins/105.txd" ) --Scarred Grove Gangster by Wall-E
  205.     engineImportTXD ( skin, 105 )
  206.     local skin = engineLoadTXD ( "skins/107.txd" ) --ripped and slashed grove by Wall-E
  207.     engineImportTXD ( skin, 107 )
  208.     local skin = engineLoadTXD ( "skins/108.txd" ) -- skeleton thug by Deixell
  209.     engineImportTXD ( skin, 108 )
  210.     local skin = engineLoadTXD ( "skins/111.txd" ) --Frank West from dead rising (nonzombie) by Slothman
  211.     engineImportTXD ( skin, 111 )
  212.     local skin = engineLoadTXD ( "skins/126.txd" ) -- bullet ridden wiseguy by Slothman
  213.     engineImportTXD ( skin, 126 )
  214.     local skin = engineLoadTXD ( "skins/127.txd" ) --flyboy from dawn of the dead by Slothman
  215.     engineImportTXD ( skin, 127 )
  216.     local skin = engineLoadTXD ( "skins/128.txd" ) --holy native by Slothman
  217.     engineImportTXD ( skin, 128 )
  218.     local skin = engineLoadTXD ( "skins/152.txd" ) --bitten schoolgirl by Slothman
  219.     engineImportTXD ( skin, 152 )
  220.     local skin = engineLoadTXD ( "skins/162.txd" ) --shirtless redneck by Slothman
  221.     engineImportTXD ( skin, 162 )
  222.     local skin = engineLoadTXD ( "skins/167.txd" ) --dead chickenman by 50p
  223.     engineImportTXD ( skin, 167 )
  224.     local skin = engineLoadTXD ( "skins/188.txd" ) --burnt greenshirt by Slothman
  225.     engineImportTXD ( skin, 188 )
  226.     local skin = engineLoadTXD ( "skins/192.txd" ) --Alice from resident evil (nonzombie) by Slothman
  227.     engineImportTXD ( skin, 192 )
  228.     local skin = engineLoadTXD ( "skins/195.txd" ) --bloody ex by Slothman
  229.     engineImportTXD ( skin, 195 )
  230.     local skin = engineLoadTXD ( "skins/206.txd" ) -- faceless zombie by Slothman
  231.     engineImportTXD ( skin, 206 )
  232.     local skin = engineLoadTXD ( "skins/209.txd" ) --Noodle vendor by 50p
  233.     engineImportTXD ( skin, 209 )
  234.     local skin = engineLoadTXD ( "skins/212.txd" ) --brainy hobo by Slothman
  235.     engineImportTXD ( skin, 212 )
  236.     local skin = engineLoadTXD ( "skins/229.txd" ) --infected tourist by Slothman
  237.     engineImportTXD ( skin, 229 )
  238.     local skin = engineLoadTXD ( "skins/230.txd" ) --will work for brains hobo by Slothman
  239.     engineImportTXD ( skin, 230 )
  240.     local skin = engineLoadTXD ( "skins/258.txd" ) --bloody sided suburbanite by Slothman
  241.     engineImportTXD ( skin, 258 )
  242.     local skin = engineLoadTXD ( "skins/264.txd" ) --scary clown by 50p
  243.     engineImportTXD ( skin, 264 )
  244.     local skin = engineLoadTXD ( "skins/274.txd" ) --Ash Williams (nonzombie) by Slothman
  245.     engineImportTXD ( skin, 274 )
  246.     local skin = engineLoadTXD ( "skins/277.txd" ) -- gutted firefighter by Wall-E
  247.     engineImportTXD ( skin, 277 )
  248.     local skin = engineLoadTXD ( "skins/280.txd" ) --infected cop by Lordy
  249.     engineImportTXD ( skin, 280 )
  250.     local skin = engineLoadTXD ( "skins/287.txd" ) --torn army by Deixell
  251.     engineImportTXD ( skin, 287 )
  252. end
  253.  
  254. --UPDATES PLAYERS COUNT OF AGGRESIVE ZOMBIES
  255. addEventHandler ( "onClientElementDataChange", getRootElement(),
  256. function ( dataName )
  257.     if getElementType ( source ) == "ped" and dataName == "status" then
  258.         local thestatus = (getElementData ( source, "status" ))
  259.         if (thestatus == "idle") or (thestatus == "dead") then     
  260.             for k, ped in pairs( myZombies ) do
  261.                 if ped == source and (getElementData (ped, "zombie") == true) then
  262.                     setElementData ( ped, "target", nil )
  263.                     table.remove( myZombies, k)
  264.                     setElementData ( getLocalPlayer(), "dangercount", tonumber(table.getn( myZombies )) )
  265.                 end
  266.             end
  267.         end
  268.     end
  269. end )
  270.  
  271. --MAKES A ZOMBIE JUMP
  272. addEvent( "Zomb_Jump", true )
  273. function Zjump ( ped )
  274.     if (isElement(ped)) then
  275.         setPedControlState( ped, "jump", true )
  276.         setTimer ( function (ped) if ( isElement ( ped ) ) then setPedControlState ( ped, "jump", false) end end, 800, 1, ped )
  277.     end
  278. end
  279. addEventHandler( "Zomb_Jump", getRootElement(), Zjump )
  280.  
  281. --MAKES A ZOMBIE PUNCH
  282. addEvent( "Zomb_Punch", true )
  283. function Zpunch ( ped )
  284.     if (isElement(ped)) then
  285.         setPedControlState( ped, "fire", true )
  286.         setTimer ( function (ped) if ( isElement ( ped ) ) then setPedControlState ( ped, "fire", false) end end, 800, 1, ped )
  287.     end
  288. end
  289. addEventHandler( "Zomb_Punch", getRootElement(), Zpunch )
  290.  
  291. --MAKES A ZOMBIE STFU
  292. addEvent( "Zomb_STFU", true )
  293. function Zstfu ( ped )
  294.     if (isElement(ped)) then
  295.         setPedVoice(ped, "PED_TYPE_DISABLED")
  296.     end
  297. end
  298. addEventHandler( "Zomb_STFU", getRootElement(), Zstfu )
  299.  
  300. --MAKES A ZOMBIE MOAN
  301. addEvent( "Zomb_Moan", true )
  302. function Zmoan ( ped, randnum )
  303.     if (isElement(ped)) then
  304.         local Zx,Zy,Zz = getElementPosition( ped )
  305.         local sound = playSound3D("sounds/mgroan"..randnum..".ogg", Zx, Zy, Zz, false)
  306.         setSoundMaxDistance(sound, 20)
  307.     end
  308. end
  309. addEventHandler( "Zomb_Moan", getRootElement(), Zmoan )
  310.  
  311. --ZOMBIE HEADSHOTS TO ALL BUT HELMETED ZOMBIES
  312. function zombiedamaged ( attacker, weapon, bodypart )
  313.     if getElementType ( source ) == "ped" then
  314.         if (getElementData (source, "zombie") == true) then
  315.             if ( bodypart == 9 ) then
  316.                 helmeted = "no"
  317.                 local zskin = getElementModel ( source )
  318.                 for k, skin in pairs( helmetzombies ) do
  319.                     if skin == zskin then
  320.                         helmeted = "yes"
  321.                     end
  322.                 end
  323.                 if helmeted == "no" then
  324.                     triggerServerEvent ("headboom", source, source, attacker, weapon, bodypart )
  325.                 end
  326.             end
  327.         end
  328.     end
  329. end
  330. addEventHandler ( "onClientPedDamage", getRootElement(), zombiedamaged )
  331.  
  332. function zombiedkilled(killer, weapon, bodypart)
  333.     if getElementType ( source ) == "ped" then
  334.         if (getElementData (source, "zombie") == true) then
  335.             setElementCollisionsEnabled(source, false)
  336.         end
  337.     end
  338. end
  339. addEventHandler ( "onClientPedWasted", getRootElement(), zombiedkilled )
  340.  
  341. --CAUSES MORE DAMAGE TO PLAYER WHEN ATTACKED BY A ZOMBIE
  342. function zombieattack ( attacker, weapon, bodypart )
  343.     if (attacker) then
  344.         if getElementType ( attacker ) == "ped" then
  345.             if (getElementData (attacker, "zombie") == true) then
  346.                 local playerHealth = getElementHealth ( getLocalPlayer() )
  347.                 if playerHealth > 15 then
  348.                     setElementHealth ( source, playerHealth - 15 )
  349.                 else
  350.                     triggerServerEvent ("playereaten", source, source, attacker, weapon, bodypart )
  351.                 end
  352.             end
  353.         end
  354.     end
  355. end
  356. addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), zombieattack )
  357.  
  358. --WOOD GUI
  359. function showwoodpic ( theElement, matchingDimension )
  360.     if ( theElement == getLocalPlayer() ) and (getElementData ( source, "purpose" ) == "zombiewood" ) then
  361.         guiSetVisible ( woodpic, true )
  362.     end
  363. end
  364. addEventHandler ( "onClientColShapeHit", getRootElement(), showwoodpic )
  365.  
  366. function hidewoodpic ( theElement, matchingDimension )
  367.     if ( theElement == getLocalPlayer() ) and (getElementData ( source, "purpose" ) == "zombiewood" ) then
  368.         guiSetVisible ( woodpic, false )
  369.     end
  370. end
  371. addEventHandler ( "onClientColShapeLeave", getRootElement(), hidewoodpic )
  372.  
  373. --ZOMBIES ATTACK FROM BEHIND AND GUI STUFF
  374. function movethroatcol ()
  375.     local screenWidth, screenHeight = guiGetScreenSize()
  376.     local dcount = tostring(table.getn( myZombies ))
  377.     dxDrawText( dcount, screenWidth-40, screenHeight -50, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.44, "pricedown" )
  378.     dxDrawText( dcount, screenWidth-42, screenHeight -52, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1.4, "pricedown" )
  379.    
  380.     if isElement(throatcol) then
  381.         local playerrot = getPedRotation ( getLocalPlayer () )
  382.         local radRot = math.rad ( playerrot )
  383.         local radius = 1
  384.         local px,py,pz = getElementPosition( getLocalPlayer () )
  385.         local tx = px + radius * math.sin(radRot)
  386.         local ty = py + -(radius) * math.cos(radRot)
  387.         local tz = pz
  388.         setElementPosition ( throatcol, tx, ty, tz )
  389.     end
  390. end
  391. addEventHandler ( "onClientRender", getRootElement(), movethroatcol )
  392.  
  393. function choketheplayer ( theElement, matchingDimension )
  394.     if getElementType ( theElement ) == "ped" and ( isPlayerDead ( getLocalPlayer () ) == false ) then
  395.         if ( getElementData ( theElement, "target" ) == getLocalPlayer () ) and (getElementData (theElement, "zombie") == true) then
  396.             local px,py,pz = getElementPosition( getLocalPlayer () )
  397.             setTimer ( checkplayermoved, 600, 1, theElement, px, py, pz)
  398.         end
  399.     end
  400. end
  401. addEventHandler ( "onClientColShapeHit", getRootElement(), choketheplayer )
  402.  
  403. function checkplayermoved (zomb, px, py, pz)
  404.     if (isElement(zomb)) then
  405.         local nx,ny,nz = getElementPosition( getLocalPlayer () )
  406.         local distance = (getDistanceBetweenPoints3D (px, py, pz, nx, ny, nz))
  407.         if (distance < .7) and ( isPlayerDead ( getLocalPlayer () ) == false ) then
  408.             setElementData ( zomb, "status", "throatslashing" )
  409.         end
  410.     end
  411. end
  412.  
  413. --ALERTS ANY IDLE ZOMBIES WITHIN A RADIUS OF 10 WHEN GUNSHOTS OCCUR OR OTHER ZOMBIES GET ALERTED
  414. function zombieradiusalert (theElement)
  415.     local Px,Py,Pz = getElementPosition( theElement )
  416.     local zombies = getElementsByType ( "ped" )
  417.     for theKey,theZomb in ipairs(zombies) do
  418.         if (isElement(theZomb)) then
  419.             if (getElementData (theZomb, "zombie") == true) then
  420.                 if ( getElementData ( theZomb, "status" ) == "idle" ) then
  421.                     local Zx,Zy,Zz = getElementPosition( theZomb )
  422.                     local distance = (getDistanceBetweenPoints3D (Px, Py, Pz, Zx, Zy, Zz))
  423.                     if (distance < 10) and ( isPlayerDead ( getLocalPlayer () ) == false ) then
  424.                         isthere = "no"
  425.                         for k, ped in pairs( myZombies ) do
  426.                             if ped == theZomb then
  427.                                 isthere = "yes"
  428.                             end
  429.                         end
  430.                         if isthere == "no" and (getElementData (getLocalPlayer (), "zombie") ~= true) then
  431.                             if (getElementType ( theElement ) == "ped") then
  432.                                 local isclear = isLineOfSightClear (Px, Py, Pz, Zx, Zy, Zz, true, false, false, true, false, false, false)
  433.                                 if (isclear == true) then
  434.                                     setElementData ( theZomb, "status", "chasing" )
  435.                                     setElementData ( theZomb, "target", getLocalPlayer () )
  436.                                     table.insert( myZombies, theZomb ) --ADDS ZOMBIE TO PLAYERS COLLECTION
  437.                                 end
  438.                             else
  439.                                 setElementData ( theZomb, "status", "chasing" )
  440.                                 setElementData ( theZomb, "target", getLocalPlayer () )
  441.                                 table.insert( myZombies, theZomb ) --ADDS ZOMBIE TO PLAYERS COLLECTION
  442.                             end
  443.                         end
  444.                     end
  445.                 end
  446.             end
  447.         end
  448.     end
  449. end
  450.  
  451. function shootingnoise ( weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement)
  452.     if alertspacer ~= 1 then
  453.         if (weapon == 9) then
  454.             alertspacer = 1
  455.             setTimer ( resetalertspacer, 5000, 1 )
  456.             zombieradiusalert(getLocalPlayer ())
  457.         elseif (weapon > 21) and (weapon ~= 23) then
  458.             alertspacer = 1
  459.             setTimer ( resetalertspacer, 5000, 1 )
  460.             zombieradiusalert(getLocalPlayer ())
  461.         end
  462.     end
  463.     if hitElement then
  464.         if (getElementType ( hitElement ) == "ped") then
  465.             if (getElementData (hitElement, "zombie") == true) then        
  466.                 isthere = "no"
  467.                 for k, ped in pairs( myZombies ) do
  468.                     if ped == hitElement then
  469.                         isthere = "yes"
  470.                     end
  471.                 end
  472.                 if isthere == "no" and (getElementData (getLocalPlayer (), "zombie") ~= true) then
  473.                     setElementData ( hitElement, "status", "chasing" )
  474.                     setElementData ( hitElement, "target", getLocalPlayer () )
  475.                     table.insert( myZombies, hitElement ) --ADDS ZOMBIE TO PLAYERS COLLECTION
  476.                     zombieradiusalert (hitElement)
  477.                 end
  478.             end
  479.         end
  480.     end
  481. end
  482. addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer (), shootingnoise )
  483.  
  484. function resetalertspacer ()
  485.     alertspacer = nil
  486. end
  487.  
  488. function choketheplayer ( theElement, matchingDimension )
  489.     if getElementType ( theElement ) == "ped" and ( isPlayerDead ( getLocalPlayer () ) == false ) and (getElementData (theElement , "zombie") == true) then
  490.         if ( getElementData ( theElement, "target" ) == getLocalPlayer () ) then
  491.             local px,py,pz = getElementPosition( getLocalPlayer () )
  492.             setTimer ( checkplayermoved, 600, 1, theElement, px, py, pz)
  493.         end
  494.     end
  495. end
  496.  
  497. addEvent( "Spawn_Placement", true )
  498. function Spawn_Place(xcoord, ycoord)
  499.     local x,y,z = getElementPosition( getLocalPlayer() )
  500.     local posx = x+xcoord
  501.     local posy = y+ycoord
  502.     local gz = getGroundPosition ( posx, posy, z+500 )
  503.     triggerServerEvent ("onZombieSpawn", getLocalPlayer(), posx, posy, gz+1 )
  504. end
  505. addEventHandler("Spawn_Placement", getRootElement(), Spawn_Place)
Advertisement
Add Comment
Please, Sign In to add comment