• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient MOD Problem, music in a zone of the map.

Udun

Well-Known Member
Joined
Jan 5, 2012
Messages
193
Solutions
1
Reaction score
67
Hello guys, I have some problems with this mod of Shawak (credits to him) that I found in TibiaKing, It would cool that would works.
Is about the music on map mod, should be just put some coordinates of an area that you want and should work, but it doesn't work, I dont know is something is wrong with the code (maybe incomplete?) or the specific place where the mod has to go on OTclient (personally I think that's is this), so I puted this serveral scripts on my otc, as the tutorial of Tibia King says, on:

otclient/mods/ ---> then I created the folder rcsound

Inside rcsoun should go:

rcsound.lua
Lua:
SOUNDS_CONFIG = {
    soundChannel = SoundChannels.Music,
    checkInterval = 500,
    folder = 'music/',
    noSound = 'No sound file for this area.',
}


SOUNDS = {
    -- Rook Cave
    {fromPos = {x=879, y=803, z=8}, toPos = {x=1079, y=963, z=15}, sound = "FF VII - Main.ogg"},
   
        -- Boss
        {fromPos = {x=977, y=903, z=8}, toPos = {x=1009, y=916, z=9}, priority = 1, sound="FF VII - Main.ogg"},
        {fromPos = {x=1001, y=917, z=9}, toPos = {x=1002, y=919, z=9}, priority = 1, sound="FF VII - Main.ogg"},
   
    -- Main
   
        -- Dragon
        {fromPos = {x=1089, y=1110, z=8}, toPos = {x=1135, y=1142, z=8}, priority = 1, sound="Fairy Tail - Main.ogg"},
        {fromPos = {x=1102, y=1128, z=9}, toPos = {x=1131, y=1149, z=9}, priority = 1, sound="Fairy Tail - Main.ogg"},
        {fromPos = {x=1117, y=1124, z=9}, toPos = {x=1128, y=1127, z=9}, priority = 1, sound="Fairy Tail - Main.ogg"},
        {fromPos = {x=1100, y=1104, z=10}, toPos = {x=1127, y=1131, z=10}, priority = 1, sound="Fairy Tail - Main.ogg"},
        {fromPos = {x=1103, y=1108, z=9}, toPos = {x=1108, y=1112, z=9}, priority = 1, sound="Fairy Tail - Main.ogg"},


        {fromPos = {x=1096, y=1088, z=5}, toPos = {x=1110, y=1100, z=6}, priority = 1, sound="Fairy Tail - Main.ogg"},


       
       
} ----------


-- Sound
local rcSoundChannel
local showPosEvent
local playingSound


-- Design
soundWindow = nil
soundButton = nil


function toggle()
  if soundButton:isOn() then
    soundWindow:close()
    soundButton:setOn(false)
  else
    soundWindow:open()
    soundButton:setOn(true)
  end
end


function onMiniWindowClose()
  soundButton:setOn(false)
end


function init()
    for i = 1, #SOUNDS do
        SOUNDS[i].sound = SOUNDS_CONFIG.folder .. SOUNDS[i].sound
    end
   
    connect(g_game, { onGameStart = onGameStart,
                    onGameEnd = onGameEnd })
   
    rcSoundChannel = g_sounds.getChannel(SOUNDS_CONFIG.soundChannel)
    -- rcSoundChannel:setGain(value/COUNDS_CONFIG.volume)


    soundButton = modules.client_topmenu.addRightGameToggleButton('soundButton', tr('Sound Info') .. '', '/images/audio', toggle)
    soundButton:setOn(true)
   
    soundWindow = g_ui.loadUI('rcsound', modules.game_interface.getRightPanel())
    soundWindow:disableResize()
    soundWindow:setup()
   
    if(g_game.isOnline()) then
        onGameStart()
    end
end


function terminate()
    disconnect(g_game, { onGameStart = onGameStart,
                       onGameEnd = onGameEnd })
    onGameEnd()
    soundWindow:destroy()
    soundButton:destroy()
end


function onGameStart()
    stopSound()
    toggleSoundEvent = addEvent(toggleSound, SOUNDS_CONFIG.checkInterval)
end


function onGameEnd()
    stopSound()
    removeEvent(toggleSoundEvent)
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


