• 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!

TFS 1.X+ Nekiro 7.72 downgrade | Modal window issue

Rondel

Active Member
Joined
Feb 1, 2022
Messages
12
Reaction score
30
Hey, I've tried implementing modal window but I've encountered an issue - the modal window shows, however I don't get response when I click the buttons. I'm using OTCv8 and downgraded 7.72 TFS by Nekiro. I've followed the TFS 1.X+ - ModalWindow not executing functions (https://otland.net/threads/modalwindow-not-executing-functions.280727/) thread and uncommented the Game::playerAnswerModalWindow function in game.cpp aswell as ProtocolGame::parseModalWindowAnswer function in protocolgame.cpp. Perhaps all of this wasn't needed and the implementation is wrong :D. I tried implementing it that way:
Lua:
local action = Action()
function action.onUse(player, item, fromPos, target, toPos, isHotkey)
  player:registerEvent("ModalWindowTest")
  local title = "Anti-mistake prompt"
  local message = "Are you sure that you want to use the teleportation scroll?"
  local window = ModalWindow(1111, title, message)
  window:addButton(100, "Yes")
  window:addButton(101, "No")
  window:setDefaultEnterButton(100)
  window:getDefaultEscapeButton(101)
  window:sendToPlayer(player)
  return true
end
action:id(1949)
action:register()
local creatureEvent = CreatureEvent("ModalWindowTest")
function creatureEvent.onModalWindow(player, modalWindowId, buttonId, choiceId)
  
  if modalWindowId == 1111 then
    if buttonId == 100 then
      print("yes")
    end
  end
  
  player:unregisterEvent("ModalWindowTest")
  return true
end
creatureEvent:register()
 
Back
Top