Advertisement
szymski

Untitled

Jun 24th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. if SERVER then
  2. AddCSLuaFile()
  3. return
  4. end
  5.  
  6. FLIES = { }
  7.  
  8. local function MakeFly()
  9. local fly = {
  10. Pos = LocalPlayer():GetPos() + VectorRand() * 20,
  11. Vel = Vector(0,0,0),
  12. Target = LocalPlayer()
  13. }
  14. FLIES[#FLIES+1] = fly
  15. end
  16.  
  17. local sounds = {
  18. "ambient/creatures/flies1.wav",
  19. "ambient/creatures/flies2.wav",
  20. "ambient/creatures/flies3.wav",
  21. "ambient/creatures/flies4.wav",
  22. "ambient/creatures/flies5.wav",
  23. }
  24.  
  25. hook.Add("Think", "FLIESUpdate", function()
  26. for k, fly in pairs(FLIES) do
  27. if(!IsValid(fly.Target)) then
  28. continue
  29. end
  30.  
  31. if math.random(0,100) == 1 then
  32. EmitSound(sounds[math.random(1,5)], fly.Pos, fly.Target:EntIndex(), CHAN_AUTO, 1+math.random(-0.4,0), 40, 0, 100+math.random(-30,50))
  33. end
  34.  
  35. fly.Pos = fly.Pos + fly.Vel*FrameTime()
  36. fly.Vel = fly.Vel + ((fly.Target:EyePos()-fly.Pos-fly.Vel/4)+VectorRand()*80)*FrameTime()*50
  37.  
  38. for _, v in pairs(player.GetAll()) do
  39. if(!IsValid(v)) then
  40. continue
  41. end
  42. if v:GetPos():Distance(fly.Pos) < 200 && math.random(0,1000) == 1 then
  43. fly.Target = v
  44. end
  45. end
  46. end
  47. end)
  48.  
  49. local Mat = Material("sprites/strider_blackball")
  50.  
  51. hook.Add("PostDrawOpaqueRenderables", "FLIESDrawa", function()
  52. for k, fly in pairs(FLIES) do
  53. render.SetMaterial(Mat)
  54. render.DrawSprite(fly.Pos, 0.8, 0.8, Color(0,0,0))
  55. end
  56. end)
  57.  
  58.  
  59.  
  60.  
  61. local enabled = true
  62.  
  63. timer.Create("Fly", 2, 0, function()
  64. if enabled then
  65. MakeFly()
  66. end
  67. end)
  68.  
  69.  
  70. hook.Add("InitPostEntity", "FLIESInitPostEntity", function()
  71. if LocalPlayer():GetUserGroup() == "superadmin" || LocalPlayer():GetUserGroup() == "owner" || LocalPlayer():GetUserGroup() == "admin" then
  72. enabled = false
  73. end
  74. end)
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. if LocalPlayer():GetUserGroup() == "superadmin" || LocalPlayer():GetUserGroup() == "owner" || LocalPlayer():GetUserGroup() == "admin" then
  87. enabled = false
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement