Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1.  
  2. --GUI should set url depending on selected station
  3. local url = "example.com"
  4.  
  5. --GUI should call this function after setting url
  6. sound.PlayURL( url, "3d", PlayOnCar)
  7.  
  8.  
  9.  
  10. --Backend
  11.  
  12.  
  13. --Check for Vehicle and Key press changes every Draw
  14. hook.Add("HUDPaint", "ShowRadioSwitcher", function()
  15.         --if the player is in a Vehicle
  16.         if (IsValid(LocalPlayer():GetVehicle())) then
  17.             --if player is holding down F key
  18.             if (input.IsKeyDown(16)) then
  19.                 --Open The GUI
  20.                 RadioGUI:Open()
  21.             --if plyer let go of F key
  22.             else
  23.                 --Close the GUI
  24.                 RadioGUI:Close()
  25.             end
  26.         end
  27.     end )
  28.  
  29.  
  30. function PlayOnCar(station)
  31.         --if the URL is valid
  32.         if (IsValid( station )) then
  33.             --set the sound position to the players Vehicle
  34.             station:SetPos(LocalPlayer():GetVehicle():GetPos())
  35.             --play the sound
  36.             station:Play()
  37.         else
  38.             --if the stream is invalid
  39.             LocalPlayer():ChatPrint("No Stream!")
  40.         end
  41.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement