Ir para conteúdo
  • 0

Ajuda Com Tabela.


Developer Berg

Pergunta

Olá Gente, queria pedir a ajuda de vcs hoje, estou usando o mod Advanced Sound do Vyctor17, mas tem um bug na tabela do mod de sound, tipo assim a tabela é essa.

SOUNDS = {--area sounds
	{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
}

se eu colocar somente um lugar com som nessa tabela funciona normalmente, mas se eu acrescentar 2 tags na tabela, para adicionar som em outros cantos alem desse canto que ta ai na tabela tipo assim.

SOUNDS = {--area sounds
	{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
	{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},
}

o som n toca, alias, o som das duas áreas n tocam, nem a primeira que no caso é a de saffron, e nem a segunda que é a de cerulean, só funciona quando tem somente uma tag na tabela que nem o primeiro exemplo que mostrei e vou mostrar agr denovo.

SOUNDS = {--area sounds
	{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
}

alguém me ajuda pfv, queria poder colocar sons em mais áreas da tabela sem parar de funcionar os sons.

 

Script.

 

 

 

require('advsound')
require('ex')

SOUNDS_CONFIG = {
	folder = 'mods/Advanced Sound/Sounds/',
	loop=false,
	start_paused=false,
	checkInterval = 500,
}



local UPDATESOUND_OPCODE = 85
local PAUSESOUND_OPCODE = 81

SOUNDS = {--area sounds
	{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
	{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},
}
local toggleSoundEvent
local e
local audio = nil
local window = nil
local volume = 100
local 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)
end
function iniciar()
	if (g_game.isOnline()) then
		removeEvent(e)
		toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)
	end
end

local m 
function startAsound()
	local player = g_game.getLocalPlayer()
	if not player then return end
	
	local pos = player:getPosition()
	for i = 1, #SOUNDS do
		if(isInPos(pos, SOUNDS[i].fromPos, SOUNDS[i].toPos)) then
			if audio == nil then
				m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS[i].sound[math.random(#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 = true
			end
		else
			audio = nil
			advsound.setPaused(m, true)
			removeEvent(toggleSoundEvent)
		end
	end
	toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)
end

local 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)
end


function pauseSound(protocol, opcode, buffer)
	if opcode == 81 then
		advsound.pauseAll()
	end
end

function terminate()
	disconnect(g_game, { onGameEnd = terminate })
	e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)
	audio = nil
	advsound.pauseAll()
end

function 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

 

 

Link para o comentário
Compartilhar em outros sites

Posts Recomendados

  • 0

Tente assim

 

require('advsound')

require('ex')

 

SOUNDS_CONFIG = {

folder = 'mods/Advanced Sound/Sounds/',

loop=false,

start_paused=false,

checkInterval = 500,

}

 

 

 

local UPDATESOUND_OPCODE = 85

local PAUSESOUND_OPCODE = 81

 

SOUNDS = {--area sounds

{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},

{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},

}

local toggleSoundEvent

local e

local audio = nil

local window = nil

local volume = 100

local 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)

end

function iniciar()

if (g_game.isOnline()) then

removeEvent(e)

toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

end

 

local m

function startAsound()

local player = g_game.getLocalPlayer()

if not player then return end

 

local pos = player:getPosition()

for i, k in pairs(SOUNDS) do

if(isInPos(pos, k.fromPos, k.toPos)) then

if audio == nil then

m = advsound.playMusic(SOUNDS_CONFIG.folder..k.sound[math.random(#k.sound)], true, SOUNDS_CONFIG.start_paused)

str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":")

volume = tonumber(str[2])

advsound.setVolume(m, volume/100)

audio = true

end

else

audio = nil

advsound.setPaused(m, true)

removeEvent(toggleSoundEvent)

end

end

toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

 

local 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)

end

 

 

function pauseSound(protocol, opcode, buffer)

if opcode == 81 then

advsound.pauseAll()

end

end

 

function terminate()

disconnect(g_game, { onGameEnd = terminate })

e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)

audio = nil

advsound.pauseAll()

end

 

function 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

Editado por Skulls
Link para o comentário
Compartilhar em outros sites

  • 0

Tente assim

 

require('advsound')

require('ex')

 

SOUNDS_CONFIG = {

folder = 'mods/Advanced Sound/Sounds/',

loop=false,

start_paused=false,

checkInterval = 500,

}

 

 

 

local UPDATESOUND_OPCODE = 85

local PAUSESOUND_OPCODE = 81

 

SOUNDS = {--area sounds

{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},

{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},

}

local toggleSoundEvent

local e

local audio = nil

local window = nil

local volume = 100

local 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)

end

function iniciar()

if (g_game.isOnline()) then

removeEvent(e)

toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

end

 

local m

function startAsound()

local player = g_game.getLocalPlayer()

if not player then return end

 

local pos = player:getPosition()

for i, k in pairs(SOUNDS) do

if(isInPos(pos, k.fromPos, k.toPos)) then

if audio == nil then

m = advsound.playMusic(SOUNDS_CONFIG.folder..k.sound[math.random(#k.sound)], true, SOUNDS_CONFIG.start_paused)

str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":")

volume = tonumber(str[2])

advsound.setVolume(m, volume/100)

audio = true

end

else

audio = nil

advsound.setPaused(m, true)

removeEvent(toggleSoundEvent)

end

end

toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

 

local 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)

end

 

 

function pauseSound(protocol, opcode, buffer)

if opcode == 81 then

advsound.pauseAll()

end

end

 

function terminate()

disconnect(g_game, { onGameEnd = terminate })

e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)

audio = nil

advsound.pauseAll()

end

 

function 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

skulls, n pegou, ainda continua sem tocar sons nas 2 tags :/ nem um dos 2 sons n funcionam.

Link para o comentário
Compartilhar em outros sites

  • 0
  • Diretor

Tou meio enferrujado mais vou te mandar uns aqui e você vai tentando, se não der certo por favor entre em contato comigo.

 

 

require('advsound')
require('ex')

SOUNDS_CONFIG = {
folder = 'mods/Advanced Sound/Sounds/',
loop=false,
start_paused=false,
checkInterval = 500,
}



local UPDATESOUND_OPCODE = 85
local PAUSESOUND_OPCODE = 81

SOUNDS = {--area sounds
{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"},
{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},
}
local toggleSoundEvent
local e
local audio = nil
local window = nil
local volume = 100
local 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)
end
function iniciar()
if (g_game.isOnline()) then
removeEvent(e)
toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)
end
end

local m
function startAsound()
local player = g_game.getLocalPlayer()
if not player then return end

local pos = player:getPosition()
for i = 1, #SOUNDS do
if(isInPos(pos, SOUNDS.fromPos, SOUNDS.toPos)) then
if audio == nil then
m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS.sound[math.random(#SOUNDS.sound)], true, SOUNDS_CONFIG.start_paused)
str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":")
volume = tonumber(str[2])
advsound.setVolume(m, volume/100)
audio = true
end
else
audio = nil
advsound.setPaused(m, true)
removeEvent(toggleSoundEvent)
end
end
toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)
end

local 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)
end


function pauseSound(protocol, opcode, buffer)
if opcode == 81 then
advsound.pauseAll()
end
end

function terminate()
disconnect(g_game, { onGameEnd = terminate })
e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)
audio = nil
advsound.pauseAll()
end

function 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

 

 

 

require('advsound')
require('ex')

SOUNDS_CONFIG = {
folder = 'mods/Advanced Sound/Sounds/',
loop=false,
start_paused=false,
checkInterval = 500,
}



local UPDATESOUND_OPCODE = 85
local PAUSESOUND_OPCODE = 81

SOUNDS = {{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
{{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},
}
local toggleSoundEvent
local e
local audio = nil
local window = nil
local volume = 100
local 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)
end
function iniciar()
if (g_game.isOnline()) then
removeEvent(e)
toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)
end
end

local m
function startAsound()
local player = g_game.getLocalPlayer()
if not player then return end

local pos = player:getPosition()
for i = 1, #SOUNDS do
if(isInPos(pos, SOUNDS.fromPos, SOUNDS.toPos)) then
if audio == nil then
m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS.sound[math.random(#SOUNDS.sound)], true, SOUNDS_CONFIG.start_paused)
str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":")
volume = tonumber(str[2])
advsound.setVolume(m, volume/100)
audio = true
end
else
audio = nil
advsound.setPaused(m, true)
removeEvent(toggleSoundEvent)
end
end
toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)
end

local 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)
end


function pauseSound(protocol, opcode, buffer)
if opcode == 81 then
advsound.pauseAll()
end
end

function terminate()
disconnect(g_game, { onGameEnd = terminate })
e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)
audio = nil
advsound.pauseAll()
end

function 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

 

 

 

require('advsound')
require('ex')

SOUNDS_CONFIG = {
folder = 'mods/Advanced Sound/Sounds/',
loop=false,
start_paused=false,
checkInterval = 500,
}



local UPDATESOUND_OPCODE = 85
local PAUSESOUND_OPCODE = 81

SOUNDS = {--area sounds
{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},
local toggleSoundEvent
local e
local audio = nil
local window = nil
local volume = 100
local 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)
end
function iniciar()
if (g_game.isOnline()) then
removeEvent(e)
toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)
end
end

local m
function startAsound()
local player = g_game.getLocalPlayer()
if not player then return end

local pos = player:getPosition()
for i = 1, #SOUNDS do
if(isInPos(pos, SOUNDS.fromPos, SOUNDS.toPos)) then
if audio == nil then
m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS.sound[math.random(#SOUNDS.sound)], true, SOUNDS_CONFIG.start_paused)
str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":")
volume = tonumber(str[2])
advsound.setVolume(m, volume/100)
audio = true
end
else
audio = nil
advsound.setPaused(m, true)
removeEvent(toggleSoundEvent)
end
end
toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)
end

local 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)
end


function pauseSound(protocol, opcode, buffer)
if opcode == 81 then
advsound.pauseAll()
end
end

function terminate()
disconnect(g_game, { onGameEnd = terminate })
e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)
audio = nil
advsound.pauseAll()
end

function 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

 

 

 

Ah ta bom kkkk fico esperando a resposta... Creio que teria que mudar um pouco este sistema para poder funcionar com mais de uma musica

 

Link para o comentário
Compartilhar em outros sites

  • 0

Tou meio enferrujado mais vou te mandar uns aqui e você vai tentando, se não der certo por favor entre em contato comigo.

 

 

require('advsound')

require('ex')

 

SOUNDS_CONFIG = {

folder = 'mods/Advanced Sound/Sounds/',

loop=false,

start_paused=false,

checkInterval = 500,

}

 

 

 

local UPDATESOUND_OPCODE = 85

local PAUSESOUND_OPCODE = 81

 

SOUNDS = {--area sounds

{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"},

{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},

}

local toggleSoundEvent

local e

local audio = nil

local window = nil

local volume = 100

local 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)

end

function iniciar()

if (g_game.isOnline()) then

removeEvent(e)

toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

end

 

local m

function startAsound()

local player = g_game.getLocalPlayer()

if not player then return end

 

local pos = player:getPosition()

for i = 1, #SOUNDS do

if(isInPos(pos, SOUNDS.fromPos, SOUNDS.toPos)) then

if audio == nil then

m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS.sound[math.random(#SOUNDS.sound)], true, SOUNDS_CONFIG.start_paused)

str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":")

volume = tonumber(str[2])

advsound.setVolume(m, volume/100)

audio = true

end

else

audio = nil

advsound.setPaused(m, true)

removeEvent(toggleSoundEvent)

end

end

toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

 

local 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)

end

 

 

function pauseSound(protocol, opcode, buffer)

if opcode == 81 then

advsound.pauseAll()

end

end

 

function terminate()

disconnect(g_game, { onGameEnd = terminate })

e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)

audio = nil

advsound.pauseAll()

end

 

function 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

 

 

 

require('advsound')

require('ex')

 

SOUNDS_CONFIG = {

folder = 'mods/Advanced Sound/Sounds/',

loop=false,

start_paused=false,

checkInterval = 500,

}

 

 

 

local UPDATESOUND_OPCODE = 85

local PAUSESOUND_OPCODE = 81

 

SOUNDS = {{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},

{{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},

}

local toggleSoundEvent

local e

local audio = nil

local window = nil

local volume = 100

local 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)

end

function iniciar()

if (g_game.isOnline()) then

removeEvent(e)

toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

end

 

