You need at least 2 options at all times otherwise it can become buggy. Here is some pseudocode on how it is done:
pUnit:GossipCreateMenu(565, player, 0)
The 565 here links to the npc_text table and is the text ID displayed.
When the npc is clicked it calls a different function to show the default gossip menu. When a item is clicked it opens another gossip menu in the on click function. The on click function calls its self when another button is pressed, which calls the default gossip menu again or closes the menu.
Code:
function Proffesion_ONClick(pUnit, event, player)
proffesionmenu(pUnit, player)
end
function proffesionmenu(pUnit, player)
pUnit:GossipCreateMenu(565, player, 0)
pUnit:GossipMenuAddItem(7, "How does being a miner work?", 9, 0)
pUnit:GossipMenuAddItem(3, "Unlearn current proffesion.", 6, 0)
pUnit:GossipMenuAddItem(0, "Nevermind.", 1, 0)
pUnit:GossipSendMenu(player)
end
function ProffesionOnGossip(pUnit, event, player, id, intid, code)
if (intid == 1) then
player:GossipComplete()
elseif intid == 4 then
proffesionmenu(pUnit, player)
elseif intid == 5 then
pUnit:GossipCreateMenu(7363, player, 0)
if pUnit == nil then
pUnit:GossipMenuAddItem(0, "debug.", 4, 0)
end
pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
pUnit:GossipSendMenu(player)
elseif intid == 6 then
pUnit:GossipCreateMenu(3802, player, 0)
pUnit:GossipMenuAddItem(4, "Are you sure you wish to unlearn your current proffesion? (You will loose your skill level and it cannot be recovered!)", 6, 0)
pUnit:GossipMenuAddItem(0, "Yes.", 7, 0)
pUnit:GossipMenuAddItem(0, "No.", 4, 0)
pUnit:GossipSendMenu(player)
end
end