Advertisement
szymski

Untitled

Jun 19th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.26 KB | None | 0 0
  1. 3D Radioclient {
  2. audio aud
  3.  
  4. bool useDown = false
  5. int useC = 0
  6.  
  7. int volume = 50
  8.  
  9. bool circles = false
  10.  
  11. function number lpintersect(vector P1,vector N1,vector P2,vector N2)
  12. {
  13. return (N1.dot(P1-P2))/(N1.dot(N2))
  14. }
  15.  
  16. function bool VecIn(vector2 m, vector2 pos, vector2 size) {
  17. return (m>pos && (m<(pos+size)))
  18. }
  19.  
  20. function void DrawGUI() {
  21. vector guipos = entity().pos() + vec(0,0,60)
  22. angle an = (guipos-localPlayer().shootPos()).angle()
  23.  
  24. vector realPos = guipos-(guipos-localPlayer().shootPos()).normal()*clamp(guipos.distance(localPlayer().shootPos())-45,20,150)
  25.  
  26. vector planePos = localPlayer().shootPos()+localPlayer().eye()*lpintersect(realPos, an.forward(), localPlayer().shootPos(), localPlayer().eye())
  27.  
  28. vector2 mpos = vec2(-((planePos-realPos).getY()*cos(an.getYaw())-(planePos-realPos).getX()*sin(an.getYaw())) * 20, -(planePos-realPos).getZ() * 20)
  29.  
  30. start3D2D(guipos-(guipos-localPlayer().shootPos()).normal()*clamp(guipos.distance(localPlayer().shootPos())-45,20,150),
  31. an+ang(-an.getPitch(),-90,90-an.getPitch()), 0.05)
  32.  
  33. setDrawColor(255,255,255)
  34. drawBox(vec2(-200,-120), vec2(400,240))
  35.  
  36. setFont("Trebuchet24", 32)
  37. setFontColor(color(100,100,100))
  38. drawText(vec2(-195,-115), "Playing: Something")
  39.  
  40. if(mpos.distance(vec2(0,0)) > 70)
  41. setDrawColor(200,200,200)
  42. else {
  43. setDrawColor(150,150,150)
  44. if(useDown) {
  45. if(aud.isPaused())
  46. aud.play()
  47. else
  48. aud.pause()
  49. }
  50. }
  51. drawCircle(vec2(0,0), 70)
  52.  
  53. setDrawColor(100,100,100)
  54.  
  55. if(!aud.isPaused()) {
  56. drawBox(vec2(-30,-40), vec2(20,80))
  57. drawBox(vec2(10,-40), vec2(20,80))
  58. }
  59. else {
  60. drawPoly(vector2Array(vec2(-20,-40),vec2(-20,40),vec2(40,0)))
  61. }
  62.  
  63. setDrawColor(100,100,100)
  64. drawBox(vec2(120,-80), vec2(40,160))
  65.  
  66. setDrawColor(0,150,235)
  67. drawBox(vec2(120,-80+160*(1-volume/100)), vec2(40,round(volume/100*160)+1))
  68.  
  69. if(VecIn(mpos, vec2(120,-90+160*(1-volume/100)), vec2(40,20))) {
  70. if(localPlayer().keyUse()) {
  71. volume = clamp(100*((80-mpos.getY())/160),0,100)
  72. }
  73. setDrawColor(150,150,150)
  74. }
  75. else
  76. setDrawColor(200,200,200)
  77. drawBox(vec2(120,-90+160*(1-volume/100)), vec2(40,20))
  78.  
  79. setDrawColor(100,100,100)
  80. drawBox(vec2(-200,100), vec2(400,10))
  81.  
  82. setDrawColor(0,150,235)
  83. drawBox(vec2(-200,100), vec2(aud.isBlockStreamed() ? 400 : realtime()*50%400,10))
  84. //int p = tan(realtime()*50)*50
  85. //drawBox(vec2(-30 + p,100), vec2(clamp(200-p+30,0,60),10))
  86.  
  87. end3D2D()
  88.  
  89. // print(mpos)
  90.  
  91. }
  92.  
  93. //http://stream.house-radio.com/listen.pls
  94. //http://ponyvillelive.com/station/playlist/id/3/format/pls
  95. //http://ponyvillelive.com/station/playlist/id/39/format/pls
  96. //http://94.23.89.48:7300/listen.pls
  97. //http://szymekk.info/music/griefers.mp3
  98. //http://uploads.damianu.info/Music/Bats.mp3
  99.  
  100. int lastDrawTime = 0
  101.  
  102. array dubs = numberArray()
  103. int maxdub = 0
  104. int nextdub = 0
  105. bool cooldown = false
  106. int maxDistance = 2000
  107. bool fading = true
  108. array fft = numberArray()
  109. array fftSmooth = numberArray()
  110. function void Play() {
  111. playURL("http://s20-3.pleerstorage.com/0042aebeb47d4f966f22cee0c50eac65ceece84879889784f71b5b9ef918f604da0abe727279e2971a2d8ed84d1bbd4357bd417a38c95f71d06b9d57a810da6f1745ee750b7e/20c4e3a0c8.mp3","",function(audio a) {
  112. aud = a
  113. a.play()
  114. a.setVolume(volume)
  115. fft = a.fft(41)
  116. fftSmooth = fft
  117. event tick() {
  118. fft = aud.fft(41)
  119. if(fading) {
  120. aud.setVolume(clamp((1-entity().pos().distance(localPlayer().pos())/maxDistance)*volume,0,100))
  121. }
  122. }
  123. event draw3D() {
  124. if(localPlayer().keyUse() && !useDown && useC == 0) {useDown = true; useC = 1 }
  125. int sz = 100 + sin(realtime()*50) * 40
  126. setRenderMat("color")
  127. renderEnableDepth(false)
  128. if(circles) {
  129. start3D2D(entity().pos(), ang())
  130. setDrawColor(0,0,0)
  131. drawCircle(vec2(),500)
  132.  
  133. int delta = realtime() - lastDrawTime
  134. lastDrawTime = realtime()
  135.  
  136. foreach(int key; int val : dubs) {
  137. dubs[key] = val + frameTime() * delta * 30000
  138. if(dubs[key,int] > 500) {
  139. dubs.removenumber(key)
  140. break
  141. }
  142. color c = hsv2rgb((realtime()*100)%360,1,1)
  143. c.setAlpha(clamp((500-val)/500*255,0,255))
  144. setDrawColor(c)
  145. drawCircle(vec2(),val)
  146. setDrawColor(0,0,0)
  147. drawCircle(vec2(),val-15)
  148. }
  149. end3D2D()
  150. }
  151. renderEnableDepth(true)
  152. if(#fft > 0) {
  153. for(int i=1; clamp(#fftSmooth,0,40); 1) {
  154. fftSmooth[i] = (fft[i,number]+fftSmooth[i,number]*3)/4 //Smoothing, because why not ;p
  155. draw3DBox(entity().pos()+vec(sin(i*9)*sz,cos(i*9)*sz,0),ang(0,-i*9,0),-vec(5,5,5),vec(5,5,fftSmooth[i,int]*200),hsv2rgb((realtime()*100+i*9)%360,1,1))
  156. }
  157. setRenderMat("sprites/light_ignorez")
  158. drawSprite(entity().pos()+vec(0,0,50),fftSmooth[1,int]*1000,fftSmooth[1,int]*1000,color(random(0,255),random(0,255),random(0,255)))
  159.  
  160. setRenderMat("trails/laser")
  161. //for(int i=2; clamp(#fftSmooth,0,40); 1) {
  162. // draw3DBeam(entity().pos()+vec(sin(i*9-9)*(sz+20),cos(i*9-9)*(sz+20),fftSmooth[i-1,int]*1000),entity().pos()+vec(sin(i*9)*(sz+20),cos(i*9)*(sz+20),fftSmooth[i,int]*1000),15,15,5,color(255,255,255))
  163. //}
  164. for(int i=2; clamp(#fftSmooth,0,41); 1) {
  165. draw3DBeam(entity().pos()+vec(sin(i*9-9)*(sz+20),cos(i*9-9)*(sz+20),20),entity().pos()+vec(sin(i*9)*(sz+20),cos(i*9)*(sz+20),20),15,15,5,color(255,255,255,clamp(fftSmooth[i,int]*200,0,255)))
  166. }
  167.  
  168. if(fft[2,int]*1000 > maxdub-20 && realtime() > nextdub && !cooldown && fft[2,int]*1000 > 100) {
  169. nextdub = realtime() + 0.2
  170. dubs.insert(0)
  171. cooldown = true
  172. }
  173.  
  174. if(fft[2,int]*1000 > maxdub-80) {
  175. maxdub = (maxdub*8+fft[2,int]*1000)/9
  176. }
  177.  
  178. if(fft[2,int]*1000 < maxdub-20 || fft[2,int]*1000 > maxdub+20) cooldown = false
  179.  
  180. }
  181. renderEnableDepth(false)
  182. DrawGUI()
  183. useDown = false
  184. if(!localPlayer().keyUse()) useC = 0
  185. }
  186. },function() {})
  187. }
  188. if(canPlayFromURL()) {
  189. Play()
  190. }
  191. event enablePlayURL() {
  192. Play()
  193. netstream nst = stream()
  194. nst.writeString(localPlayer().name())
  195. nst.sendToServer("enabled")
  196. }
  197.  
  198. event drawScreen(int w, int h) {
  199. setFontColor(color(0,100,255))
  200. setFont("Trebuchet24",48)
  201. drawText(vec2(h/2-getTextWidth("Enable URL sounds :>")/2,230), "Enable URL sounds :>")
  202. }
  203.  
  204. event draw3D() {}
  205.  
  206. event requestFeatures() {
  207. request3DRendering()
  208. requestPlayURL()
  209. return true
  210. }
  211.  
  212. event acceptedFeatures() {
  213. Play()
  214. }
  215. }
  216. server {
  217. netReceive("enabled", function(netstream st) {
  218. print(st.readString() + "has enabled Radio")
  219. })
  220.  
  221.  
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement