Language:
Lua     Change language:
Pastebin: 119907
Author: p3lim
Subject: Re: epgpcapture
Created: 2009-08-03 10:00:15
Download and save
Toggle line numbers
1local addon = CreateFrame('Frame'
2local running = 0 
3local winner, winnerPR 
4 
5local function onUpdate(self, elapsed) 
6    if(running) then 
7        if(running == 5) then 
8            SendChatMessage('Bidding ending in 5 seconds!', 'RAID'
9        elseif(running <= 0) then 
10            SendChatMessage(format('Bidding ended! %s won the item with %d PR, congrats!', winner or 'Noone', winnerPR), 'RAID'
11            addon:UnregisterEvent('CHAT_MSG_RAID', addon.raidEvent) 
12            addon:UnregisterEvent('CHAT_MSG_RAID_LEADER', addon.raidEvent) 
13            winner = nil 
14        end 
15 
16        running = running - elapsed 
17    end 
18end 
19 
20local function slashHandler() 
21    SendChatMessage('Starting bid (1 for Main Spec, 2 for Secondary Spec', 'RAID_WARNING'
22    addon:RegisterEvent('CHAT_MSG_RAID', addon.raidEvent) 
23    addon:RegisterEvent('CHAT_MSG_RAID_LEADER', addon.raidEvent) 
24 
25    running = 15 
26end 
27 
28-- events handling bids 
29function addon:raidEvent(str, author) 
30    local spec = str == '1' and 'Main Spec' or '2' and 'Secondary Spec' 
31    if(not spec) then return end 
32    for index = 1, GetNumGuildMembers() do 
33        local name, _, _, _, _, _, _, note= GetGuildRosterInfo(index) 
34 
35        if(author == name) then 
36            local ep, gp = string.split(',', note, 2
37            local pr = ep / gp 
38 
39            winner = pr > winnerPR and name 
40            winnerPR = pr > winnerPR and pr 
41 
42            print('|cffff8080EPGPCapture:|r', name, 'Bid for', spec, 'PR:', pr) 
43        end 
44    end 
45end 
46 
47-- if player asks what is  
48local function whisperEvent(str, author) 
49    if(str:lower():find('epgp')) then 
50        for index = 1, GetNumGuildMembers() do 
51            local name, _, _, _, _, _, _, note= GetGuildRosterInfo(index) 
52 
53            if(author == name) then 
54                local ep, gp = string.split(',', note, 2
55                SendChatMessage(format('Your EP: %s, GP: %s, PR: %s', ep, gp, ep / gp), 'WHISPER', nil, author) 
56            end 
57        end 
58    end 
59end 
60 
61-- register slashhandler 
62SLASH_EPGPCAPTURE1 = '/epgpcapture' 
63SlashCmdList.EPGPCAPTURE = slashHandler 
64 
65-- function handler 
66do 
67    local orig = RegisterEvent 
68    function addon:RegisterEvent(event, func) 
69        self[event] = func 
70        self:orig(event) 
71    end 
72end 
73 
74do 
75    local orig = UnregisterEvent 
76    function addon:UnregisterEvent(event, func) 
77        self[event] = nil 
78        self:orig(event) 
79    end 
80end 
81 
82-- set the update script 
83addon:SetScript('OnUpdate', onUpdate) 
84 
85-- event handler 
86addon:SetScript('OnEvent', function(self, event, ...) self[event](...) end
87 
88-- events to register 
89addon:RegisterEvent('CHAT_MSG_WHISPER', whisperEvent) 
Download and save
Toggle line numbers
Thread:
[119907] Re: epgpcapture by p3lim at 2009-08-03 10:00:15
Tip: Click the line numbers to toggle highliting on that line.

Paste followup:

Language:
Author:
Subject:


    Tabstop:     bigger biggest
Note: You can prefix a line with "@@@" to highlight it.