Castillo Posted March 30, 2012 Posted March 30, 2012 local carRadios = { } -- Create a table. function attachradio ( thePlayer ) local car = getPedOccupiedVehicle ( thePlayer ) if ( car ) then if ( isElement ( carRadios[ car ] ) ) then -- If the vehicle already has a radio... outputChatBox ( "This vehicle already has a radio.", thePlayer, 255, 0, 0 ) else local x, y, z = getElementRotation ( car ) carRadios[ car ] = createObject ( 2232, 1016.2437133789, -2473.1711425781, 7.6930656433105, x, y, z ) -- Create radio object for the vehicle. attachElements ( carRadios[ car ], car, 0, -4, 0.45 ) -- Attach the radio to the vehicle. triggerClientEvent ( "playRadioCar", root, car ) outputChatBox ( "Here is the radio!", thePlayer ) end end end addCommandHandler ( "radio", attachradio ) This will check if the vehicle already has a radio, if so, output a message to the player. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 30, 2012 Author Posted March 30, 2012 thank you again snake work and who can i make a command to destroy attachElement from vehicle and destroy sound like /destoryradio ? and sorry for inconvenience again
Castillo Posted March 30, 2012 Posted March 30, 2012 -- client side: sounds = "http://www.181.fm/winamp.pls?station=181-power&style=mp3" carSounds = { } function playRadioCar ( car ) local x,y,z = getElementPosition ( car ) if ( isElement ( carSounds[ car ] ) ) then destroyElement ( carSounds[ car ] ) end carSounds[ car ] = playSound3D ( sounds, x, y, z, true ) attachElements ( carSounds[ car ], car ) end addEvent ( "playRadioCar", true ) addEventHandler( "playRadioCar", getRootElement(), playRadioCar ) addEvent ( "stopCarRadio", true ) addEventHandler ( "stopCarRadio", root, function ( car ) if ( isElement ( carSounds[ car ] ) ) then destroyElement ( carSounds[ car ] ) end end ) -- server side: local carRadios = { } -- Create a table. function attachradio ( thePlayer ) local car = getPedOccupiedVehicle ( thePlayer ) if ( car ) then if ( isElement ( carRadios[ car ] ) ) then -- If the vehicle already has a radio... outputChatBox ( "This vehicle already has a radio.", thePlayer, 255, 0, 0 ) else local x, y, z = getElementRotation ( car ) carRadios[ car ] = createObject ( 2232, 1016.2437133789, -2473.1711425781, 7.6930656433105, x, y, z ) -- Create radio object for the vehicle. attachElements ( carRadios[ car ], car, 0, -4, 0.45 ) -- Attach the radio to the vehicle. triggerClientEvent ( "playRadioCar", root, car ) outputChatBox ( "Here is the radio!", thePlayer ) end end end addCommandHandler ( "radio", attachradio ) addCommandHandler ( "stopradio", function ( thePlayer ) local car = getPedOccupiedVehicle ( thePlayer ) if ( car ) then if ( not isElement ( carRadios[ car ] ) ) then -- If the vehicle has no radio... outputChatBox ( "This vehicle has no radio.", thePlayer, 255, 0, 0 ) else triggerClientEvent ( "stopCarRadio", root, car ) destroyElement ( carRadios[ car ] ) end end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 30, 2012 Author Posted March 30, 2012 thannnnnnnnk you snake but sound dont stop when i do /stopradio just speacker destory but music dont stop
X-SHADOW Posted March 30, 2012 Posted March 30, 2012 try using this addEvent ( "stopCarRadio", true ) addEventHandler ( "stopCarRadio", root, function ( car ) if ( isElement ( carSounds[ car ] ) ) then stopSound ( carSounds[ car ] ) end end ) My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
Castillo Posted March 30, 2012 Posted March 30, 2012 thannnnnnnnk you snake but sound dont stop when i do /stopradio just speacker destory but music dont stop The sound is destroyed, it works fine here. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 30, 2012 Author Posted March 30, 2012 try using this addEvent ( "stopCarRadio", true ) addEventHandler ( "stopCarRadio", root, function ( car ) if ( isElement ( carSounds[ car ] ) ) then stopSound ( carSounds[ car ] ) end end ) it still work the sound The sound is destroyed, it works fine here. idk why dont work for me i tested it i do /radio and the sound start and when i do /stopradio the music still work just speaker destroy
X-SHADOW Posted March 30, 2012 Posted March 30, 2012 addEvent ( "stopCarRadio", true ) addEventHandler ( "stopCarRadio", root, function ( car ) if ( isElement ( carSounds[ car ] ) ) then stopSound ( Sounds) end end ) My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
Castillo Posted March 30, 2012 Posted March 30, 2012 @X-SHADOW: Stop posting the same thing, that'll just stop the sound, it'll stay there still. @sckatchof: I've tested it with two vehicles, both times is destroyed. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
X-SHADOW Posted March 30, 2012 Posted March 30, 2012 soldSnake its not worng to help some one i want help him My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
Castillo Posted March 30, 2012 Posted March 30, 2012 Random codes won't help him. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 30, 2012 Author Posted March 30, 2012 thanks all for help but i will try to fix it idk why it dont work for me
X-SHADOW Posted March 30, 2012 Posted March 30, 2012 i well try help you just 1 min wait me My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
Castillo Posted March 30, 2012 Posted March 30, 2012 thanks all for help but i will try to fix it idk why it dont work for me Are you sure you've copied my last code? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
sckatchof Posted March 30, 2012 Author Posted March 30, 2012 Are you sure you've copied my last code? Yes im sure if u want i will upload my resource
Castillo Posted March 30, 2012 Posted March 30, 2012 Try copying my last code again. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
X-SHADOW Posted March 30, 2012 Posted March 30, 2012 hope this work local s = false addCommandHandler ( "stopradio", function () if s then stopSound(carSounds[ car ]) s = false return end end) My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
drk Posted March 30, 2012 Posted March 30, 2012 LOL What is that X-SHADOW EPT Team Server Development: 0% Learning C++ | C++ is amazing
sckatchof Posted March 30, 2012 Author Posted March 30, 2012 Try copying my last code again. i copy your last code again, still dont stop
Castillo Posted March 30, 2012 Posted March 30, 2012 Please upload your resource to: http://mediafire.com/ San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
X-SHADOW Posted March 30, 2012 Posted March 30, 2012 i found it on topic this topic lol https://forum.multitheftauto.com/viewtop ... 6&p=398145 My ingame nickname : Ops! -DeathMatch GameMode By Ops! : 5%
sckatchof Posted March 30, 2012 Author Posted March 30, 2012 Please upload your resource to: http://mediafire.com/ Link : http://www.mediafire.com/?uxr856xtiiy6co3
sckatchof Posted March 30, 2012 Author Posted March 30, 2012 i found it on topic this topic lolhttps://forum.multitheftauto.com/viewtop ... 6&p=398145 @X-SHADOW : don't copy the code without check if he work
drk Posted March 30, 2012 Posted March 30, 2012 X-SHADOW, your code is completely wrong. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted March 30, 2012 Posted March 30, 2012 How could it ever work if you forgot to add this: addEvent ( "stopCarRadio", true ) addEventHandler ( "stopCarRadio", root, function ( car ) if ( isElement ( carSounds[ car ] ) ) then destroyElement ( carSounds[ car ] ) end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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