-- OT-MMO: botín automático. El servidor (server/scripts/autobotin.lua) guarda el interruptor por personaje y manda por -- el opcode 126 «A|1» (activo) o «A|0». El botón vive en el micromenú de game_hud; aquí solo se guarda el estado y se pide -- el cambio: «T» alterna. Comando de respaldo: !botin [on|off]. local OPCODE = 126 local activoAhora = false autobotinController = Controller:new() local function avisarHud() local hud = modules.game_hud if hud and hud.marcarAutobotin then hud.marcarAutobotin(activoAhora) end end function activo() return activoAhora end function alternar() local protocol = g_game.getProtocolGame() if protocol then protocol:sendExtendedOpcode(OPCODE, 'T') end end local function onOpcode(protocol, opcode, buffer) if buffer:sub(1, 2) ~= 'A|' then return end activoAhora = buffer:sub(3, 3) == '1' avisarHud() end function autobotinController:onInit() ProtocolGame.registerExtendedOpcode(OPCODE, onOpcode) if g_game.isOnline() then -- recargado a mitad de partida self:onGameStart() end end function autobotinController:onGameStart() activoAhora = false avisarHud() -- Al entrar se pide el estado: lo que el servidor manda en el primer instante del login puede perderse. scheduleEvent(function() local protocol = g_game.getProtocolGame() if protocol then protocol:sendExtendedOpcode(OPCODE, 'P') end end, 1000) end function autobotinController:onGameEnd() activoAhora = false avisarHud() end function autobotinController:onTerminate() ProtocolGame.unregisterExtendedOpcode(OPCODE) end