Jump to content

[Ayuda] Sonido al Spawnear SlothBot


Narutimmy

Recommended Posts

Posted

Hola bueno lo que pasa es que quiero que al spawnear el slothbot se reproduca un sonido, primero me pase por la wiki y estube intentando tanto con el playsound como el 3d pero no funciono :/

esto es lo que ise:

function Bot ( ) 
    local random = math.random ( #randomSpawnTable ) 
    local x, y, z = unpack ( randomSpawnTable [ random ] ) 
    slothbot = exports [ "slothbot" ]:spawnBot ( x, y, z, 90, 33, 0, 0, BOSS, 38, hunting, true ) 
    exports.extra_health:setElementExtraHealth ( slothbot, 50000) 
    outputChatBox ( "#ff0000Nemesis: #eeff00S.T.A.R.S!!!", getRootElement(), 255, 255, 255, true ) 
    playSound("nemesis.mp3") 
     
end 
addEventHandler ( "onResourceStart", resourceRoot, Bot ) 
setTimer(Bot,1800000,0) 

Posted

Eso es porque es una funcion client side, y el script tuyo es server side.

Tenes que usar:

triggerClientEvent 

-- server side:

function Bot ( ) 
    local random = math.random ( #randomSpawnTable ) 
    local x, y, z = unpack ( randomSpawnTable [ random ] ) 
    slothbot = exports [ "slothbot" ]:spawnBot ( x, y, z, 90, 33, 0, 0, BOSS, 38, hunting, true ) 
    exports.extra_health:setElementExtraHealth ( slothbot, 50000 ) 
    outputChatBox ( "#ff0000Nemesis: #eeff00S.T.A.R.S!!!", getRootElement(), 255, 255, 255, true ) 
    triggerClientEvent ( "playTheSound", root ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, Bot ) 
setTimer ( Bot, 1800000, 0 ) 

-- client side:

addEvent ( "playTheSound", true ) 
addEventHandler ( "playTheSound", root, 
    function ( ) 
        playSound ( "nemesis.mp3" ) 
    end 
) 

Posted
Eso es porque es una funcion client side, y el script tuyo es server side.

Tenes que usar:

triggerClientEvent 

-- server side:

function Bot ( ) 
    local random = math.random ( #randomSpawnTable ) 
    local x, y, z = unpack ( randomSpawnTable [ random ] ) 
    slothbot = exports [ "slothbot" ]:spawnBot ( x, y, z, 90, 33, 0, 0, BOSS, 38, hunting, true ) 
    exports.extra_health:setElementExtraHealth ( slothbot, 50000 ) 
    outputChatBox ( "#ff0000Nemesis: #eeff00S.T.A.R.S!!!", getRootElement(), 255, 255, 255, true ) 
    triggerClientEvent ( "playTheSound", root ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, Bot ) 
setTimer ( Bot, 1800000, 0 ) 

-- client side:

addEvent ( "playTheSound", true ) 
addEventHandler ( "playTheSound", root, 
    function ( ) 
        playSound ( "nemesis.mp3" ) 
    end 
) 

Antes se Dañaba el Scrip, pero asi como me lo pones no se daño, pero tampoco se Reproduce el Sonido :/

Posted

Donde pusiste:

addEvent ( "playTheSound", true ) 
addEventHandler ( "playTheSound", root, 
    function ( ) 
        playSound ( "nemesis.mp3" ) 
    end 
) 

Posted
Donde pusiste:
addEvent ( "playTheSound", true ) 
addEventHandler ( "playTheSound", root, 
    function ( ) 
        playSound ( "nemesis.mp3" ) 
    end 
) 

dentro de

Porque es client, esta mal?

Posted
Eso esta bien.

Pero no va a funcionar, porque el script client side aun no cargo, y el server side ya intenta enviar el evento.

Entonses no se va a poder? tendrian que estar los 2 en client?

Posted
Y eso no es posible, porque los slothbot son server side.

Que suerte ya Funciono ;D, con el primer spawn no funciona, pero como el slothbot se spawnea cada 10mins pues ya carga la otro y si se reproduce, gracias

  • Recently Browsing   0 members

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