Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile()
- return
- end
- FLIES = { }
- local function MakeFly()
- local fly = {
- Pos = LocalPlayer():GetPos() + VectorRand() * 20,
- Vel = Vector(0,0,0),
- Target = LocalPlayer()
- }
- FLIES[#FLIES+1] = fly
- end
- local sounds = {
- "ambient/creatures/flies1.wav",
- "ambient/creatures/flies2.wav",
- "ambient/creatures/flies3.wav",
- "ambient/creatures/flies4.wav",
- "ambient/creatures/flies5.wav",
- }
- hook.Add("Think", "FLIESUpdate", function()
- for k, fly in pairs(FLIES) do
- if(!IsValid(fly.Target)) then
- continue
- end
- if math.random(0,100) == 1 then
- 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))
- end
- fly.Pos = fly.Pos + fly.Vel*FrameTime()
- fly.Vel = fly.Vel + ((fly.Target:EyePos()-fly.Pos-fly.Vel/4)+VectorRand()*80)*FrameTime()*50
- for _, v in pairs(player.GetAll()) do
- if(!IsValid(v)) then
- continue
- end
- if v:GetPos():Distance(fly.Pos) < 200 && math.random(0,1000) == 1 then
- fly.Target = v
- end
- end
- end
- end)
- local Mat = Material("sprites/strider_blackball")
- hook.Add("PostDrawOpaqueRenderables", "FLIESDrawa", function()
- for k, fly in pairs(FLIES) do
- render.SetMaterial(Mat)
- render.DrawSprite(fly.Pos, 0.8, 0.8, Color(0,0,0))
- end
- end)
- local enabled = true
- timer.Create("Fly", 2, 0, function()
- if enabled then
- MakeFly()
- end
- end)
- hook.Add("InitPostEntity", "FLIESInitPostEntity", function()
- if LocalPlayer():GetUserGroup() == "superadmin" || LocalPlayer():GetUserGroup() == "owner" || LocalPlayer():GetUserGroup() == "admin" then
- enabled = false
- end
- end)
- if LocalPlayer():GetUserGroup() == "superadmin" || LocalPlayer():GetUserGroup() == "owner" || LocalPlayer():GetUserGroup() == "admin" then
- enabled = false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement