DortiftoSamurai

Cringe MP3 Player | Starfall EX

Jun 23rd, 2022 (edited)
761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.56 KB | None | 0 0
  1. --@name MP3 Player ebat
  2. --@author Dick_Inside_Head + Sad
  3.  
  4.  
  5. if SERVER then
  6.  
  7.     local weapon_to_takebox = {
  8.         ["none"] = true,
  9.         ["weapon_empty_hands"] = true,
  10.        
  11.     }
  12.    
  13.     --chip():setPos( chip():localToWorld(Vector(0,0,50)) )
  14.    
  15.     chip():setAngles( Angle(0,0,0) )
  16.    
  17.     local PlayerHandler = nil
  18.    
  19.     MainBase= prop.create(chip():getPos()+Vector(0,0,10),Angle(0,0,0),"models/sprops/cuboids/height06/size_1/cube_6x18x6.mdl", 0 )
  20.     MainBase:setColor( Color(0, 0, 0, 0) )
  21.     MainBase:setMass(600)
  22.    
  23.     MainHolo = holograms.create(MainBase:getPos(),Angle(0,0,0),"models/sprops/cuboids/height06/size_1/cube_6x18x6.mdl")
  24.     MainHolo:setParent(MainBase)
  25.     MainHolo:setColor( Color(0, 0, 0, 255) )
  26.    
  27.     --chip():setParent( MainBase )
  28.        
  29.     A = holograms.create(MainBase:getPos(),Angle(0,0,0),"models/sprops/cuboids/height06/size_1/cube_6x18x6.mdl")
  30.     A:setScale(Vector(1.02,0.98,1.02))
  31.     A:setParent(MainHolo)
  32.     A:setMaterial("sprops/textures/sprops_wood4")
  33.    
  34.     function SpawnScreen()
  35.         screen = prop.createComponent(MainBase:localToWorld(Vector(0,0.1,0)), MainBase:localToWorldAngles(Angle(180,0,-90)), "starfall_screen", "models/sprops/cuboids/height06/size_1/cube_6x6x6.mdl", true)
  36.         screen:setColor( Color(0, 0, 0, 1) )
  37.         screen:linkComponent(chip())
  38.         screen:setParent( MainHolo )
  39.         screen:setSolid( false )  
  40.     end
  41.     function RemoveScreen()
  42.         screen:remove()
  43.     end
  44.    
  45.    
  46.     hook.add("PlayerSay", "Hey", function(ply, txt)
  47.         if ply==owner() and txt:sub(1, 6)=="!song " then
  48.             net.start("playSong")
  49.             net.writeString(txt:sub(7))
  50.             net.send()
  51.  
  52.             return ""
  53.         end
  54.     end)
  55.    
  56.     function FolowerBoxStart( ply )
  57.    
  58.         hook.remove("playeruse","take_radio")
  59.  
  60.         targetPos = ply:lookupBone( "ValveBiped.Bip01_Spine4" )
  61.        
  62.         targetHeadPos = ply:lookupBone( "ValveBiped.Bip01_Head1" )
  63.        
  64.         local UnoPosHolo, UnoAngHolo = ply:getBonePosition( targetPos )
  65.  
  66.         MainHolo:setParent( ply , "chest")
  67.         MainHolo:setAngles( UnoAngHolo + Angle(0 , 0 , 90)  )
  68.        
  69.         MainHolo:setAngles( MainHolo:localToWorldAngles(Angle(0,90,90)) )
  70.        
  71.         MainHolo:setPos( UnoPosHolo )
  72.         MainHolo:setPos( MainHolo:localToWorld(Vector(0,5,-1)) )
  73.        
  74.         hook.add("think", "BoxFolower", function()
  75.             if isValid(chip()) then
  76.                
  77.                 MainBase:setPos( ply:getPos() +Vector(0,0,40) )
  78.                 MainBase:setSolid( false )  
  79.                
  80.                 if ply:keyDown(IN_KEY.SPEED) and ply:keyDown(IN_KEY.WALK) then
  81.                     FolowerBoxEnd( ply )
  82.                 end
  83.                
  84.                 if !ply:isAlive() then
  85.                     FolowerBoxEnd( ply )
  86.                 end
  87.             end
  88.         end)
  89.        
  90.     end
  91.    
  92.     function FolowerBoxEnd( ply )
  93.         hook.remove("think", "BoxFolower")
  94.        
  95.         MainBase:enableMotion( true )
  96.         MainBase:setSolid( true )  
  97.        
  98.         MainBase:setPos( ply:getEyePos() + ply:getAimVector() * 20 )
  99.        
  100.         MainBase:setAngles((MainBase:getPos() - ply:getEyePos()):getAngle() + Angle(0,90,0) )
  101.        
  102.         MainBase:applyForceCenter(ply:getAimVector() * 80000)
  103.        
  104.         MainHolo:setParent( MainBase)
  105.         MainHolo:setAngles( MainBase:localToWorldAngles(Angle(0,0,0)) )
  106.         MainHolo:setPos( MainBase:localToWorld(Vector(0,0,0)) )
  107.         StartUseCheck()
  108.         PlayerHandler = nil
  109.        
  110.     end
  111.     function StartUseCheck()
  112.         hook.add("playeruse","take_radio",function(ply,used)
  113.             if used ~= MainBase then return end
  114.             if isValid(ply)  then --and ply == owner()
  115.                 if !weapon_to_takebox[ ply:getActiveWeapon():getClass() ] then return end
  116.                 if PlayerHandler == nil then
  117.                     PlayerHandler = ply
  118.                     FolowerBoxStart( PlayerHandler )
  119.                 end
  120.             end
  121.            
  122.         end)
  123.     end
  124.  
  125.     timer.simple(1, function()
  126.    
  127.         --chip():setColor( Color(0, 0, 0, 0) )
  128.         --chip():setNocollideAll( 1 )
  129.         --chip():setSolid( false )  
  130.         --chip():setParent( MainHolo )  
  131.        
  132.         net.start("SendParentEntity")
  133.         net.writeEntity( MainHolo )
  134.         net.send()
  135.        
  136.         StartUseCheck()
  137.         SpawnScreen()
  138.        
  139.     end)
  140.  
  141. else
  142.  
  143.  
  144.     local boom = {val = 0, x = 0, y = 0}
  145.     local settings = { vol = 0.75, idk = 1}
  146.    
  147.     local HolosLocal = {}
  148.    
  149.     function holoCreate(tbl, index, pos, ang, scale, model, color, parent, mat, disableshading)
  150.         if tbl == nil then
  151.             local holo = holograms.create(pos, ang, model, scale)
  152.             holo:setColor(color)
  153.             holo:setMaterial(mat)
  154.             holo:suppressEngineLighting(disableshading)
  155.             holo:setParent(parent)
  156.  
  157.             return holo
  158.         else
  159.             tbl[index] = holograms.create(pos, ang, model, scale)
  160.             tbl[index]:setColor(color)
  161.             tbl[index]:setMaterial(mat)
  162.             tbl[index]:suppressEngineLighting(disableshading)
  163.             tbl[index]:setParent(parent)
  164.         end
  165.     end
  166.     local MainBase = chip()
  167.     net.receive("SendParentEntity", function(len)
  168.         MainBase = net.readEntity()
  169.         print(MainBase)
  170.        
  171.         holoCreate(HolosLocal, 1, MainBase:localToWorld(Vector(6.05,2.3,0)), MainBase:localToWorldAngles(Angle(0,0,-90)), Vector(0.5), "models/cheeze/wires/speaker.mdl", Color(255,255,255,255), MainBase, "", false)
  172.         holoCreate(HolosLocal, 2, MainBase:localToWorld(Vector(-6.05,2.3,0)), MainBase:localToWorldAngles(Angle(0,0,-90)), Vector(0.5), "models/cheeze/wires/speaker.mdl", Color(255,255,255,255), MainBase, "", false)
  173.        
  174.         holoCreate(HolosLocal, 3, MainBase:localToWorld(Vector(-6.05,0,3)), MainBase:localToWorldAngles(Angle(10,1,2)), Vector(0.08,0.08,0.07), "models/props_c17/signpole001.mdl", Color(255,255,255,255), MainBase, "", false)
  175.         holoCreate(HolosLocal, 4, MainBase:localToWorld(Vector(-6.05,0,3)), MainBase:localToWorldAngles(Angle(-10,2,4)), Vector(0.08,0.08,0.06), "models/props_c17/signpole001.mdl", Color(255,255,255,255), MainBase, "", false)
  176.         holoCreate(HolosLocal, 5, MainBase:localToWorld(Vector(-6.05,0,3)), MainBase:localToWorldAngles(Angle(0,0,0)), Vector(0.5), "models/sprops/misc/fittings/cred_3_1_5_short.mdl", Color(0,0,0,255), MainBase, "", false)
  177.        
  178.     end)
  179.  
  180.     function BassStart()
  181.    
  182.         hook.add("think", "BassRender", function()
  183.             boom.val = math.max(0, boom.val - timer.frametime() * 70)
  184.            
  185.             if song and type(song) == "Bass" and song ~= nil then
  186.                 local fft = song:getFFT(4)
  187.                
  188.                 if #fft >= 64 then
  189.                     local avg2 = 0
  190.                     for i = 8, 16 do
  191.                         avg2 = avg2 + fft[i] / 10
  192.                     end
  193.                     boom.val = math.max(boom.val, math.max(0, avg2 - 0.06) * 20)
  194.                    
  195.                 end
  196.            
  197.             end
  198.         end)
  199.     end
  200.  
  201.  
  202.     local function loadSong(songURL)
  203.         if song then song:stop() end
  204.  
  205.         bass.loadURL(songURL, "3d noblock", function(snd, err, errtxt)
  206.             if snd then
  207.                 song = snd
  208.                 snd:setFade(400,600)
  209.                 snd:setVolume(settings.vol)
  210.                 pcall(snd.setLooping, snd, true) -- pcall in case of audio stream
  211.                 BassStart()
  212.                 hook.add("think", "snd", function()
  213.                     if isValid(snd) and isValid(owner()) then
  214.                         snd:setPos(MainBase:getPos())
  215.                        
  216.                         if ( player():getPos() - MainBase:getPos() ):getLength() >= 600 then
  217.                             snd:setVolume(0)
  218.                         else
  219.                             snd:setVolume( settings.vol )
  220.                         end
  221.                        
  222.                        
  223.                         for k = 1,2 do
  224.                             HolosLocal[k]:setSize( Vector(6+boom.val,6+boom.val,1.8+(boom.val/5)) )
  225.                         end
  226.                     end
  227.                 end)
  228.             else
  229.                 print(errtxt)
  230.             end
  231.         end)
  232.  
  233.         url = nil
  234.     end
  235.  
  236.     net.receive("playSong", function(len)
  237.         url = net.readString()
  238.         hook.remove( "think", "snd" ) hook.remove( "think", "BassRender" )
  239.         loadSong(url)
  240.     end)
  241.  
  242.   --setupPermissionRequest({"bass.loadURL"}, "URL sounds from external sites", true)
  243.  
  244.     hook.add("permissionrequest", "permission", function()
  245.         if url then
  246.             loadSong(url)
  247.         end
  248.     end)
  249.    
  250.     local font64 = render.createFont("Lucida Sans Unicode",100)
  251.    
  252.     hook.add("render","",function()
  253.  
  254.         ScrX, ScrY = render.getResolution()
  255.        
  256.         local Time = os.date( "%H:%M:%S\n%d/%m/%Y" , Timestamp )
  257.  
  258.         if ( player():getPos() - MainBase:getPos() ):getLength() >= 200 then return end
  259.        
  260.         render.setBackgroundColor(Color(0, 0, 0, 0))
  261.         render.setFont(font64)
  262.        
  263.         render.setColor(Color(255, 155, 0,200))  
  264.        
  265.         render.drawRoundedBox(25, 0, ScrY/2-125, ScrX, ScrY/2)
  266.        
  267.         --render.setColor(Color((timer.curtime()*100+180)%360-180, 1, 1):hsvToRGB())
  268.         render.setColor(Color(0, 0, 0,240))  
  269.        
  270.         render.drawText(ScrX/2, ScrY/2-100, Time , 1)
  271.  
  272.  
  273.     end)
  274.    
  275.    
  276. end
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
Add Comment
Please, Sign In to add comment