function toggleSound()
    local player = g_game.getLocalPlayer()
    if not player then return end
   
    local pos = player:getPosition()
    local toPlay = nil


    for i = 1, #SOUNDS do
        if(isInPos(pos, SOUNDS[i].fromPos, SOUNDS[i].toPos)) then
            if(toPlay) then
                toPlay.priority = toPlay.priority or 0
                if((toPlay.sound~=SOUNDS[i].sound) and (SOUNDS[i].priority>toPlay.priority)) then
                    toPlay = SOUNDS[i]
                end
            else
                toPlay = SOUNDS[i]
            end
        end
    end


    playingSound = playingSound or {sound='', priority=0}
   
    if(toPlay~=nil and playingSound.sound~=toPlay.sound) then
        g_logger.info("RC Sounds: New sound area detected:")
        g_logger.info("  Position: {x=" .. pos.x .. ", y=" .. pos.y .. ", z=" .. pos.z .. "}")
        g_logger.info("  Music: " .. toPlay.sound)
        stopSound()
        playSound(toPlay.sound)
        playingSound = toPlay
    elseif(toPlay==nil) and (playingSound.sound~='') then
        g_logger.info("RC Sounds: New sound area detected:")
        g_logger.info("  Left music area.")
        stopSound()
    end


    toggleSoundEvent = scheduleEvent(toggleSound, SOUNDS_CONFIG.checkInterval)
end


function playSound(sound)
    rcSoundChannel:enqueue(sound, 0)
    setLabel(clearName(sound))
end


function clearName(soundName)
    local explode = string.explode(soundName, "/")
    soundName = explode[#explode]
    explode = string.explode(soundName, ".ogg")
    soundName = ''
    for i = 1, #explode-1 do
        soundName = soundName .. explode[i]
    end
    return soundName
end


function stopSound()
    setLabel(SOUNDS_CONFIG.noSound)
    rcSoundChannel:stop()
    playingSound = nil
end


function setLabel(str)
    soundWindow:recursiveGetChildById('currentSound'):getChildById('value'):setText(str)
end

rcsound.otmod
Lua:
Module
  name: rc_sound
  description: Handels sounds for Rising Client.
  author: Shawak
  website: none
 
  autoload: true
  autoload-priority: 1000
  sandbox: true
 
  scripts: [ rcsound ]
  @onLoad: init()
  @onUnload: terminate()

rcsound.otui
Lua:
Module
  name: rc_sound
  description: Handels sounds for Rising Client.
  author: Shawak
  website: none
 
  autoload: true
  autoload-priority: 1000
  sandbox: true
 
  scripts: [ rcsound ]
  @onLoad: init()
  @onUnload: terminate()

Additional to this, I had to create a file inside of otclient/mods/rcsound called music, here must be the music files for the music areas in format .ogg
Well, I did all this, and it creates a bug, that when the otc is opened the music of the startup keeps going inside the game eternaly, if I remove the file rcsound of the mods folder the startup music shuts up when the player enters, the normal thing...
So... Anybody knows how fix it or make it work? O where must put all this?
I tried to put it on modules, but doesn't work, I put it on the client's folder and causes a bug on otc...
so anybody?
Thanks in advance!
 
im almost in the same stuff, i edited the lua something like this
Code:
-- Main
    
        -- Dragon
        {fromPos = {x=33166, y=31807, z=8}, toPos = {x=33169, y=31804, z=8}, priority = 1, sound="Fairy Tail - Main.ogg"},

but runing in that range doesnot seems to trigger the music U.U
 
your problem is like the mine? do you try to set the frompos and topos? i think the mod stuff is gr8 but i would love to have a kind of guide or tutorial = )
 
bump! We're need help! D:


broooo if u press ctr + t you would see the console(new shit i lerned today = 3 ) i found this error


ERROR: audio buffer underrun
at:
[C++]: StreamSoundSource::update

dont get what is it U.U but i guess it could help
 
broooo if u press ctr + t you would see the console(new shit i lerned today = 3 ) i found this error


ERROR: audio buffer underrun
at:
[C++]: StreamSoundSource::update

dont get what is it U.U but i guess it could help

Damn, idk men, if is something in the game sources it will be more diffucult, I dont know anything of source editing
Do you know smething about that?
 
not on windows XD i needed to download a compiled realese, im getting trouble to intall the vpgk stuff U.U, but let me check what i can do, u can compile in windows the otc?
 
not on windows XD i needed to download a compiled realese, im getting trouble to intall the vpgk stuff U.U, but let me check what i can do, u can compile in windows the otc?

heey man, I found this on github
a complete guide to compile otc. I need some time to try all this stuff. But I'm not sure if this will fix this and other problems, hopefully it will.
 
Back
Top