local m

function startAsound()

local player = g_game.getLocalPlayer()

if not player then return end

 

local pos = player:getPosition()

for i = 1, #SOUNDS do

if(isInPos(pos, SOUNDS.fromPos, SOUNDS.toPos)) then

if audio == nil then

m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS.sound[math.random(#SOUNDS.sound)], true, SOUNDS_CONFIG.start_paused)

str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":")

volume = tonumber(str[2])

advsound.setVolume(m, volume/100)

audio = true

end

else

audio = nil

advsound.setPaused(m, true)

removeEvent(toggleSoundEvent)

end

end

toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

 

local 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)

end

 

 

function pauseSound(protocol, opcode, buffer)

if opcode == 81 then

advsound.pauseAll()

end

end

 

function terminate()

disconnect(g_game, { onGameEnd = terminate })

e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)

audio = nil

advsound.pauseAll()

end

 

function 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

 

 

 

require('advsound')

require('ex')

 

SOUNDS_CONFIG = {

folder = 'mods/Advanced Sound/Sounds/',

loop=false,

start_paused=false,

checkInterval = 500,

}

 

 

 

local UPDATESOUND_OPCODE = 85

local PAUSESOUND_OPCODE = 81

 

SOUNDS = {--area sounds

{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},

{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}},

local toggleSoundEvent

local e

local audio = nil

local window = nil

local volume = 100

local 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)

end

function iniciar()

if (g_game.isOnline()) then

removeEvent(e)

toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

end

 

local m

function startAsound()

local player = g_game.getLocalPlayer()

if not player then return end

 

local pos = player:getPosition()

for i = 1, #SOUNDS do

if(isInPos(pos, SOUNDS.fromPos, SOUNDS.toPos)) then

if audio == nil then

m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS.sound[math.random(#SOUNDS.sound)], true, SOUNDS_CONFIG.start_paused)

str = string.explode(window:getChildById('musicSoundVolumeLabel'):getText(), ":")

volume = tonumber(str[2])

advsound.setVolume(m, volume/100)

audio = true

end

else

audio = nil

advsound.setPaused(m, true)

removeEvent(toggleSoundEvent)

end

end

toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)

end

 

local 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)

end

 

 

function pauseSound(protocol, opcode, buffer)

if opcode == 81 then

advsound.pauseAll()

end

end

 

function terminate()

disconnect(g_game, { onGameEnd = terminate })

e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)

audio = nil

advsound.pauseAll()

end

 

function 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

 

 

 

Ah ta bom kkkk fico esperando a resposta... Creio que teria que mudar um pouco este sistema para poder funcionar com mais de uma musica

 

no primeiro script deu esse erro.

ERROR: Unable to load module 'Advanced Sound': LUA ERROR: /Advanced Sound/Adsound.lua:20: '}' expected (to close '{' at line 16) near 'local'
stack traceback:
    [C]: ?
    [C]: in function 'autoLoadModules'
    /init.lua:49: in main chunk

no segundo deu esse.

ERROR: Unable to load module 'Advanced Sound': LUA ERROR: /Advanced Sound/Adsound.lua:19: '}' expected (to close '{' at line 16) near 'local'
stack traceback:
    [C]: ?
    [C]: in function 'autoLoadModules'
    /init.lua:49: in main chunk

e no terceiro deu esse.

ERROR: Unable to load module 'Advanced Sound': LUA ERROR: /Advanced Sound/Adsound.lua:19: unexpected symbol near 'local'
stack traceback:
    [C]: ?
    [C]: in function 'autoLoadModules'
    /init.lua:49: in main chunk
Link para o comentário
Compartilhar em outros sites

  • 0
  • Diretor

é imaginei que daria bosta mesmo... mano acho que não tem jeito mesmo de por mais de 1 musica.

 

Você já tentou remover a ultima virgula da segunda linha?

{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}}

como muitos sabem em scripts muitas funções igual essa por exemplo não é necessário usar a , na ultima line

Link para o comentário
Compartilhar em outros sites

  • 0

é imaginei que daria bosta mesmo... mano acho que não tem jeito mesmo de por mais de 1 musica.

 

Você já tentou remover a ultima virgula da segunda linha?

{fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
{fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}}

