Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:USERAPI PLAYER MONEY
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{userfunc}} <!-- Leave this line in! --> Output when you gain or lose money and the amount to the chat frame. == Code == local function FormatMoney(money) local ret = "" local gold = floor(money / (COPPER_PER_SILVER * SILVER_PER_GOLD)); local silver = floor((money - (gold * COPPER_PER_SILVER * SILVER_PER_GOLD)) / COPPER_PER_SILVER); local copper = mod(money, COPPER_PER_SILVER); if gold > 0 then ret = gold .. " gold " end if silver > 0 or gold > 0 then ret = ret .. silver .. " silver " end ret = ret .. copper .. " copper" return ret end local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_MONEY") frame:RegisterEvent("PLAYER_ENTERING_WORLD") frame:SetScript("OnEvent", function(self, event, ...) local tmpMoney = GetMoney() if self.CurrentMoney then self.DiffMoney = tmpMoney - self.CurrentMoney else self.DiffMoney = 0 end self.CurrentMoney = tmpMoney if self.DiffMoney > 0 then ChatFrame1:AddMessage("You gained" .. FormatMoney(self.DiffMoney) .. ".") elseif self.DiffMoney < 0 then ChatFrame1:AddMessage("You lost" .. FormatMoney(self.DiffMoney * -1) .. ".") end end)
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Apinav
(
edit
)
Template:Editlink
(
edit
)
Template:Notebox
(
edit
)
Template:Userfunc
(
edit
)