Jump to content

Help again


sckatchof

Recommended Posts

  • Replies 60
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 
) 

and i add this i still work the music

Link to comment
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 ) 
                triggerClientEvent ( "stopCarRadio", root, car ) 
            end 
        end 
    end 
) 

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 
            stopSound ( carSounds[ car ] ) 
        end 
    end 
) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...