Thread Tools Display Modes
06-13-09, 04:17 PM   #1
Horaxe
A Murloc Raider
 
Horaxe's Avatar
AddOn Compiler - Click to view compilations
Join Date: Nov 2005
Posts: 9
Red face Need some advice

Recently my guild implemented a new system for loot, called the Wish system. Basically, every player (player, not character) gets to pick one item per difficulty setting/instance and if that item drops they get priority (assuming no one else has it on their list). If the player gets an item they can't use another Wish for 30 days. What I would like to do is make an AddOn that lets players have a button that sends a raid warning letting everyone know they have that item a as a Wish, then the officers can click an accept dialog to start the timer on that person's Wish. Afterward, the button simply gives a message saying something along the lines of "Your next Wish will be available in 29 days." Is this possible? And if so, where do I start? Any and all help/advice would be greatly appreciated.
__________________
  Reply With Quote
06-13-09, 05:31 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
It's certainly possible, but it's not very likely that an addon author is going to write an addon for a unique loot distribution system for a guild he has no affiliation with. Good luck.
  Reply With Quote
06-13-09, 05:45 PM   #3
Horaxe
A Murloc Raider
 
Horaxe's Avatar
AddOn Compiler - Click to view compilations
Join Date: Nov 2005
Posts: 9
Yeah, that's really the heart of the matter. I haven't done any kind of UI coding since EQ and I'm not sure where to really start with this.
__________________
  Reply With Quote
06-13-09, 06:21 PM   #4
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
To do this correctly would be slightly complicated as a first addon project; but certainly possible. With such a simple GUI requirement, I would personally use StaticPopupDialogs, but you could also acquaint yourself with frames and buttons, and their methods.
You also need to determine what you want to do if multiple people send requests at the same time, particularly if it's for the same drop. The following does not address that problem at all.

A simple example process:

1. Create a dialog that has a single button, create a slash command to show/hide the dialog.
2. When the dialog shows, it's OnShow handler checks a local database (saved variable [specifically a table]) to determine when the next "wish" is. If it is in the past, enable the button, otherwise set its text to the appropriate number and disable it.
3. When the button is pressed, it sends an addon message to the raid leader (having this notification go to multiple people is possible but if you do so, you'll need to worry about conflict resolution).

1. Create a frame which watches for whispered addon messages with a specific message that will be from your players pressing the button above. This frame should also watch for raid warnings because of step 5.
2. When this frame receives that message, check if the current player is the raid leader. If so, display the dialog mentioned in the next step.
2a. Create a dialog asking for confirmation whether to allow a wish to be granted.
3. When the above dialog is shown, its OnShow handler checks the addon's (in this case, running on the RLs computer) local database of player wish wait-times. If the requesting player has an entry which has not yet expired, immediately re-hide the frame (which will prevent anything else from happening and won't be visiable to the RL since it will re-hide within one video frame of showing).
4. If the player (who is the RL) presses accept in this dialog, send a raid warning (I strongly suggest using the *accepting* player to send the RW, because you can then confirm that it is legitimate...plus otherwise you'd have to give everyone an A) with a formula like "Name's request for a wish has been granted."
5. The frame in step 1 (on the computers of every raid member) will see the raid warning and confirm that it came from the RL. If it did come from the RL, it will make note of the player whose wish was granted, and update the addon's local database to reflect the fact that "player"'s next wish will be on (current date + 30 days).



The following are links to functions that you will need:

API functions:
SendAddonMessage
SendChatMessage --to send the raid warning
CreateFrame("FRAME")
frame:SetScript("OnEvent", --[[blah]]) --this is a frame method, "frame" is the frame object created by CreateFrame
UnitName("player") --to know which database entry to check for your own timer
GetRaidRosterInfo --for determining who is the raid leader

Events (see http://www.wowwiki.com/Events_(API)):
"CHAT_MSG_ADDON"
"CHAT_MSG_RAID_WARNING"

You also need to do various things with the GUI objects if you're not using StaticPopupDialogs...everything after this is only needed if you're making the dialogs yourself:

CreateFrame("BUTTON")

Frame methods:
Show
Hide

Button methods:
OnClick
Enable
Disable
SetScript("OnShow", --[[blah]]) -- to determine whether the button should be disabled/what the text should be/etc.

Fontstring methods:
local t = me.button1:CreateFontstring(--[[blah]])
t:SetFont(--[[blah]])
t:SetText("something")

Last edited by Akryn : 06-13-09 at 06:28 PM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Need some advice

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off