#DeltaSCR Posted February 2, 2019 Posted February 2, 2019 Olá, pretendo desenvolver um código cujo quando um Player esteja em um veículo de emergência, ao apertar "H", cancele a sirene original, juntamente com o giroflex padrão, e toque um som modificado (3d), alguém tem ideia de como eu devo fazer isso? Minha resposta te ajudou? Por favor, não esqueça de avaliar - #DeltaSCR Minha página no Facebook: Delta Scripting - MTA "Viribus et honor"
androksi Posted February 3, 2019 Posted February 3, 2019 Não é tão complicado. Para desativar o som de sirene e giroflex, basta usar essa função no lado client. function fClientResourceStart( ) setWorldSoundEnabled( 17, 10, false, true ); setWorldSoundEnabled( 17, 11, false, true ); end addEventHandler( "onClientResourceStart", resourceRoot, fClientResourceStart ); As funções que você deverá usar são: CLIENT-SIDE bindKey( ); -- // para fazer uma função de toggle (down, up), verificando se o jogador está segurando ou não a tecla H playSound3D( ); -- // para tocar o áudio setSoundVolume( ); -- // para alterar o volume da sirene setSoundMinDistance( ); -- // altere para 1.0 setSoundMaxDistance( ); -- // a distância que os jogadores irão ouvir attachElements( ); -- // fazer com que o elemento áudio grude no jogador responsável por apertar a tecla H triggerServerEvent( ); -- // para sincronizar o áudio (client -> server) SERVER-SIDE triggerClientEvent( ); -- // mandar o áudio e o jogador responsável por apertar a tecla H para o client 1 Hello, world. Tutorial sobre interação de BOTs do Discord com o seu servidor - Visitar (Brazilian Portuguese) Tutorial sobre tabelas - Visitar (Brazilian Portuguese) Tutorial sobre banco de dados - Visitar (Brazilian Portuguese)
Moderators Lord Henry Posted February 3, 2019 Moderators Posted February 3, 2019 @asrzk Boa. Mas faltou dizer como desativar o giroflex padrão (as luzes). Isso aí só desabilita o som da sirene. Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
androksi Posted February 3, 2019 Posted February 3, 2019 @EDIT SERVER-SIDE setVehicleSirensOn( ); -- // para desativar as luzes da sirene Obrigado por avisar, @Lord Henry. É que eu fiz o script completo aqui para eu mesmo testar. O código está funcionando perfeitamente, realmente faltava essa função para ficar xuxu. 1 Hello, world. Tutorial sobre interação de BOTs do Discord com o seu servidor - Visitar (Brazilian Portuguese) Tutorial sobre tabelas - Visitar (Brazilian Portuguese) Tutorial sobre banco de dados - Visitar (Brazilian Portuguese)
#DeltaSCR Posted February 5, 2019 Author Posted February 5, 2019 Desculpe a demora para ver o tópico, então eu poderia fazer assim? Client-Side function disableSound () setWorldSoundEnabled (17, 10, false, true) setWorldSoundEnabled (17, 11, false, true) end addEventHandler ("onClientResourceStart", resourceRoot, disableSound) Client-Side fub function startSound () for id, vehicle (getElementType(vehicle)) == "vehicle" do -- Não entendo muito de loops, me corrijam pls local veh = getPedOccupiedVehicle(localPlayer) if veh = (id == 596) then local pos = getElementPosition (localPlayer) local som = playSound3D ("som.mp3", pos) setSoundMinDistance (som, 1.0) setSoundMaxDistance (som, 25.0) -- Não tenho ideia de como fazer triggerEvent end end end bindKey ("h", "down", startSound) ESTARIA CORRETO DESSA FORMA? Minha resposta te ajudou? Por favor, não esqueça de avaliar - #DeltaSCR Minha página no Facebook: Delta Scripting - MTA "Viribus et honor"
androksi Posted February 5, 2019 Posted February 5, 2019 Aqui o script completo. CLIENT-SIDE -- // TABELA DE VEÍCULOS QUE TERÃO NOVAS SIRENES local tVehicles = { [ 597 ] = true, [ 416 ] = true }; -- // TABELA DOS CLIENTES local tAudio = { }; -- // FUNÇÕES function fClientResourceStart( ) setWorldSoundEnabled( 17, 10, false, true ); setWorldSoundEnabled( 17, 11, false, true ); end function fPlayModifySiren( _, keyState ) local vehicle = getPedOccupiedVehicle( localPlayer ); if ( vehicle and tVehicles[ getElementModel( vehicle ) ] ) then if ( keyState == "down" ) then triggerServerEvent( "toggleSirens", resourceRoot, true ); elseif ( keyState == "up" ) then triggerServerEvent( "toggleSirens", resourceRoot, false ); end end end function fStartSiren( client ) if ( not tAudio[ client ] ) then if ( tAudio[ client ] and isElement( tAudio[ client ] ) ) then destroyElement( tAudio[ client ] ); end tAudio[ client ] = playSound3D( "sfx/siren.mp3", Vector3( getElementPosition( client ) ) ); setSoundVolume( tAudio[ client ], 1.0 ); setSoundMinDistance( tAudio[ client ], 1.0 ); setSoundMaxDistance( tAudio[ client ], 100.0 ); attachElements( tAudio[ client ], client ); end end function fStopSiren( client ) if ( tAudio[ client ] ) then if ( tAudio[ client ] and isElement( tAudio[ client ] ) ) then destroyElement( tAudio[ client ] ); tAudio[ client ] = nil; end end end -- // EVENTOS addEvent( "startSiren", true ); addEvent( "stopSiren", true ); addEventHandler( "startSiren", resourceRoot, fStartSiren ); addEventHandler( "stopSiren", resourceRoot, fStopSiren ); addEventHandler( "onClientResourceStart", resourceRoot, fClientResourceStart ); -- // KEYS bindKey( "h", "both", fPlayModifySiren ); SERVER-SIDE -- // FUNÇÕES function fToggleSirens( state ) if ( state ) then setVehicleSirensOn( getPedOccupiedVehicle( client ), false ); triggerClientEvent( root, "startSiren", resourceRoot, client ); else triggerClientEvent( root, "stopSiren", resourceRoot, client ); end end -- // EVENTOS addEvent( "toggleSirens", true ); addEventHandler( "toggleSirens", resourceRoot, fToggleSirens ); 1 Hello, world. Tutorial sobre interação de BOTs do Discord com o seu servidor - Visitar (Brazilian Portuguese) Tutorial sobre tabelas - Visitar (Brazilian Portuguese) Tutorial sobre banco de dados - Visitar (Brazilian Portuguese)
#DeltaSCR Posted February 5, 2019 Author Posted February 5, 2019 1 minute ago, asrzk said: Aqui o script completo. CLIENT-SIDE -- // TABELA DE VEÍCULOS QUE TERÃO NOVAS SIRENES local tVehicles = { [ 597 ] = true, [ 416 ] = true }; -- // TABELA DOS CLIENTES local tAudio = { }; -- // FUNÇÕES function fClientResourceStart( ) setWorldSoundEnabled( 17, 10, false, true ); setWorldSoundEnabled( 17, 11, false, true ); end function fPlayModifySiren( _, keyState ) local vehicle = getPedOccupiedVehicle( localPlayer ); if ( vehicle and tVehicles[ getElementModel( vehicle ) ] ) then if ( keyState == "down" ) then triggerServerEvent( "toggleSirens", resourceRoot, true ); elseif ( keyState == "up" ) then triggerServerEvent( "toggleSirens", resourceRoot, false ); end end end function fStartSiren( client ) if ( not tAudio[ client ] ) then if ( tAudio[ client ] and isElement( tAudio[ client ] ) ) then destroyElement( tAudio[ client ] ); end tAudio[ client ] = playSound3D( "sfx/siren.mp3", Vector3( getElementPosition( client ) ) ); setSoundVolume( tAudio[ client ], 1.0 ); setSoundMinDistance( tAudio[ client ], 1.0 ); setSoundMaxDistance( tAudio[ client ], 100.0 ); attachElements( tAudio[ client ], client ); end end function fStopSiren( client ) if ( tAudio[ client ] ) then if ( tAudio[ client ] and isElement( tAudio[ client ] ) ) then destroyElement( tAudio[ client ] ); tAudio[ client ] = nil; end end end -- // EVENTOS addEvent( "startSiren", true ); addEvent( "stopSiren", true ); addEventHandler( "startSiren", resourceRoot, fStartSiren ); addEventHandler( "stopSiren", resourceRoot, fStopSiren ); addEventHandler( "onClientResourceStart", resourceRoot, fClientResourceStart ); -- // KEYS bindKey( "h", "both", fPlayModifySiren ); SERVER-SIDE -- // FUNÇÕES function fToggleSirens( state ) if ( state ) then setVehicleSirensOn( getPedOccupiedVehicle( client ), false ); triggerClientEvent( root, "startSiren", resourceRoot, client ); else triggerClientEvent( root, "stopSiren", resourceRoot, client ); end end -- // EVENTOS addEvent( "toggleSirens", true ); addEventHandler( "toggleSirens", resourceRoot, fToggleSirens ); Nossa! Muito obrigado mano Minha resposta te ajudou? Por favor, não esqueça de avaliar - #DeltaSCR Minha página no Facebook: Delta Scripting - MTA "Viribus et honor"
#DeltaSCR Posted February 24, 2019 Author Posted February 24, 2019 Então Galera, sei quem passou um certo tempo desde a última atualização do post, mas me vi na necessidade de, quais alterações eu teria que fazer pra quando eu segurasse a letra "h", tocasse uma outra sirene modificada? Minha resposta te ajudou? Por favor, não esqueça de avaliar - #DeltaSCR Minha página no Facebook: Delta Scripting - MTA "Viribus et honor"
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