Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --@name MP3 Player ebat
- --@author Dick_Inside_Head + Sad
- if SERVER then
- local weapon_to_takebox = {
- ["none"] = true,
- ["weapon_empty_hands"] = true,
- }
- --chip():setPos( chip():localToWorld(Vector(0,0,50)) )
- chip():setAngles( Angle(0,0,0) )
- local PlayerHandler = nil
- MainBase= prop.create(chip():getPos()+Vector(0,0,10),Angle(0,0,0),"models/sprops/cuboids/height06/size_1/cube_6x18x6.mdl", 0 )
- MainBase:setColor( Color(0, 0, 0, 0) )
- MainBase:setMass(600)
- MainHolo = holograms.create(MainBase:getPos(),Angle(0,0,0),"models/sprops/cuboids/height06/size_1/cube_6x18x6.mdl")
- MainHolo:setParent(MainBase)
- MainHolo:setColor( Color(0, 0, 0, 255) )
- --chip():setParent( MainBase )
- A = holograms.create(MainBase:getPos(),Angle(0,0,0),"models/sprops/cuboids/height06/size_1/cube_6x18x6.mdl")
- A:setScale(Vector(1.02,0.98,1.02))
- A:setParent(MainHolo)
- A:setMaterial("sprops/textures/sprops_wood4")
- function SpawnScreen()
- 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)
- screen:setColor( Color(0, 0, 0, 1) )
- screen:linkComponent(chip())
- screen:setParent( MainHolo )
- screen:setSolid( false )
- end
- function RemoveScreen()
- screen:remove()
- end
- hook.add("PlayerSay", "Hey", function(ply, txt)
- if ply==owner() and txt:sub(1, 6)=="!song " then
- net.start("playSong")
- net.writeString(txt:sub(7))
- net.send()
- return ""
- end
- end)
- function FolowerBoxStart( ply )
- hook.remove("playeruse","take_radio")
- targetPos = ply:lookupBone( "ValveBiped.Bip01_Spine4" )
- targetHeadPos = ply:lookupBone( "ValveBiped.Bip01_Head1" )
- local UnoPosHolo, UnoAngHolo = ply:getBonePosition( targetPos )
- MainHolo:setParent( ply , "chest")
- MainHolo:setAngles( UnoAngHolo + Angle(0 , 0 , 90) )
- MainHolo:setAngles( MainHolo:localToWorldAngles(Angle(0,90,90)) )
- MainHolo:setPos( UnoPosHolo )
- MainHolo:setPos( MainHolo:localToWorld(Vector(0,5,-1)) )
- hook.add("think", "BoxFolower", function()
- if isValid(chip()) then
- MainBase:setPos( ply:getPos() +Vector(0,0,40) )
- MainBase:setSolid( false )
- if ply:keyDown(IN_KEY.SPEED) and ply:keyDown(IN_KEY.WALK) then
- FolowerBoxEnd( ply )
- end
- if !ply:isAlive() then
- FolowerBoxEnd( ply )
- end
- end
- end)
- end
- function FolowerBoxEnd( ply )
- hook.remove("think", "BoxFolower")
- MainBase:enableMotion( true )
- MainBase:setSolid( true )
- MainBase:setPos( ply:getEyePos() + ply:getAimVector() * 20 )
- MainBase:setAngles((MainBase:getPos() - ply:getEyePos()):getAngle() + Angle(0,90,0) )
- MainBase:applyForceCenter(ply:getAimVector() * 80000)
- MainHolo:setParent( MainBase)
- MainHolo:setAngles( MainBase:localToWorldAngles(Angle(0,0,0)) )
- MainHolo:setPos( MainBase:localToWorld(Vector(0,0,0)) )
- StartUseCheck()
- PlayerHandler = nil
- end
- function StartUseCheck()
- hook.add("playeruse","take_radio",function(ply,used)
- if used ~= MainBase then return end
- if isValid(ply) then --and ply == owner()
- if !weapon_to_takebox[ ply:getActiveWeapon():getClass() ] then return end
- if PlayerHandler == nil then
- PlayerHandler = ply
- FolowerBoxStart( PlayerHandler )
- end
- end
- end)
- end
- timer.simple(1, function()
- --chip():setColor( Color(0, 0, 0, 0) )
- --chip():setNocollideAll( 1 )
- --chip():setSolid( false )
- --chip():setParent( MainHolo )
- net.start("SendParentEntity")
- net.writeEntity( MainHolo )
- net.send()
- StartUseCheck()
- SpawnScreen()
- end)
- else
- local boom = {val = 0, x = 0, y = 0}
- local settings = { vol = 0.75, idk = 1}
- local HolosLocal = {}
- function holoCreate(tbl, index, pos, ang, scale, model, color, parent, mat, disableshading)
- if tbl == nil then
- local holo = holograms.create(pos, ang, model, scale)
- holo:setColor(color)
- holo:setMaterial(mat)
- holo:suppressEngineLighting(disableshading)
- holo:setParent(parent)
- return holo
- else
- tbl[index] = holograms.create(pos, ang, model, scale)
- tbl[index]:setColor(color)
- tbl[index]:setMaterial(mat)
- tbl[index]:suppressEngineLighting(disableshading)
- tbl[index]:setParent(parent)
- end
- end
- local MainBase = chip()
- net.receive("SendParentEntity", function(len)
- MainBase = net.readEntity()
- print(MainBase)
- 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)
- 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)
- 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)
- 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)
- 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)
- end)
- function BassStart()
- hook.add("think", "BassRender", function()
- boom.val = math.max(0, boom.val - timer.frametime() * 70)
- if song and type(song) == "Bass" and song ~= nil then
- local fft = song:getFFT(4)
- if #fft >= 64 then
- local avg2 = 0
- for i = 8, 16 do
- avg2 = avg2 + fft[i] / 10
- end
- boom.val = math.max(boom.val, math.max(0, avg2 - 0.06) * 20)
- end
- end
- end)
- end
- local function loadSong(songURL)
- if song then song:stop() end
- bass.loadURL(songURL, "3d noblock", function(snd, err, errtxt)
- if snd then
- song = snd
- snd:setFade(400,600)
- snd:setVolume(settings.vol)
- pcall(snd.setLooping, snd, true) -- pcall in case of audio stream
- BassStart()
- hook.add("think", "snd", function()
- if isValid(snd) and isValid(owner()) then
- snd:setPos(MainBase:getPos())
- if ( player():getPos() - MainBase:getPos() ):getLength() >= 600 then
- snd:setVolume(0)
- else
- snd:setVolume( settings.vol )
- end
- for k = 1,2 do
- HolosLocal[k]:setSize( Vector(6+boom.val,6+boom.val,1.8+(boom.val/5)) )
- end
- end
- end)
- else
- print(errtxt)
- end
- end)
- url = nil
- end
- net.receive("playSong", function(len)
- url = net.readString()
- hook.remove( "think", "snd" ) hook.remove( "think", "BassRender" )
- loadSong(url)
- end)
- --setupPermissionRequest({"bass.loadURL"}, "URL sounds from external sites", true)
- hook.add("permissionrequest", "permission", function()
- if url then
- loadSong(url)
- end
- end)
- local font64 = render.createFont("Lucida Sans Unicode",100)
- hook.add("render","",function()
- ScrX, ScrY = render.getResolution()
- local Time = os.date( "%H:%M:%S\n%d/%m/%Y" , Timestamp )
- if ( player():getPos() - MainBase:getPos() ):getLength() >= 200 then return end
- render.setBackgroundColor(Color(0, 0, 0, 0))
- render.setFont(font64)
- render.setColor(Color(255, 155, 0,200))
- render.drawRoundedBox(25, 0, ScrY/2-125, ScrX, ScrY/2)
- --render.setColor(Color((timer.curtime()*100+180)%360-180, 1, 1):hsvToRGB())
- render.setColor(Color(0, 0, 0,240))
- render.drawText(ScrX/2, ScrY/2-100, Time , 1)
- end)
- end
Add Comment
Please, Sign In to add comment