Wysłany: 2018-12-17, 18:19
adisonboss
Wiek: 23 Na forum: 3331 dni Posty: 237
Piwa : 6
Witam. Ot?? chc? by aktualny d?wi?k nie by? odtwarzany w p?tli tylko jeden raz. Co musz? zmieni? i na co ? Za pomoc oraz
addEvent ( "broadcastSound3D1" , true )
addEventHandler ( "broadcastSound3D1" , root , function( sound , range , minrange , bliskiKomunikat , dalekiKomunikat )
local el = source
if getElementDimension ( localPlayer )~= getElementDimension ( el ) then return end
if getElementInterior ( localPlayer )~= getElementInterior ( el ) then return end
local x , y , z = getElementPosition ( localPlayer )
local x2 , y2 , z2 = getElementPosition ( el )
local dist = getDistanceBetweenPoints3D ( x , y , z , x2 , y2 , z2 )
if dist < range * 2 then
if bliskiKomunikat and minrange and dist < minrange then
triggerEvent ( "onCaptionedEvent1" , root , bliskiKomunikat , 10 )
outputChatBox ( " * " .. bliskiKomunikat )
elseif dalekiKomunikat and dist < range then
triggerEvent ( "onCaptionedEvent1" , root , dalekiKomunikat , 10 )
outputChatBox ( " * " .. dalekiKomunikat )
end
local s = playSound3D ( sound , x2 , y2 , z2 )
setSoundMinDistance ( s , minrange or 5 )
setSoundMaxDistance ( s , range )
end
end )
--------------------------------------------------------------------------------------- SAPD
local soundSwitch_lu1 = getTickCount ()- 2000
local function soundSwitch_lu12 ()
outputDebugString ( "sw0" )
if getTickCount ()- soundSwitch_lu1 < 2000 then return end
soundSwitch_lu1 = getTickCount ()
local pojazd = getPedOccupiedVehicle ( localPlayer )
outputDebugString ( "sw2" )
if pojazd and getVehicleController ( pojazd )== localPlayer then
local em = getElementModel ( pojazd )
if em == 431 or em == 490 or em == 528 or em == 433 or em == 552 or em == 544 or em == 419 or em == 515 or em == 601 or em == 407 or em == 499 or em == 403 then -- SAPD
triggerServerEvent ( "toggleVehicleSound1" , pojazd , "poganiaczPSP.ogg" , 225 )
cancelEvent ()
return
end
end
end
bindKey ( "i" , "down" , soundSwitch_lu12 )
local soundSwitch_lu1 = getTickCount ()- 2000
local function soundSwitch_lu12 ()
outputDebugString ( "sw0" )
if getTickCount ()- soundSwitch_lu1 < 2000 then return end
soundSwitch_lu1 = getTickCount ()
local pojazd = getPedOccupiedVehicle ( localPlayer )
outputDebugString ( "sw2" )
if pojazd and getVehicleController ( pojazd )== localPlayer then
local em = getElementModel ( pojazd )
if em == 467 or em == 498 or em == 416 or em == 438 or em == 440 or em == 456 or em == 609 or em == 482 or em == 483 or em == 529 or em == 507 or em == 596 or em == 418 or em == 598 or em == 523 or em == 545 or em == 427 or em == 599 or em == 597 or em == 546 or em == 413 or em == 471 or em == 500 then -- SAPD
triggerServerEvent ( "toggleVehicleSound1" , pojazd , "sapd_horn.ogg" , 225 )
cancelEvent ()
return
end
end
end
bindKey ( "i" , "down" , soundSwitch_lu12 )
-- SAPD + SAMC / SAMA
-- triggerClientEvent ( "createVehicleSound1" , source , dzwiek1 , range )
addEvent ( "createVehicleSound1" , true )
addEventHandler ( "createVehicleSound1" , root , function( dzwiek1 , range )
local snd1 = playSound3D ( dzwiek1 , 0 , 0 , 0 , true )
setSoundMaxDistance ( snd1 , range or 125 )
attachElements ( snd1 , source )
end )
addEvent ( "destroyVehicleSound1" , true )
addEventHandler ( "destroyVehicleSound1" , root , function()
local el = getAttachedElements ( source )
for i , v in ipairs ( el ) do
if getElementType ( v )== "sound" then
destroyElement ( v )
end
end
end )
-- triggerClientEvent ( "odtworzDzwiek1" , resourceRoot , dzwiek1 )
addEvent ( "odtworzDzwiek1" , true )
addEventHandler ( "odtworzDzwiek1" , resourceRoot , function( dzwiek1 )
if fileExists ( "audio/" .. dzwiek1 .. ".ogg" ) then
playSound ( "audio/" .. dzwiek1 .. ".ogg" )
elseif fileExists ( "audio/" .. dzwiek1 .. ".mp3" ) then
playSound ( "audio/" .. dzwiek1 .. ".mp3" )
end
end )
local lu130 ={}
addEvent ( "broadcastSound3D1" , true )
addEventHandler ( "broadcastSound3D1" , root , function( dzwiek1 , range , minrange , delay , bliskiKomunikat , dalekiKomunikat )
if delay then
if lu130 [ dzwiek1 ] and getTickCount ()- lu130 [ dzwiek1 ]< delay then
outputChatBox ( string . format ( "(( Musisz odczeka? %d sekund. ))" , delay / 1000 ), client , 255 , 0 , 0 )
return
end
lu130 [ dzwiek1 ]= getTickCount ()
end
triggerClientEvent ( "broadcastSound3D1" , source , dzwiek1 , range , minrange , bliskiKomunikat , dalekiKomunikat )
end )
addEvent ( "toggleVehicleSound1" , true )
addEventHandler ( "toggleVehicleSound1" , root , function( dzwiek1 , range )
local snd1 = getElementData ( source , "snd1:" .. dzwiek1 )
if snd1 then
triggerClientEvent ( "destroyVehicleSound1" , source , dzwiek1 )
setTimer ( removeElementData , 500 , 1 , source , "snd1:" .. dzwiek1 )
return
end
triggerClientEvent ( "createVehicleSound1" , source , dzwiek1 , range )
setElementData ( source , "snd1:" .. dzwiek1 , true )
end )
Wysłany: 2018-12-17, 18:22
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Pi?ty argument, looped, odpowiada za zap?tlanie d?wi?ku.
Więcej informacji znajdziesz w Wikipedii MTA: playSound3D
Więcej szczegółów
Wystawiono 1 piw(a):adisonboss
Wysłany: 2018-12-17, 18:33
adisonboss
Wiek: 23 Na forum: 3331 dni Posty: 237
Piwa : 6
Orientujesz si? mo?e gdzie to jest w tym skrypcie bo ni ciula nie mog? znale??
Wysłany: 2018-12-17, 19:13
Kalizman
Wiek: 23 Na forum: 3651 dni Posty: 1394
Piwa : 4619
adisonboss , ctrl+f w kodzie i fraza playSound3D (tak jak podal Wilq , ) co w tym trudnego?
Wysłany: 2018-12-18, 06:09
Dawcio77
Wiek: 22 Na forum: 3312 dni Posty: 89
Nick w MP: cx_u
Piwa : 136
U?ywasz eventHandler?w na client'a, czy skrypt kt?ry wys?a?e? jest po s-side? Je?li tak, wy?lij kod z skryptu c-side
Wysłany: 2018-12-18, 12:14
adisonboss
Wiek: 23 Na forum: 3331 dni Posty: 237
Piwa : 6
Dziena dzia?a Wilq ,
[ Dodano : 2018-12-18, 12:15 ]
Do zamkniecia
Tagi: odtwarzanie :: pętli
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: