dazzlepoint Posted July 17, 2013 Share Posted July 17, 2013 when i try this i can't hear anything, can you help me ? function startMySound() local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) local id = getVehicleID(vehicle) if (id== 513 ) then setRadioChannel(0) sound = playSound( "http://d.liveatc.net/kjfk_twr", true ) end if (id== 429 ) then setRadioChannel(0) sound = playSound( "http://212.45.104.34:8042/listen.pls", true ) end end addEventHandler("onClientPlayerVehicleEnter",getRootElement(),startMySound) function stopMySound() stopSound( sound ) end addCommandHandler ( "stopsound", stopMySound ) addEventHandler("onClientVehicleExplode",getRootElement(),stopMySound) Link to comment
iMr.3a[Z]eF Posted July 17, 2013 Share Posted July 17, 2013 Try this: local sounds = { ['S1'] = "http://d.liveatc.net/kjfk_twr", ['S2'] = "http://212.45.104.34:8042/listen.pls", } function startMySound() local vehicle = getPedOccupiedVehicle( localPlayer ) local id = getVehicleID(vehicle) if (id == 513 ) then setRadioChannel(0) playSound( sounds['S1'] ) elseif (id == 429 ) then setRadioChannel(0) sound = playSound( sounds['S2'] ) end end addEventHandler("onClientPlayerVehicleEnter",getRootElement(),startMySound) function stopMySound() stopSound( sounds ) end addCommandHandler ( "stopsound", stopMySound ) addEventHandler("onClientVehicleExplode",getRootElement(),stopMySound) Link to comment
dazzlepoint Posted July 18, 2013 Share Posted July 18, 2013 I must add this links in the meta.xml file ? and how do you do that ? Link to comment
Hutchpe Posted July 19, 2013 Share Posted July 19, 2013 Sorry for intruding on this thread but I have a similar problem. When I get in a vehicle it starts playing the sound but when I get out of the vehicle or issue the 'stopsound' command the sound won't stop. function startGarageMusic() local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) local sound = playSound("saints_row_garage.mp3", true) setRadioChannel(0) setSoundVolume( sound, 0.8 ) end addEventHandler("onClientVehicleEnter",getRootElement(),startGarageMusic) function stopGarageMusic() stopSound( sound ) end addCommandHandler ( "stopsound", stopGarageMusic ) addEventHandler("onClientVehicleExit",getRootElement(),stopGarageMusic) Can someone point me in the right direction? Thanks Link to comment
dazzlepoint Posted July 19, 2013 Share Posted July 19, 2013 is there a server side ? is this only for client ? Link to comment
Jaysds1 Posted July 19, 2013 Share Posted July 19, 2013 (edited) @Hutchpe try this: local sound --make the sound available for the whole script function startGarageMusic() sound = playSound("saints_row_garage.mp3", true) setRadioChannel(0) setSoundVolume( sound, 0.8 ) end addEventHandler("onClientVehicleEnter",getRootElement(),startGarageMusic) function stopGarageMusic() if isElement(sound) then stopSound( sound ) end end addCommandHandler ( "stopsound", stopGarageMusic ) addEventHandler("onClientVehicleExit",getRootElement(),stopGarageMusic) @dazzlepoint Try this: local sounds = { ['S1'] = "http://d.liveatc.net/kjfk_twr", ['S2'] = "http://212.45.104.34:8042/listen.pls", } function startMySound() local vehicle = getPedOccupiedVehicle( localPlayer ) local id = getVehicleID(vehicle) or getElementModel(vehicle) if (id == 513 ) then setRadioChannel(0) sound = playSound( sounds['S1'] ) elseif (id == 429 ) then setRadioChannel(0) sound = playSound( sounds['S2'] ) end end addEventHandler("onClientPlayerVehicleEnter",getRootElement(),startMySound) function stopMySound() stopSound( sounds ) end addCommandHandler ( "stopsound", stopMySound ) addEventHandler("onClientVehicleExplode",getRootElement(),stopMySound) Yes it does have to be client-side, and no you don't need to add the sound to the [[meta.xml]] . Edited July 19, 2013 by Guest Link to comment
iMr.3a[Z]eF Posted July 22, 2013 Share Posted July 22, 2013 @Hutchpe try this: local sound --make the sound available for the whole script function startGarageMusic() sound = playSound("saints_row_garage.mp3", true) setRadioChannel(0) setSoundVolume( sound, 0.8 ) end addEventHandler("onClientVehicleEnter",getRootElement(),startGarageMusic) function stopGarageMusic() if isElement(sound) then stopSound( sound ) end end addCommandHandler ( "stopsound", stopGarageMusic ) addEventHandler("onClientVehicleExit",getRootElement(),stopGarageMusic) @dazzlepoint Try this: local sounds = { ['S1'] = "http://d.liveatc.net/kjfk_twr", ['S2'] = "http://212.45.104.34:8042/listen.pls", } function startMySound() local vehicle = getPedOccupiedVehicle( localPlayer ) local id = getVehicleID(vehicle) or getElementModel(vehicle) if (id == 513 ) then setRadioChannel(0) sound = playSound( sounds['S1'] ) elseif (id == 429 ) then setRadioChannel(0) sound = playSound( sounds['S2'] ) end end addEventHandler("onClientPlayerVehicleEnter",getRootElement(),startMySound) function stopMySound() stopSound( sounds ) end addCommandHandler ( "stopsound", stopMySound ) addEventHandler("onClientVehicleExplode",getRootElement(),stopMySound) Yes it does have to be client-side, and no you don't need to add the sound to the [[meta.xml]] . Is that my code? That code for @dazzlepoint. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now