como muitos sabem em scripts muitas funções igual essa por exemplo não é necessário usar a , na ultima line

ss :/ mais n foi :/

Link para o comentário
Compartilhar em outros sites

  • 0

Não que eu esteja botando mt fé.... Mas vai que cola... :v

 

Tenta assim:

require('advsound')
require('ex')

SOUNDS_CONFIG = {
	folder = 'mods/Advanced Sound/Sounds/',
	loop=false,
	start_paused=false,
	checkInterval = 500,
}



local UPDATESOUND_OPCODE = 85
local PAUSESOUND_OPCODE = 81

SOUNDS = {--area sounds
	[1] = {fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
	[2] = {fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}}
}
local toggleSoundEvent
local e
local audio = nil
local window = nil
local volume = 100
local 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)
end
function iniciar()
	if (g_game.isOnline()) then
		removeEvent(e)
		toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)
	end
end

local m 
function startAsound()
	local player = g_game.getLocalPlayer()
	if not player then return end
	
	local pos = player:getPosition()
	for i = 1, #SOUNDS do
		if(isInPos(pos, SOUNDS[i].fromPos, SOUNDS[i].toPos)) then
			if audio == nil then
				m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS[i].sound[math.random(#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 = true
			end
		else
			audio = nil
			advsound.setPaused(m, true)
			removeEvent(toggleSoundEvent)
		end
	end
	toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)
end

local 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)
end


function pauseSound(protocol, opcode, buffer)
	if opcode == 81 then
		advsound.pauseAll()
	end
end

function terminate()
	disconnect(g_game, { onGameEnd = terminate })
	e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)
	audio = nil
	advsound.pauseAll()
end

function 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
Link para o comentário
Compartilhar em outros sites

  • 0

 

Não que eu esteja botando mt fé.... Mas vai que cola... :v

 

Tenta assim:

require('advsound')
require('ex')

SOUNDS_CONFIG = {
	folder = 'mods/Advanced Sound/Sounds/',
	loop=false,
	start_paused=false,
	checkInterval = 500,
}



local UPDATESOUND_OPCODE = 85
local PAUSESOUND_OPCODE = 81

SOUNDS = {--area sounds
	[1] = {fromPos = {x = 1045, y = 1042, z = 7}, toPos = {x = 1065, y = 1055, z = 7}, sound = {"Saffron.mp3", "Saffron2.mp3"}},
	[2] = {fromPos = {x = 1045, y = 1091, z = 7}, toPos = {x = 1057, y = 1103, z = 7}, sound = {"Cerulean.mp3", "Cerulean2.mp3"}}
}
local toggleSoundEvent
local e
local audio = nil
local window = nil
local volume = 100
local 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)
end
function iniciar()
	if (g_game.isOnline()) then
		removeEvent(e)
		toggleSoundEvent = addEvent(startAsound, SOUNDS_CONFIG.checkInterval)
	end
end

local m 
function startAsound()
	local player = g_game.getLocalPlayer()
	if not player then return end
	
	local pos = player:getPosition()
	for i = 1, #SOUNDS do
		if(isInPos(pos, SOUNDS[i].fromPos, SOUNDS[i].toPos)) then
			if audio == nil then
				m = advsound.playMusic(SOUNDS_CONFIG.folder..SOUNDS[i].sound[math.random(#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 = true
			end
		else
			audio = nil
			advsound.setPaused(m, true)
			removeEvent(toggleSoundEvent)
		end
	end
	toggleSoundEvent = scheduleEvent(startAsound, SOUNDS_CONFIG.checkInterval)
end

local 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)
end


function pauseSound(protocol, opcode, buffer)
	if opcode == 81 then
		advsound.pauseAll()
	end
end

function terminate()
	disconnect(g_game, { onGameEnd = terminate })
	e = cycleEvent(iniciar, SOUNDS_CONFIG.checkInterval)
	audio = nil
	advsound.pauseAll()
end

function 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

n funcionou, mas tipo, na segunda posição, quando eu entro nela, no caso a posição da segunda tag, fica tocando o comecinho da musica, e fica se repetindo, tipo o comecinho mesmo, tipo 1 segundo da musica só, ai para e começa denovo, e na posição da primeira tag n funcionou, n tocou nada.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...