WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Search/Requests (https://www.wowinterface.com/forums/forumdisplay.php?f=6)
-   -   LF Gold trade announcer (https://www.wowinterface.com/forums/showthread.php?t=56857)

outer1990 11-21-18 09:10 PM

LF Gold trade announcer
 
Looking for a addon that announces how much gold i receive / lose to a certain person.

So it will pop up in /say chat

/say Trade with X(Character's name) was completed. Received X (Amount of gold)

/say Trade with X(Character's name) was completed. Lost X (Amount of gold)


I do not know if a addon exist or if it would be easy to make. Let me know. Thank you anyways :)

myrroddin 11-22-18 08:42 AM

I don't know of such an AddOn, but I can *ahem* say that printing the message to /say or any other channel will get annoying very quickly for everybody around you. It would be much better as a message to yourself.

Tradeskillmaster is extreme overkill for only this feature, but it does track gold trades in its Ledger tab, along with sales and auctions. TSM does a whole host of other things, but if you only want that one thing, maybe some other commenters can think of a specialized AddOn.

JDoubleU00 11-22-18 12:06 PM

I would agree with myrroddin that it would get annoying quickly. This does not announce to a channel, but does track your money.

https://wowinterface.com/downloads/i...ntClassic.html

There are others similar to this, but this was the first one that came to mind.

Xrystal 11-22-18 03:23 PM

If none of the suggested addons suit you and you can't find any others then maybe you can use this project as your first leap into addon writing.

A code example similar to what you are asking is at https://wow.gamepedia.com/User:Egingell/PLAYER_MONEY which could be a good help to your first project.

outer1990 11-22-18 10:27 PM

Quote:

Originally Posted by Xrystal (Post 330903)
If none of the suggested addons suit you and you can't find any others then maybe you can use this project as your first leap into addon writing.

A code example similar to what you are asking is at https://wow.gamepedia.com/User:Egingell/PLAYER_MONEY which could be a good help to your first project.

thanks this works! only problem is that i have add %t to say current targets name. Would rather have it automatically name the person in the trade but i do not think its possible . thank you!

Xrystal 11-22-18 11:00 PM

You could look into the following to incoporate that feature

https://wow.gamepedia.com/TRADE_ACCEPT_UPDATE

https://wow.gamepedia.com/TRADE_SHOW

https://wow.gamepedia.com/API_GetUnitName


Of course if the other trade person targetted you first then it may not return a true value unless you make a point of targetting them yourself before completing the trade.


However, this event may help you identify when someone has requested trade with you with arg1 being the result of the string format ERR_TRADE_REQUEST_S where the first word is the other player's name.

The same event with arg1 being the result of the string format ERR_INITIATE_TRADE_S with the last value the players name will handle you trading with them.

https://wow.gamepedia.com/CHAT_MSG_SYSTEM
https://www.townlong-yak.com/framexm...balStrings.lua


It all depends on what is the important element to the functionality. And may take a little play about with those functions to find the best combination of code to make it work.

Kanegasi 11-22-18 11:38 PM

I use UnitName("npc") to get the name of the trading target for my addon.

Lua Code:
  1. local f = CreateFrame("frame")
  2. function f.TRADE_SHOW()
  3.     local name, realm = UnitName("npc")
  4.     print(name..(realm and "-"..realm or "").." has opened a trade with me.")
  5. end
  6. f:RegisterEvent("TRADE_SHOW")
  7. f:SetScript("OnEvent", function(self, event, ...) self[event](...) end)

I got this from http://wowprogramming.com/docs/api_types#unitID before it was deleted.

Edit: It's been quite a while since I found/used that, so I had a look in Blizzard's TradeFrame.lua, they use it to set the other player's name in the window:

Lua Code:
  1. function TradeFrame_Update()
  2.     SetPortraitTexture(TradeFramePlayerPortrait, "player");
  3.     SetPortraitTexture(TradeFrameRecipientPortrait, "NPC");
  4.     TradeFramePlayerNameText:SetText(GetUnitName("player"));
  5.     TradeFrameRecipientNameText:SetText(GetUnitName("NPC"));
  6.     for i=1, MAX_TRADE_ITEMS, 1 do
  7.         TradeFrame_UpdateTargetItem(i);
  8.         TradeFrame_UpdatePlayerItem(i);
  9.     end
  10.     TradeHighlightRecipient:Hide();
  11.     TradeHighlightPlayer:Hide();
  12.     TradeHighlightPlayerEnchant:Hide();
  13.     TradeHighlightRecipientEnchant:Hide();
  14. end

UnitName is defined in the C portion of WoW's code, but GetUnitName is in UnitFrame.lua:

Lua Code:
  1. function GetUnitName(unit, showServerName)
  2.     local name, server = UnitName(unit);
  3.     local relationship = UnitRealmRelationship(unit);
  4.     if ( server and server ~= "" ) then
  5.         if ( showServerName ) then
  6.             return name.."-"..server;
  7.         else
  8.             if (relationship == LE_REALM_RELATION_VIRTUAL) then
  9.                 return name;
  10.             else
  11.                 return name..FOREIGN_SERVER_LABEL;
  12.             end
  13.         end
  14.     else
  15.         return name;
  16.     end
  17. end

outer1990 11-23-18 01:25 AM

Quote:

Originally Posted by Kanegasi (Post 330908)
I use UnitName("npc") to get the name of the trading target for my addon.

Lua Code:
  1. local f = CreateFrame("frame")
  2. function f.TRADE_SHOW()
  3.     local name, realm = UnitName("npc")
  4.     print(name..(realm and "-"..realm or "").." has opened a trade with me.")
  5. end
  6. f:RegisterEvent("TRADE_SHOW")
  7. f:SetScript("OnEvent", function(self, event, ...) self[event](...) end)

I got this from http://wowprogramming.com/docs/api_types#unitID before it was deleted.

Edit: It's been quite a while since I found/used that, so I had a look in Blizzard's TradeFrame.lua, they use it to set the other player's name in the window:

Lua Code:
  1. function TradeFrame_Update()
  2.     SetPortraitTexture(TradeFramePlayerPortrait, "player");
  3.     SetPortraitTexture(TradeFrameRecipientPortrait, "NPC");
  4.     TradeFramePlayerNameText:SetText(GetUnitName("player"));
  5.     TradeFrameRecipientNameText:SetText(GetUnitName("NPC"));
  6.     for i=1, MAX_TRADE_ITEMS, 1 do
  7.         TradeFrame_UpdateTargetItem(i);
  8.         TradeFrame_UpdatePlayerItem(i);
  9.     end
  10.     TradeHighlightRecipient:Hide();
  11.     TradeHighlightPlayer:Hide();
  12.     TradeHighlightPlayerEnchant:Hide();
  13.     TradeHighlightRecipientEnchant:Hide();
  14. end

UnitName is defined in the C portion of WoW's code, but GetUnitName is in UnitFrame.lua:

Lua Code:
  1. function GetUnitName(unit, showServerName)
  2.     local name, server = UnitName(unit);
  3.     local relationship = UnitRealmRelationship(unit);
  4.     if ( server and server ~= "" ) then
  5.         if ( showServerName ) then
  6.             return name.."-"..server;
  7.         else
  8.             if (relationship == LE_REALM_RELATION_VIRTUAL) then
  9.                 return name;
  10.             else
  11.                 return name..FOREIGN_SERVER_LABEL;
  12.             end
  13.         end
  14.     else
  15.         return name;
  16.     end
  17. end

thank you, it does let me know who opens trade with me which is useful to know when trading with 10+ people at once. thank you for this script... it has been added on. Still must target the person when accepting a trade to get there name in "Xname has traded you 2000g confirmed" Dont think it is possible.. but still a useful script! <3

Xrystal 11-23-18 04:53 AM

Oh, that is handy to know as I would have thought that a player trade would require "target" rather than "npc" as a player would not be an npc. But I suppose Blizzard just made the code work functionally the same regardless of where the trader is an npc or player.


All times are GMT -6. The time now is 12:44 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI