Jump to content

[AJUDA] Saída do som para todos. [RESOLVIDO]


Recommended Posts

Olá a todos. Estou com uma dúvida no seguinte, fiz um script para a policia que, ao apertar um botão, neste caso 7 sai um som de sirene, porém só sai para a pessoa que apertou o botão (7) queria deixar para todos ouvir. Script abaixo:

function bindHoron(_,state,veh) 
local veh = getPedOccupiedVehicle(localPlayer) 
local x,y,z = getElementPosition(veh)    
     if isElement(veh) then 
      if ( state == "down" ) then 
            sound = playSound3D ("som.mp3",x,y,z) 
            setSoundMinDistance(sound,1.0) 
            setSoundMaxDistance(sound, 100) 
            attachElements (sound,veh) 
                        elseif ( state == "up" ) then 
             if isElement( sound ) then 
                stopSound( sound ) 
                 
            end 
        end 
    end 
end 
bindKey("7", "down", bindHoron) 
bindKey("7", "up",bindHoron) 

Edited by Guest
Link to comment

Tente isto (não foi testado) e tambem não sou o melhor scripter (ainda aprendendo :S)

addEventHandler( 'onClientResourceStart', resourceRoot,    
function bindHoron(_,state,veh) 
    local veh = getPedOccupiedVehicle(localPlayer) 
    local x,y,z = getElementPosition(veh)   
         if isElement(veh) then 
          if ( state == "down" ) then 
               local sound = playSound3D ("som.mp3",x,y,z, true) 
                setSoundMaxDistance( uSound, 100 ) 
                attachElements (sound,veh) 
                            elseif ( state == "up" ) then 
                 if isElement( sound ) then 
                    stopSound( sound )   
                end 
            end 
        end 
    end 
) 
    bindKey("7", "down", bindHoron) 
    bindKey("7", "up",bindHoron) 

O que substitui:

sound = playSound3D ("som.mp3",x,y,z) 

para

local sound = playSound3D ("som.mp3",x,y,z, true) 

e

    setSoundMinDistance(sound,1.0) 
   setSoundMaxDistance(sound, 100) 

para

setSoundMaxDistance( uSound, 100 ) 

Também veja isto que pode o ajudar:

https://wiki.multitheftauto.com/wiki/PlaySound3D

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