Thread Tools Display Modes
03-08-09, 02:30 PM   #1
Vilkku
An Aku'mai Servant
 
Vilkku's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 35
Tables

Hello!
I'm writing a mod to manage DKP bids for my guild. The guild does bids with whispers - everyone whispers a player (the one with the mod) and then the mod calculates who is the winner, according to our rules. What I would like to to make it notice the players who have already bid for the item. So far I have this:
Code:
ProphDKP_bidders = {}
if (event == "CHAT_MSG_WHISPER") then
if not ProphDKP_bidders[arg2] then 
	ProphDKP_bidders[arg2] = 1 
else 
	ProphDKP_bidders[arg2] = ProphDKP_bidders[arg2] + 1 
end
for name,amount in pairs(ProphDKP_bidders) do
	if (amount > 1 and name == arg2) then
		ProphDKP_duplicatebid = 1
	end
end
end
This is obviously a part of a longer piece of code, but this should be enough for you to help me.
Problem is that after someone has bid two times, it will also treat all bid coming after that persons second bid as duplicates, even if they aren't.

Any help appreciated

Last edited by Vilkku : 03-08-09 at 02:31 PM. Reason: Bit more info.
  Reply With Quote
03-08-09, 02:34 PM   #2
Foxlit
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
ProphDKP_duplicatebid is likely a global, so after the first time you set it to 1, it just stays equal to 1.

What you're looking for is something as short as:
Code:
if not ProphDKP_bidders[arg2] then 
	ProphDKP_bidders[arg2] = 1 
else 
	-- this is clearly a duplicate bid.
end
__________________
... and you do get used to it, after a while.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Tables


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