View Single Post
  #7  
Old 06-30-2010, 09:31 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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(acctcategoryitemnameinitialbidbuyout) {
  
// Create Auction 
  
this.auction.(@this.auctionid) = {
    
acctcategoryitemname"(npcserver)"initialbidbuyout
  
};
  
// 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(auctionidacctnewbid) {
  
// Check if New Bid is Greater than Old Bid
  
if (newbid getAuctionBid(auctionid)) {
    
// Refund Old Bid

    // Change Current Bid Information
    
setAuctionBidder(auctionidacct);
    
setAuctionBid(auctionidnewbid);
  }
  
// 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.auctionidthis.auctions) {
    
temp.data.add(getAuction(temp.auctionid));
  }
  return 
temp.data;
}

public function 
getAuctionsByCategory(category) {
  for (
temp.auctionidthis.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(auctionidacct) {
  
this.auction.(@auctionid)[3] = acct;
}

function 
getAuctionBid(auctionid) {
  return 
this.auction.(@auctionid)[4];
}

function 
setAuctionBid(auctionidbid) {
  
this.auction.(@auctionid)[4] = bid;
}

function 
getAuctionBuyout(auctionidacct) {
  return 
this.auction.(@auctionid)[5];

Of course you'll have to add your own improvements like pagination, search limits, auction expiry.
__________________
Quote:

Last edited by fowlplay4; 06-30-2010 at 09:43 PM..
Reply With Quote