I have tried multiple ways to attempt to detect when the player gets on a flight path, but the only thing I have unfortunately got to work is when the player loses control which is a bad solution. Unfortunately for me I deleted all of the old code attempts out of the file when I finished it at 3 am and I wasn't thinking straight at that time, so I did not realize at the time what it was exactly that I had done. So now I have the issue of the button showing up every time the player loses control. I added in the slash command to hide and show the button when I realized this, but that is more of a stop gap than anything else.
I know that just: if UnitonTaxi("player") is not enough to trigger the button to show. I'm pretty sure I need to use the OnTaxi to get it to work properly with a more complicated check, but I'm having difficulty doing that properly.
Here is the code:
local name = "StopFrame"
local RequestButtonEnable
local RequestFrame = CreateFrame("Frame", "RequestFrame")
SLASH_SRB1 = '/srb';
function StopRequestHandler(self, event, ...)
--print("|cffcc33ff We made it here")
if event == "PLAYER_ENTERING_WORLD" then
-- print("|cffcc33ff Welcome to Azeroth")
StopButton:Hide()
elseif event == "PLAYER_CONTROL_GAINED" then
-- print("Not on Flight Path")
-- OnTaxi = nil
StopButton:Hide()
elseif not UnitOnTaxi("player") then
-- print("On Flight Path")
StopButton:Show()
end
end
RequestFrame:SetPoint("CENTER", 180, -180)
RequestFrame:RegisterEvent("UnitOnTaxi")
RequestFrame:RegisterEvent("PLAYER_CONTROL_GAINED")
RequestFrame:RegisterEvent("VEHICLE_UPDATE")
RequestFrame:RegisterEvent("PLAYER_CONTROL_LOST")
RequestFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
RequestFrame:SetScript("OnEvent", StopRequestHandler)
local template = "UIPanelButtonTemplate"
local StopButton = CreateFrame("Button", "StopButton", UIParent, "UIPanelButtonTemplate")
StopButton:SetSize(120, 50)
StopButton:SetText("Request Stop")
StopButton:SetPoint("CENTER", 180, -180)
StopButton:SetScript("OnClick", function()
RaidNotice_AddMessage(RaidWarningFrame, "|cffcc33ff Okay|r |cff00ccff "..UnitName("player").."|r |cffcc33ff Stopping at the next Flight Master.|r", ChatTypeInfo["RAID_WARNING"])
print("|cffcc33ff Okay|r |cff00ccff "..UnitName("player").."|r |cffcc33ff Stopping at the next Flight Master.|r");
TaxiRequestEarlyLanding()
end)
function SlashCmdList.SRB()
if StopButton:IsVisible() then
StopButton:Hide()
else
StopButton:Show()
end
end
0
I have tried multiple ways to attempt to detect when the player gets on a flight path, but the only thing I have unfortunately got to work is when the player loses control which is a bad solution. Unfortunately for me I deleted all of the old code attempts out of the file when I finished it at 3 am and I wasn't thinking straight at that time, so I did not realize at the time what it was exactly that I had done. So now I have the issue of the button showing up every time the player loses control. I added in the slash command to hide and show the button when I realized this, but that is more of a stop gap than anything else.
I know that just: if UnitonTaxi("player") is not enough to trigger the button to show. I'm pretty sure I need to use the OnTaxi to get it to work properly with a more complicated check, but I'm having difficulty doing that properly.
Here is the code: