This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [QUESTION] New gossip UI  (Read 1655 times)

osler

  • Contributors
  • Polygonshifter
  • *****
  • Posts: 59
    • View Profile
[QUESTION] New gossip UI
« on: May 18, 2013, 06:45:06 pm »
Hello!
I was wondering how to make a different gossip UI for a specific creature.
I have tried a hack in GossipFrame.lua, but it didn´t work:
Code: [Select]
elseif ( event == "GOSSIP_SHOW" and GetUnitName(self.unit) == "UNIT NAME") then
Now I´m thinking about doing it mostly server-side:
Server sends something to clients, which is interpreted in GossipFrame.lua and displays the modified gossip frame, but I have no idea how to do it.
Can anybody give me some advice?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

stoneharry

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 617
    • View Profile
Re: [QUESTION] New gossip UI
« Reply #1 on: May 18, 2013, 06:51:40 pm »
You could have the npc have a server side on click event (gossip start), then send them a invisible message (or better, an addon message).

When the client receives this message it opens the relevant frame.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

osler

  • Contributors
  • Polygonshifter
  • *****
  • Posts: 59
    • View Profile
Re: [QUESTION] New gossip UI
« Reply #2 on: May 18, 2013, 08:50:14 pm »
Thanks, I wil try that metohd :D
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

osler

  • Contributors
  • Polygonshifter
  • *****
  • Posts: 59
    • View Profile
Re: [QUESTION] New gossip UI
« Reply #3 on: June 02, 2013, 11:30:30 pm »
I´ve managed to make the npc whisp a message (actually is a visible message) but I think that my Lua code is wrong...
Also I have tried PLAYER_PLEVEL_UP event, and doesn´t work.

Code: [Select]
   local f = CreateFrame('frame')
    f:RegisterEvent('PLAYER_LEVEL_UP')
    f:RegisterEvent('CHAT_MSG_SYSTEM')
     
    f:SetScript('OnEvent', function(self, event, ...)
        if event == 'PLAYER_LEVEL_UP' then
            SendChatMessage("I've leveled up!")
        else
            local message = ...
            if message:find('Welcome...") then
                SendChatMessage('Somebody has whispered me!')
            end
        end
    end)

--EDIT--
I´ve updated my code, and now the level up event works correctly, but whisper doesn´t.

--EDIT #2--
Now it works ONLY when a player whispers. Is there any othe event which fires when a creature whispers?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

osler

  • Contributors
  • Polygonshifter
  • *****
  • Posts: 59
    • View Profile
Re: [QUESTION] New gossip UI
« Reply #4 on: June 12, 2013, 10:37:38 pm »
I´m still modifying my code, but I doesn´t work. I think that it´s becaouse the event:
Code: [Select]
   local f = CreateFrame('frame')
    f:RegisterEvent('PLAYER_LEVEL_UP')
    f:RegisterEvent('CHAT_MSG_WHISPER')
    f:RegisterEvent("PLAYER_TARGET_CHANGED");
     
    f:SetScript('OnEvent', function(self, event, ...)
        if event == 'PLAYER_LEVEL_UP' then
            SendChatMessage("I've leveled up!")
        elseif event == 'CHAT_MSG_WHISPER' then
            local message = ...
            if message:find('This is a test') then
                SendChatMessage('Somebody has whispered me!')
            end
        end
    end)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

stoneharry

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 617
    • View Profile
Re: [QUESTION] New gossip UI
« Reply #5 on: June 13, 2013, 03:56:25 pm »
This is a code snippet taken from one of my scripts:

Code: [Select]
ChatFrame_MessageEventHandler2 = ChatFrame_MessageEventHandler

function ChatFrame_MessageEventHandler(s,e,arg1,...)
if arg1 ~= nil then
if arg1 ~= "" then
if string.find(arg1, "[CU-ADDON]", 1, true) ~= nil then
if (arg1 == "[CU-ADDON] OpenMenuFactionChoose") then
DestinyFrame_OnEvent(DestinyFrame, 0);
end
return;
elseif string.find(arg1, "CHAOTIC:SCENARIO", 1, true) ~= nil then
return;
elseif string.find(arg1, "[EoC-Addon]", 1, true) ~= nil then
if (arg1 == "[EoC-Addon] HungerGamesOpen") then
HungerGames:Show()
end
return;
end
end
end
ChatFrame_MessageEventHandler2(s,e,arg1,...)
end

This hooks the chat frame, looks for strings and calls functions then returns if string matches are found. By returning, it does not actually show the message in the chat frame.

The better method to do this is via addon messages. http://wowprogramming.com/docs/api/SendAddonMessage I cannot remember the server-side code.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »