Advertisement
DortiftoSamurai

Kega | Starfall EX

Apr 9th, 2022 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.77 KB | None | 0 0
  1. --@name Kega
  2. --@author Dick_Inside_Head
  3. --@shared
  4.  
  5. if SERVER then
  6.    
  7.     function SpawnNewKega()
  8.        
  9.         random_count = math.random(5,10)
  10.         real_count = 0
  11.    
  12.         kega = prop.createSent(chip():localToWorld(Vector(0, 0, 20)), chip():localToWorldAngles(Angle(0,0,0)), "sent_soccerball", false)
  13.         kega:setNoDraw( 1 )
  14.         --kega:setUnbreakable( true )
  15.        
  16.         kegaholo = holograms.create( kega:localToWorld(Vector(0, 0, 0) ) , kega:localToWorldAngles(Angle(0,0,0)), "models/props_junk/garbage_plasticbottle003a.mdl" , Vector( 2.5 , 2.5 , 1.5) )
  17.         kegaholo:setParent( kega )
  18.         kegaholo:setColor( Color(255,200,20,200) )
  19.        
  20.         kegaholo2 = holograms.create( kega:localToWorld(Vector(0, 0, 16) ) , kega:localToWorldAngles(Angle(0,0,90)), "models/sprops/geometry/fdisc_12.mdl" , Vector( 0.5 , 1 , 0.5) )
  21.         kegaholo2:setParent( kegaholo )
  22.         kegaholo2:setColor( Color(255,255,255,255) )
  23.         kegaholo2 = holograms.create( kega:localToWorld(Vector(0, 0, 1) ) , kega:localToWorldAngles(Angle(0,0,90)), "models/sprops/geometry/fdisc_12.mdl" , Vector( 0.1 , 9 , 0.1 ) )
  24.         kegaholo2:setParent( kegaholo )
  25.         kegaholo2:setColor( Color(255,100,20,150) )
  26.        
  27.         ThinkForNewKega()
  28.        
  29.     end
  30.    
  31.     local kegaPos,kegaSpeed
  32.    
  33.     function KegaBooom( pos )
  34.    
  35.         local kegaBoom = prop.create( pos , chip():localToWorldAngles(Angle(0,0,0)), "models/props_phx/cannonball_solid.mdl", false)
  36.    
  37.         net.start("playSong")
  38.         net.writeVector( pos )
  39.         net.send()
  40.        
  41.         kegaBoom:setNoDraw( 1 )
  42.         kegaBoom:setSolid( false )
  43.         kegaBoom:breakEnt()
  44.    
  45.     end
  46.    
  47.     local nextCount = 2
  48.    
  49.     function ThinkForNewKega()
  50.         hook.add("think", "checkKegaLife", function()
  51.            
  52.             if isValid(kega) then
  53.                
  54.                 kegaPos = kega:getPos()
  55.                
  56.                 local forward = kega:localToWorld( Vector(1, 0, 0) ) - kegaPos
  57.                 kegaSpeed = kega:getVelocity():dot( forward )
  58.                
  59.                 if timer.curtime() < nextCount then return end    
  60.                
  61.                 if kegaSpeed >= 100 then
  62.                    
  63.                     nextCount= timer.curtime() + 2
  64.                     real_count = real_count + 1
  65.                    
  66.                     print( real_count .. "of" .. random_count )    
  67.                    
  68.                 end
  69.                
  70.                 if real_count == random_count then
  71.                    
  72.                     kega:remove()
  73.                    
  74.                 end
  75.                
  76.             else
  77.                 KegaBooom( kegaPos ) hook.remove("think", "checkKegaLife")
  78.             end
  79.            
  80.            
  81.         end)
  82.     end
  83.    
  84.     timer.create("Tick", 1,0, function()
  85.            
  86.             if !isValid(kega) then
  87.                 SpawnNewKega()
  88.             end
  89.  
  90.     end)
  91.    
  92. else
  93.  
  94.     url = "https://cdn.discordapp.com/attachments/828760088062722068/962460669800759387/tailera1-vzorvalo-naxui-kega-kissvkcom_5Is7piR8.mp3"
  95.     vol = 1
  96.     id = Vector(1,1,1)
  97.    
  98.     local function loadSong(songURL, vector, vols)
  99.         if song then song:stop() end
  100.        
  101.         bass.loadURL(songURL, "3d noblock", function(snd, err, errtxt)
  102.             if snd then
  103.                 song = snd
  104.                 snd:setPos( id )
  105.                 snd:setFade(500, 1000)
  106.                 snd:setVolume(1)
  107.             else
  108.                 print(errtxt)
  109.             end
  110.         end)
  111.  
  112.         --url = nil
  113.     end
  114.  
  115.     net.receive("playSong", function(len)
  116.         --url = net.readString()
  117.         id = net.readVector()
  118.         --print(id)
  119.         loadSong(url, id, vol)
  120.     end)
  121.    
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement