sec = {{{{{{},{},{},{}}}}}} -- ------------------------------ -- Variables -- ------------------------------ local subTrackOnSoundDown = 0.1 -- The volume that goes down, when the player clicks "Volume -" local subTrackOnSoundUp = 0.1 -- The volume that goes up, when the player clicks "Volume +" ------------------------------ -- The GUI -- ------------------------------ local rx, ry = guiGetScreenSize ( ) button = { } window = guiCreateWindow( ( rx - 295 ), ( ry / 2 - 253 / 2 ), 293, 253, "Radio URL", false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) CurrentSpeaker = guiCreateLabel(8, 33, 254, 17, "Estas usando una radio: No", false, window) volume = guiCreateLabel(10, 50, 252, 17, "Volumen Actual: 100%", false, window) pos = guiCreateLabel(10, 66, 252, 15, "X: 0 | Y: 0 | Z: 0", false, window) guiCreateLabel(11, 81, 251, 15, "URL:", false, window) url = guiCreateEdit(11, 96, 272, 23, "http://www.181.fm/winamp.pls?station=181-power&style=mp3&description=Power%20181%20(Top%2040)&file=181-power.pls", false, window) --url = guiCreateEdit(11, 96, 272, 23, "http://roscripts.netau.net/sound.mp3", false, window) -- (This link may not work, by the time you get the script) button["place"] = guiCreateButton(9, 129, 128, 20, "Crear/Mover Radio", false, window) button["remove"] = guiCreateButton(9, 159, 274, 20, "Destruir Radio", false, window) button["v-"] = guiCreateButton(9, 189, 128, 20, "Volumen -", false, window) button["v+"] = guiCreateButton(155, 189, 128, 20, "Volumen +", false, window) button["close"] = guiCreateButton(9, 219, 274, 20, "Salir", false, window) button["place2"] = guiCreateButton(155, 129, 128, 20, "Portar", false, window) guiSetEnabled ( button["place2"], false) -------------------------- -- My sweet codes -- -------------------------- local isSound = false addEvent ( "onPlayerViewSpeakerManagment", true ) addEventHandler ( "onPlayerViewSpeakerManagment", root, function ( current ) local toState = not guiGetVisible ( window ) guiSetVisible ( window, toState ) showCursor ( toState ) if ( toState == true ) then if getElementData(localPlayer, "admin") or getElementData(localPlayer, "soporte") or getElementData(localPlayer, "VIPpremium") or getElementData(localPlayer, "VIPdiamante") then guiSetEnabled ( button["place2"], true) else guiSetEnabled ( button["place2"], false) end guiSetInputMode ( "no_binds_when_editing" ) local x, y, z = getElementPosition ( localPlayer ) guiSetText ( pos, "X: "..math.floor ( x ).." | Y: "..math.floor ( y ).." | Z: "..math.floor ( z ) ) if ( current ) then guiSetText ( CurrentSpeaker, "Estas usando una radio: Si" ) isSound = true else guiSetText ( CurrentSpeaker, "Estas usando una radio: No" ) end end end ) addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == button["close"] ) then guiSetVisible ( window, false ) showCursor ( false ) elseif ( source == button["place"] ) then if ( isURL ( ) ) then triggerServerEvent ( "onPlayerPlaceSpeakerBox", localPlayer, guiGetText ( url ), isPedInVehicle ( localPlayer ) ) guiSetText ( CurrentSpeaker, "Estas usando una radio: Si" ) isSound = true guiSetText ( volume, "Volume Actual: 100%" ) else outputChatBox ( "Necesitas introducir una URL.", 255, 0, 0 ) end elseif ( source == button["remove"] ) then triggerServerEvent ( "onPlayerDestroySpeakerBox", localPlayer ) guiSetText ( CurrentSpeaker, "Estas usando una radio: No" ) isSound = false guiSetText ( volume, "Volume Actual: 100%" ) elseif ( source == button["v-"] ) then if ( isSound ) then local toVol = math.round ( getSoundVolume ( speakerSound [ localPlayer ] ) - subTrackOnSoundDown, 2 ) if ( toVol > 0.0 ) then outputChatBox ( "Volume set to "..math.floor ( toVol * 100 ).."%!", 0, 255, 0 ) triggerServerEvent ( "onPlayerChangeSpeakerBoxVolume", localPlayer, toVol ) guiSetText ( volume, "Volume Actual: "..math.floor ( toVol * 100 ).."%" ) else outputChatBox ( "The volume cannot go any lower.", 255, 0, 0 ) end end elseif ( source == button["v+"] ) then if ( isSound ) then local toVol = math.round ( getSoundVolume ( speakerSound [ localPlayer ] ) + subTrackOnSoundUp, 2 ) if ( toVol < 1.1 ) then outputChatBox ( "Volume Cambiado a "..math.floor ( toVol * 100 ).."%!", 0, 255, 0 ) triggerServerEvent ( "onPlayerChangeSpeakerBoxVolume", localPlayer, toVol ) guiSetText ( volume, "Volume Actual: "..math.floor ( toVol * 100 ).."%" ) else outputChatBox ( "The volume cannot go any higher.", 255, 0, 0 ) end end elseif ( source == button["place2"] ) then if ( isURL ( ) ) then triggerServerEvent ( "onPlayerPlaceSpeakerBoxInPlayer", localPlayer, guiGetText ( url ) ) guiSetText ( CurrentSpeaker, "Estas usando una radio: Si" ) isSound = true guiSetText ( volume, "Volume Actual: 100%" ) else outputChatBox ( "Necesitas introducir una URL.", 255, 0, 0 ) end end end ) speakerSound = { } -- test meta radio addEventHandler("onClientSoundStream", root, function(success, length, streamName) if streamName then if ( isElement (speakerSound[getLocalPlayer()]) ) then if speakerSound[getLocalPlayer()] == nil then return end if speakerSound[getLocalPlayer()] == source then outputChatBox("#FFFFFFRadio stream: #00ff00 " .. streamName, 0, 0, 0, true) end end end end ) addEventHandler("onClientSoundChangedMeta", root, function(streamTitle) if streamTitle then if ( isElement (speakerSound[getLocalPlayer()]) ) then if speakerSound[getLocalPlayer()] == nil then return end if speakerSound[getLocalPlayer()] == source then outputChatBox("#FFFFFFRadio Info: ##00ff00 " .. streamTitle, 0, 0, 0, true) end end end end ) -------------------------------- addEvent ( "onPlayerStartSpeakerBoxSound", true ) addEventHandler ( "onPlayerStartSpeakerBoxSound", root, function ( who, url, isCar ) if ( isElement ( speakerSound [ who ] ) ) then destroyElement ( speakerSound [ who ] ) end local x, y, z = getElementPosition ( who ) speakerSound [ who ] = playSound3D ( url, x, y, z, true ) setSoundVolume ( speakerSound [ who ], 1 ) setSoundMinDistance ( speakerSound [ who ], 13 ) setSoundMaxDistance ( speakerSound [ who ], 18 ) local int = getElementInterior ( who ) setElementInterior ( speakerSound [ who ], int ) setElementDimension ( speakerSound [ who ], getElementDimension ( who ) ) if ( isCar ) then local car = getPedOccupiedVehicle ( who ) attachElements ( speakerSound [ who ], car, 0, 5, 1 ) end end ) addEvent ( "onPlayerStartSpeakerBoxSoundInPlayer", true ) addEventHandler ( "onPlayerStartSpeakerBoxSoundInPlayer", root, function ( who, url, isCar ) if ( isElement ( speakerSound [ who ] ) ) then destroyElement ( speakerSound [ who ] ) end local x, y, z = getElementPosition ( who ) speakerSound [ who ] = playSound3D ( url, x, y, z, true ) setSoundVolume ( speakerSound [ who ], 1 ) setSoundMinDistance ( speakerSound [ who ], 13 ) setSoundMaxDistance ( speakerSound [ who ], 18 ) local int = getElementInterior ( who ) setElementInterior ( speakerSound [ who ], int ) setElementDimension ( speakerSound [ who ], getElementDimension ( who ) ) attachElements ( speakerSound [ who ], who, 0, 0.5, 0.2 ) setElementCollisionsEnabled(speakerSound [ who ], false) end ) addEvent ( "onPlayerDestroySpeakerBox", true ) addEventHandler ( "onPlayerDestroySpeakerBox", root, function ( who ) if ( isElement ( speakerSound [ who ] ) ) then destroyElement ( speakerSound [ who ] ) end end ) -------------------------- -- Volume -- -------------------------- addEvent ( "onPlayerChangeSpeakerBoxVolumeC", true ) addEventHandler ( "onPlayerChangeSpeakerBoxVolumeC", root, function ( who, vol ) if ( isElement ( speakerSound [ who ] ) ) then setSoundVolume ( speakerSound [ who ], tonumber ( vol ) ) end end ) function isURL ( ) if ( guiGetText ( url ) ~= "" ) then return true else return false end end function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end