Modcraft - The community dedicated to quality WoW modding!

Wrath of the Lich King Modding => Serverside Modding => Topic started by: osler on May 18, 2013, 06:45:06 pm

Title: [QUESTION] New gossip UI
Post by: osler 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?
Title: Re: [QUESTION] New gossip UI
Post by: stoneharry 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.
Title: Re: [QUESTION] New gossip UI
Post by: osler on May 18, 2013, 08:50:14 pm
Thanks, I wil try that metohd :D
Title: Re: [QUESTION] New gossip UI
Post by: osler 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?
Title: Re: [QUESTION] New gossip UI
Post by: osler 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)
Title: Re: [QUESTION] New gossip UI
Post by: stoneharry 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 (http://wowprogramming.com/docs/api/SendAddonMessage" onclick="window.open(this.href);return false;) I cannot remember the server-side code.