Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.23 KB | None | 0 0
  1. ZombiePedSkins = {13,22,56} --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
  2. --ZombiePedSkins = {13,22,56,67,68,69,70,92,97,105,107,108,126,127,128,152,162,167,195,206,209,212,229,230,258,264,277,280 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY)
  3.  
  4. setElementData(getRootElement(),"zombiestotal",0)
  5. setElementData(getRootElement(),"zombiesalive",0)
  6. createTeam("Zombies")
  7.  
  8. itemTableZombies = {
  9. {"Обезболивающие",2709,0.5,0,7},
  10. {"Граната",342,1,0,0.5},
  11. {"Доллары",1833,1,0,3},
  12. }
  13.  
  14. function createZombieTable (player)
  15. setElementData(player,"playerZombies",{"no","no","no","no","no","no","no","no","no"})
  16. setElementData(player,"spawnedzombies",0)
  17. end
  18.  
  19. function createZomieForPlayer (x,y,z)
  20. x,y,z = getElementPosition(source)
  21. counter = 0
  22. if getElementData(source,"lastzombiespawnposition") then
  23. local xL,yL,zL = getElementData(source,"lastzombiespawnposition")[1] or false,getElementData(source,"lastzombiespawnposition")[2] or false,getElementData(source,"lastzombiespawnposition")[3] or false
  24. if xL and getDistanceBetweenPoints3D (x,y,z,xL,yL,zL) < 50 then return end
  25. end
  26. if getElementData(source,"spawnedzombies")+3 <= gameplayVariables["playerzombies"] then
  27. for i = 1, gameplayVariables["amountzombies"] do
  28. counter = counter+1
  29. local number1 = math.random(-50,50)
  30. local number2 = math.random(-50,50)
  31. if number1 < 18 and number1 > -18 then
  32. number1 = 20
  33. end
  34. if number2 < 18 and number2 > -18 then
  35. number2 = -20
  36. end
  37. randomZskin = math.random ( 1, table.getn ( ZombiePedSkins ) )
  38. zombie = call (getResourceFromName("slothbot"),"spawnBot",x+number1,y+number2,z,math.random(0,360),ZombiePedSkins[randomZskin],0,0,getTeamFromName("Zombies"))
  39. setElementData(zombie,"zombie",true)
  40. setElementData(zombie,"blood",gameplayVariables["zombieblood"])
  41. setElementData(zombie,"owner",source)
  42. call ( getResourceFromName ( "slothbot" ), "setBotGuard", zombie, x+number1,y+number2,z, false)
  43. end
  44. setElementData(source,"lastzombiespawnposition",{x,y,z})
  45. setElementData(source,"spawnedzombies",getElementData(source,"spawnedzombies")+3)
  46. end
  47. end
  48. addEvent("createZomieForPlayer",true)
  49. addEventHandler("createZomieForPlayer",getRootElement(),createZomieForPlayer)
  50.  
  51. function zombieCheck1 ()
  52. for i,ped in ipairs(getElementsByType("ped")) do
  53. if getElementData(ped,"zombie") then
  54. goReturn = false
  55. local zombieCreator = getElementData(ped,"owner")
  56. if not isElement(zombieCreator) then
  57. setElementData ( ped, "status", "dead" )
  58. setElementData ( ped, "target", nil )
  59. setElementData ( ped, "leader", nil )
  60. destroyElement(ped)
  61. goReturn = true
  62. end
  63. if not goReturn then
  64. local xZ,yZ,zZ = getElementPosition(getElementData(ped,"owner"))
  65. local x,y,z = getElementPosition(ped)
  66. if getDistanceBetweenPoints3D (x,y,z,xZ,yZ,zZ) > 60 then
  67. if getElementData(zombieCreator,"spawnedzombies")-1 >= 0 then
  68. setElementData(zombieCreator,"spawnedzombies",getElementData(zombieCreator,"spawnedzombies")-1)
  69. end
  70. setElementData ( ped, "status", "dead" )
  71. setElementData ( ped, "target", nil )
  72. setElementData ( ped, "leader", nil )
  73. destroyElement(ped)
  74. end
  75. end
  76. end
  77. end
  78. end
  79. setTimer(zombieCheck1,20000,0)
  80.  
  81.  
  82. function botAttack (ped)
  83. call ( getResourceFromName ( "slothbot" ), "setBotFollow", ped, source)
  84. end
  85. addEvent("botAttack",true)
  86. addEventHandler("botAttack",getRootElement(),botAttack)
  87.  
  88. function botStopFollow (ped)
  89. local x,y,z = getElementPositon(ped)
  90. call ( getResourceFromName ( "slothbot" ), "setBotGuard", ped, x, y, z, true)
  91. end
  92. addEvent("botStopFollow",true)
  93. addEventHandler("botStopFollow",getRootElement(),botStopFollow)
  94.  
  95. function outputChange(dataName,oldValue)
  96. if getElementType(source) == "player" then -- check if the element is a player
  97. if dataName == "spawnedzombies" then
  98. local newValue = getElementData(source,dataName) -- find the new value
  99. outputChatBox(oldValue.." to "..newValue) -- output the change for the affected player
  100. end
  101. end
  102. end
  103.  
  104. function destroyTable ()
  105. for i,ped in ipairs(getElementsByType("ped")) do
  106. if getElementData(ped,"zombie") then
  107. if getElementData(ped,"owner") == source then
  108. setElementData(getElementData(ped,"owner"),"spawnedzombies",getElementData(getElementData(ped,"owner"),"spawnedzombies")-1)
  109. setElementData ( ped, "status", "dead" )
  110. setElementData ( ped, "target", nil )
  111. setElementData ( ped, "leader", nil )
  112. destroyElement(ped)
  113. end
  114. end
  115. end
  116. end
  117.  
  118. function destroyDeadZombie (ped,pedCol)
  119. destroyElement(ped)
  120. destroyElement(pedCol)
  121. end
  122.  
  123. function zombieKilled (killer,headshot)
  124. if killer then
  125. setElementData(killer,"zombieskilled",getElementData(killer,"zombieskilled")+1)
  126. givePlayerXP ( killer, gameplayVariables["zobiekillxp"] )
  127. end
  128. local skin = getElementModel(source)
  129. local x,y,z = getElementPosition(source)
  130. local ped = createPed(skin,x,y,z)
  131. local pedCol = createColSphere(x,y,z,1.5)
  132. killPed(ped)
  133. setTimer(destroyDeadZombie,360000 ,1,ped,pedCol)
  134. attachElements (pedCol,ped,0,0,0)
  135. setElementData(pedCol,"parent",ped)
  136. setElementData(pedCol,"playername","Zombie")
  137. setElementData(pedCol,"deadman",true)
  138. setElementData(ped,"deadzombie",true)
  139. setElementData(pedCol,"deadman",true)
  140. local time = getRealTime()
  141. local hours = time.hour
  142. local minutes = time.minute
  143. setElementData(pedCol,"deadreason","Зомби был окончательно убит: "..hours..":"..minutes..".")
  144. for i, item in ipairs(itemTableZombies) do
  145. local value = math.percentChance (item[5]/2.5,1)
  146. setElementData(pedCol,item[1],value)
  147. setElementData(pedCol,"Доллары",math.random(0,1))
  148. local ammoData,weapID = getWeaponAmmoType (item[1],true)
  149. if ammoData and value > 0 then
  150. setElementData(pedCol,ammoData,1)
  151. end
  152. end
  153. local zombieCreator = getElementData(source,"owner")
  154. setElementData(zombieCreator,"spawnedzombies",getElementData(zombieCreator,"spawnedzombies")-1)
  155. destroyElement(source)
  156. if headshot == true then
  157. setPedHeadless ( ped, true )
  158. setElementData(killer,"headshots",getElementData(killer,"headshots")+1)
  159. end
  160. end
  161. addEvent("onZombieGetsKilled",true)
  162. addEventHandler("onZombieGetsKilled",getRootElement(),zombieKilled)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement