Jump to content

Help again


sckatchof

Recommended Posts

hi guys i have problem when i do /radio the speaker attach to vehicle but only one player get the speaker when anther player do /radio the speaker change to his car and it removed from my vehicle this is my script

carRadio = createObject(2232, 1016.2437133789, -2473.1711425781, 7.6930656433105, 0, 2, 30) 
  
function attachradio(thePlayer) 
   local car = getPedOccupiedVehicle(thePlayer) 
   if(car) then 
      local x, y, z = getElementRotation(car) 
      setObjectRotation(carRadio, x, y, z) 
      triggerClientEvent ( thePlayer, "playRadioCar", getRootElement(), car) 
      attachElements(carRadio, car, 0, -4, 0.45) 
      setObjectRotation(carRadio, x, y, z) 
      outputChatBox("Here is the radio!", thePlayer) 
end 
end 
addCommandHandler("radio", attachradio) 
  

Link to comment
  • Replies 60
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

addCommandHandler ( 'radio',  
    function ( player, command ) 
        if ( getPedOccupiedVehicle ( player ) ) then 
            local carRadio = createObject ( 2232, 1016.2437133789, -2473.1711425781, 7.6930656433105, 0, 2, 30 ); 
            local x, y, z = getElementRotation ( getPedOccupiedVehicle ( player ) ); 
            triggerClientEvent ( 'playRadioCar', root, getPedOccupiedVehicle ( player ) ) 
            attachElements ( carRadio, getPedOccupiedVehicle ( player ), 0, -4, 0.45 ); 
            setObjectRotation ( carRadio, x, y, z ); 
            outputChatBox ( 'Here is the radio!', player ); 
        end 
    end 
) 
  

Edited by Guest
Link to comment
carRadio = createObject(2232, 1016.2437133789, -2473.1711425781, 7.6930656433105, 0, 2, 30) 
  
function attachradio() 
   local car = getPedOccupiedVehicle(source) 
   if(car) then 
      local x, y, z = getElementRotation(car) 
      setObjectRotation(carRadio, x, y, z) 
      triggerClientEvent ( source, "playRadioCar", car) 
      attachElements(carRadio, car, 0, -4, 0.45) 
      setObjectRotation(carRadio, x, y, z) 
      outputChatBox("Here is the radio!", source) 
end 
end 
addCommandHandler("radio", attachradio) 

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... 
            destroyElement ( carRadios[ car ] ) -- Destroy it. 
        end 
        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 ( thePlayer, "playRadioCar", getRootElement(), car ) 
        outputChatBox ( "Here is the radio!", thePlayer ) 
    end 
end 
addCommandHandler ( "radio", attachradio ) 

Link to comment
The script creates the radio object, I've tested and it worked.

sorry i edit my post it work thank yooou :D

but i have anther problem when i do /radio start music attach to my car it work but me can listen but anther players can't listen

this is my script

.. 
  
sounds = "http://www.181.fm/winamp.pls?station=181-power&style=mp3" 
function playRadioCar ( car ) 
            local x,y,z = getElementPosition( car ) 
            sound = playSound3D( sounds, x, y, z, true) 
            attachElements ( sound, car) 
 end 
addEvent( "playRadioCar", true ) 
addEventHandler("playRadioCar", getRootElement(), playRadioCar) 
  

Link to comment

-- client side:

sounds = "http://www.181.fm/winamp.pls?station=181-power&style=mp3" 
  
function playRadioCar ( car ) 
    local x,y,z = getElementPosition ( car ) 
    sound = playSound3D ( sounds, x, y, z, true ) 
    attachElements ( sound, car ) 
end 
addEvent ( "playRadioCar", true ) 
addEventHandler( "playRadioCar", getRootElement(), playRadioCar ) 

-- 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... 
            destroyElement ( carRadios[ car ] ) -- Destroy it. 
        end 
        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 
addCommandHandler ( "radio", attachradio ) 

Link to comment

thank you snake for help work :) i have anther question how can i make if player do /radio and get to anther car and do /radio

it radio remouve with music and create to his car or he have already the radio it show outputChatBox ( "tthe radio is already exists", thePlayer ) .

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...