olá gente, estou usando o Advanced Sound do Vyctor17 para soltar sons em certas posições, mais ou menos que nem o Rc-Sound, e queria pedir para alguém experiente fazer um Math.ramdon nessa script para tocar dois ou mais sons na mesma área sendo que aleatório os sons, e se vc entrar e sair dessa área, ela troca de musica aleatória também, que nem o pxg, ou padventures que os sistemas de sons lá é assim.
Script
Mostrar conteúdo oculto
require('advsound')require('ex')
SOUNDS_CONFIG ={
folder ='mods/Advanced Sound/Sounds/',
loop=false,
start_paused=false,
checkInterval =500,}local UPDATESOUND_OPCODE =85local PAUSESOUND_OPCODE =81
SOUNDS ={--area sounds
{fromPos ={x =000, y =000, z =0}, toPos ={x =000, y =000, z =0}, sound ="Musica.mp3"},}local toggleSoundEvent
local e
local audio =nillocal window =nillocal volume =100local str
function init()
connect(g_game,{ onGameEnd = terminate })
window = modules.client_options.audioPanel
str =string.explode(window:getChildById('musicSoundVolumeLabel'):getText(),":")
volume = tonumber(str[2])ProtocolGame.registerExtendedOpcode(UPDATESOUND_OPCODE, getSound)ProtocolGame.registerExtendedOpcode(PAUSESOUND_OPCODE, pauseSound)
e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)endfunction iniciar()if(g_game.isOnline())then
removeEvent(e)
toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)endendlocal m
function startAsound()local player = g_game.getLocalPlayer()ifnot player thenreturnendlocal pos = player:getPosition()for i =1,#SOUNDS doif(isInPos(pos, SOUNDS[i].fromPos, SOUNDS[i].toPos))thenif audio ==nilthen
m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS[i].sound,true, SOUNDS_CONFIG.start_paused)
str =string.explode(window:getChildById('musicSoundVolumeLabel'):getText(),":")
volume = tonumber(str[2])
advsound.setVolume(m, volume/100)
audio =trueendelse
audio =nil
advsound.setPaused(m,true)
removeEvent(toggleSoundEvent)endend
toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)endlocal music
function getSound(protocol, opcode, buffer)local cof =string.explode(buffer,"|")local conff ={["true"]=true,["false"]=false,}
music = advsound.playMusic(SOUNDS_CONFIG.folder..cof[1], conff[cof[2]], SOUNDS_CONFIG.start_paused)
str =string.explode(window:getChildById('musicSoundVolumeLabel'):getText(),":")
volume = tonumber(str[2])
advsound.setVolume(music, volume/100)endfunction pauseSound(protocol, opcode, buffer)if opcode ==81then
advsound.pauseAll()endendfunction terminate()
disconnect(g_game,{ onGameEnd = terminate })
e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)
audio =nil
advsound.pauseAll()endfunction isInPos(pos, fromPos, toPos)return
pos.x>=fromPos.x and
pos.y>=fromPos.y and
pos.z>=fromPos.z and
pos.x<=toPos.x and
pos.y<=toPos.y and
pos.z<=toPos.z
end
Pergunta
Developer Berg 65
olá gente, estou usando o Advanced Sound do Vyctor17 para soltar sons em certas posições, mais ou menos que nem o Rc-Sound, e queria pedir para alguém experiente fazer um Math.ramdon nessa script para tocar dois ou mais sons na mesma área sendo que aleatório os sons, e se vc entrar e sair dessa área, ela troca de musica aleatória também, que nem o pxg, ou padventures que os sistemas de sons lá é assim.
Script
up
Up
Up
up
up
Editado por ricardobergLink para o comentário
https://xtibia.com/forum/topic/239526-pedido-mathramdon-em-uma-script-de-sound-ambient/Compartilhar em outros sites
13 respostass a esta questão
Posts Recomendados