Jump to content

[Ayuda] Sonido al Spawn de Zombie


Narutimmy

Recommended Posts

Posted

Hola bueno rato sin pasar por aqui, vengo en busca de ayuda, la idea es que al spawnear un zombi (DayZ) se reprodusca un sonido (gemido de zombie) en donde aparece... el problema es que si funciona pero al morir el zombie el sonido sigue reproduciendose, lo que quiero es que cuando spawnee, solo se escuche el sonido por unos 10 segundos y luego deje de sonar, intente con stopsound y destroyelement pero no me funciono :/

function zombieSpawning() 
 for i, ped in ipairs(getElementsByType("ped")) do 
--PLAY ZOMBIE SOUNDS 
local Zx,Zy,Zz = getElementPosition( ped ) 
local randnum = math.random(1,10) 
local gemido = playSound3D("sounds/mgroan"..randnum..".ogg", Zx, Zy, Zz, false) 
setSoundMaxDistance(gemido, 20) 
  
  
  local x, y, z = getElementPosition(getLocalPlayer()) 
  local material, hitX, hitY, hitZ = isObjectAroundPlayer2(getLocalPlayer(), 30, 3) 
  if material == 0 and not isInBuilding(x, y, z) then 
    triggerServerEvent("createZomieForPlayer", getLocalPlayer(), hitX, hitY, hitZ) 
  end 
end 
end 
setTimer(zombieSpawning, 3000, 0) 

  • MTA Team
Posted

Eso es porque tenes un timer infinito...

--

usa esto, o un trigger desde el server side:

  
function zombieSpawning() 
 for i, ped in ipairs(getElementsByType("ped")) do 
--PLAY ZOMBIE SOUNDS 
local Zx,Zy,Zz = getElementPosition( ped ) 
local randnum = math.random(1,10) 
local gemido = playSound3D("sounds/mgroan"..randnum..".ogg", Zx, Zy, Zz, false) 
setSoundMaxDistance(gemido, 20) 
  
  
  local x, y, z = getElementPosition(getLocalPlayer()) 
  local material, hitX, hitY, hitZ = isObjectAroundPlayer2(getLocalPlayer(), 30, 3) 
  if material == 0 and not isInBuilding(x, y, z) then 
    triggerServerEvent("createZomieForPlayer", getLocalPlayer(), hitX, hitY, hitZ) 
  end 
end 
end 
addCommandHandler("gemido",zombieSpawning) 

Posted
Eso es porque tenes un timer infinito...

--

usa esto, o un trigger desde el server side:

  
function zombieSpawning() 
 for i, ped in ipairs(getElementsByType("ped")) do 
--PLAY ZOMBIE SOUNDS 
local Zx,Zy,Zz = getElementPosition( ped ) 
local randnum = math.random(1,10) 
local gemido = playSound3D("sounds/mgroan"..randnum..".ogg", Zx, Zy, Zz, false) 
setSoundMaxDistance(gemido, 20) 
  
  
  local x, y, z = getElementPosition(getLocalPlayer()) 
  local material, hitX, hitY, hitZ = isObjectAroundPlayer2(getLocalPlayer(), 30, 3) 
  if material == 0 and not isInBuilding(x, y, z) then 
    triggerServerEvent("createZomieForPlayer", getLocalPlayer(), hitX, hitY, hitZ) 
  end 
end 
end 
addCommandHandler("gemido",zombieSpawning) 

pero necesito el timer ya que es lo que spawnea a los zombies, solo que cada zombie genera un sonido que no termina, la idea es que dejen de sonar a los 10 seg .

  • MTA Team
Posted
  
  
function zombieSpawning() 
 for i, ped in ipairs(getElementsByType("ped")) do 
--PLAY ZOMBIE SOUNDS 
local Zx,Zy,Zz = getElementPosition( ped ) 
local randnum = math.random(1,10) 
local gemido = playSound3D("sounds/mgroan"..randnum..".ogg", Zx, Zy, Zz, false) 
setSoundMaxDistance(gemido, 20) 
if gemido then 
setTimer(function () stopSound(gemido),10000,1) 
end 
  local x, y, z = getElementPosition(getLocalPlayer()) 
  local material, hitX, hitY, hitZ = isObjectAroundPlayer2(getLocalPlayer(), 30, 3) 
  if material == 0 and not isInBuilding(x, y, z) then 
    triggerServerEvent("createZomieForPlayer", getLocalPlayer(), hitX, hitY, hitZ) 
  end 
end 
end 
setTimer(zombieSpawning, 3000, 0) 
  

Posted

Ignora lo que puso ciber, está mal.

Lo que puedes intentar hacer es que cuando el zombie sea asesinado (onZombieWasted creo que es o onPedWasted), hacer un tiggerClientEvent y ahí stopSoundeas el sonido. Espero haberme explicado!

  • MTA Team
Posted

@Renkon deja que lo pruebe antes de decir que esta mal.Para que usarias un trigger client side si el script es client side? es ilogico.Lo que puede hacer es triggear una funcion dentro del mismo script client side.

Posted
@Renkon deja que lo pruebe antes de decir que esta mal.Para que usarias un trigger client side si el script es client side? es ilogico.Lo que puede hacer es triggear una funcion dentro del mismo script client side.

No.

Posted
@Renkon deja que lo pruebe antes de decir que esta mal.Para que usarias un trigger client side si el script es client side? es ilogico.Lo que puede hacer es triggear una funcion dentro del mismo script client side.

Ya con poner esto

setTimer(function () stopSound(gemido),10000,1) 

Tus argumentos son inválidos

onZombieWasted o onPedWasted es serverside.. o eso creo al menos

Posted

Bueno lo intente de la forma quer dijo "CiBeR~! " y no funciono me daba Error en el Timer en un "," algo asi decia. asi que lo probe asi y me funciono:

function soundzombies () 
 for i, ped in ipairs(getElementsByType("ped")) do 
--PLAY ZOMBIE SOUNDS 
local Zx,Zy,Zz = getElementPosition( ped ) 
local randnum = math.random(1,10) 
local gemido = playSound3D("http://sonidosmp3gratis.com/sounds/casa_3.mp3", Zx, Zy, Zz, false) 
setSoundMaxDistance(gemido, 20) 
  
  
end 
end 
  
function stops () 
  
stopSound(gemido) 
  
  
end 
  
setTimer(stops, 10000, 1) 
setTimer(soundzombies, 60000, 0) 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...