Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --GUI should set url depending on selected station
- local url = "example.com"
- --GUI should call this function after setting url
- sound.PlayURL( url, "3d", PlayOnCar)
- --Backend
- --Check for Vehicle and Key press changes every Draw
- hook.Add("HUDPaint", "ShowRadioSwitcher", function()
- --if the player is in a Vehicle
- if (IsValid(LocalPlayer():GetVehicle())) then
- --if player is holding down F key
- if (input.IsKeyDown(16)) then
- --Open The GUI
- RadioGUI:Open()
- --if plyer let go of F key
- else
- --Close the GUI
- RadioGUI:Close()
- end
- end
- end )
- function PlayOnCar(station)
- --if the URL is valid
- if (IsValid( station )) then
- --set the sound position to the players Vehicle
- station:SetPos(LocalPlayer():GetVehicle():GetPos())
- --play the sound
- station:Play()
- else
- --if the stream is invalid
- LocalPlayer():ChatPrint("No Stream!")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement