I'm sorry but your system is a mess if you have to do 3 loops to get that kind of information.
Here's a different way you could store the data instead of having such a high dependency on getdynamicvars.
this.auctions - Stores all current auction ids.
this.auction.id - Stores auction specific data (account, category, itemname, bidder, currentbid, buyout price)
Here's some barebones of what I think would be ideal for storing the information and some samples of how it would be used in the system.
PHP Code:
function onCreated() {
// Increment Auction ID
this.auctionid++;
}
public function createAuction(acct, category, itemname, initialbid, buyout) {
// Create Auction
this.auction.(@this.auctionid) = {
acct, category, itemname, "(npcserver)", initialbid, buyout
};
// Add Auction to Auctions Array
this.auctions.add(this.auctionid);
// Increment Auction ID to prevent overlap
this.auctionid++;
// Force Save of DB (Workaround)
this.trigger("update", "");
}
public function bidOnAuction(auctionid, acct, newbid) {
// Check if New Bid is Greater than Old Bid
if (newbid > getAuctionBid(auctionid)) {
// Refund Old Bid
// Change Current Bid Information
setAuctionBidder(auctionid, acct);
setAuctionBid(auctionid, newbid);
}
// Force Save of DB (Workaround)
this.trigger("update", "");
}
public function closeAuction(auctionid) {
// Handle Auction Closing Code Here
// Remove Data from DB
this.auctions.remove(auctionid);
this.auctions.(@auctionid) = "";
// Force Save of DB (Workaround)
this.trigger("update", "");
}
/*
Accessors / Mutators
*/
public function getAuctions() {
for (temp.auctionid: this.auctions) {
temp.data.add(getAuction(temp.auctionid));
}
return temp.data;
}
public function getAuctionsByCategory(category) {
for (temp.auctionid: this.auctions) {
if (getAuctionCategory(temp.auctionid) == category) {
temp.data.add(getAuction(temp.auctionid));
}
}
return temp.data;
}
public function getAuction(auctionid) {
return this.auction.(@auctionid);
}
function getAuctionAccount(auctionid) {
return this.auction.(@auctionid)[0];
}
function getAuctionCategory(auctionid) {
return this.auction.(@auctionid)[1];
}
function getAuctionItemName(auctionid) {
return this.auction.(@auctionid)[2];
}
function getAuctionBidder(auctionid) {
return this.auction.(@auctionid)[3];
}
function setAuctionBidder(auctionid, acct) {
this.auction.(@auctionid)[3] = acct;
}
function getAuctionBid(auctionid) {
return this.auction.(@auctionid)[4];
}
function setAuctionBid(auctionid, bid) {
this.auction.(@auctionid)[4] = bid;
}
function getAuctionBuyout(auctionid, acct) {
return this.auction.(@auctionid)[5];
}
Of course you'll have to add your own improvements like pagination, search limits, auction expiry.