Auction Script

By RusselB on Nov 09, 2006

A person can "sell" something via auction, using the !sell command
While an auction is in progress, people can bid using !bid
All commands work via pm or oin channel. Seller must have a common channel with the bot/client running the code in order to sell. Bidders (at the time of bidding) must also have a common channel.
Help is available using !auction help
Auctions run for one day, unless the client exits/disconnects, in which case the auction is "held" until the next connection, when the timers for the auctions will resume from where they left off.
I was unable to figure out how to incorporate an incremental increase for the bids, so that a maximum bid could be entered (similar to the way E-Bay works)
When a new high bid is entered, the seller, highbidder (and if applicable old highbidder) are notified via a notice.
At the end of the auction, the seller and the highbidder are notified, unless there have been no bids, in which case the seller is told so.
Seller's are not allowed to bid on their own auctions, and changing nicks won't help, as nick changes are accounted for.

on *:exit:{
  save_auctions
}
on *:disconnect:{
  save_auctions
}
alias save_auctions {
  var %a = 1, %b = $timer(0)
  while %a <= %b {
    var %auction = $timer(%a), %time = $timer(%auction).secs
    if Auction isincs %auction {
      %details = $hget(%auction), %details = $puttok(%details,%time,-2,32)
      .hadd -m Auction %auction %details
    }
    inc %a
  }
  .hsave -o Auction Auction.hsh
}
on *:start:{
  if !$hget(Auction) { .hmake Auction 100 }
  if $exists(Auction.hsh) { .hload Auction Auction.hsh }
}
on *:connect:{
  var %a = 1, %b = $hget(Auction,0}.item
  while %a <= %b {
    var %timer.name = $hget(Auction,%a), %timer = $gettok($hget(Auction,%a).data,-2,32)
    if !$timer(%timer.name) {
      $+(.timer,.,%timer.name) 1 %timer end_auction $gettok(%timer.name,1,46) $gettok(%timer.name,2,46)
    }
    inc %a
  }
}
on me:*:join:#:{
  if $hget(Auction,0).item {
    .notice $chan There are $hget(Auction,0).item auction(s) in progress
  }
}
on *:text:!auction*help:*:{ 
  .timer 1 1  .msg $nick Auction Help 
  .timer 1 2  .msg $nick ============ 
  .timer 1 4  .msg $nick To sell items, use !sell <item description> <price> 
  .timer 1 5  .msg $nick <price> is the minimum amount that you are willing to sell for 
  .timer 1 6  .msg $crlf 
  .timer 1 8  .msg $nick To bid for an item, use !bid <auction.id> <bid> 
  .timer 1 9  .msg $nick A message will be sent to you if you are outbid or if you are the winner at the end of the auction 
  .timer 1 10  .msg $nick $crlf 
  .timer 1 12  .msg $nick You are not allowed to bid on your own auctions 
  .timer 1 13  .msg $nick $crlf 
  .timer 1 15  .msg $nick To see a list of current auctions, use !list 
  .timer 1 16  .msg $nick You and I must have at least one channel in common at the time you put the item up for sale and/or bid for an item 
  .timer 1 17  .msg $nick Auctions run for one (1) day unless I get disconnected, in which case all current bids & auctions are nullified 
} 
on *:text:!sell*:*:{ 
  if !$2 || $2 isnum {    .notice $nick You didn't specify what you want to sell  } 
  elseif !$comchan($nick,0) {    .notice $nick Sorry, but you must be in at least one channel with me to sell items  } 
  else { 
    var %price = $gettok($2-,-1,32), %item = $gettok($2-,$+(1-$calc($numtok($2-,32) - 1)),32)
    if %price !isnum {    .notice $nick You didn't specify the minimum selling amount  } 
    else { 
      .hinc Auction $+($nick,.0)
      var %auction = $hget(Auction,$+($nick,.0))
      .hadd -m Auction $+($nick,.,%auction) %item %price 86400 $nick
      .ame announces that $nick has put %item up for bids. 
      .ame notes that this item can be referenced using the auction ID of  $+($nick,.,%auction)  
      .ame States that bidding will start at $round($calc(%price / 10),0) 
      set $+(%,seller,$address) $addtok($($+(%,seller,$address),2),$nick,32)
    } 
    $+(.timer,.,$+($nick,.,%auction)) 1 86400 end_auction $nick %auction 
  } 
} 
on *:nick:{
  set $+(%,seller,$address) $addtok($($+(%,seller,$address),2),$newnick,32)
}
on *:text:!bid*:*:{ 
  if !$2 {    .notice $nick You didn't specify what you want to bid on  } 
  elseif !$comchan($nick,0) {    .notice $nick Sorry, but you must be in at least one channel with me to bid on items  } 
  elseif $3 !isnum {    .notice $nick You can't bid an amount of 0  } 
  elseif !$hget(Auction,$2) {    .notice $nick Sorry, I can't find that auction  } 
  else { 
    var %seller = $gettok($2,1,46) 
    if $istok($($+(%,seller,$address),2),$nick,32) {      .notice $nick You can't bid on your own items    } 
    else { 
      var %details = $hget(Auction,$2)
      var %time = $gettok(%details,-2,32)
      var %price = $gettok(%details,-3,32)
      var %item = $numtok(%details,32)
      dec %item 3
      %item = $gettok(%details,$+(1-,%item),32)
      if $3 > %price { 
        var %oldhigh = $gettok(%details,-1,32), %newhigh = $nick, %price = $3
        .enable #bid_notice
        .ison %seller %oldhigh
        .notice $nick You now have high bid for auction ID %id 
        .hadd -m Auction $2 $3 $timer($2).secs $nick
      } 
      else { 
        .notice $nick Sorry, but the current bid for this item is %price 
      } 
    } 
  } 
} 
#bid_notice off 
raw 303:*:{ 
  if $istok($2-,%seller,32) { 
    .notice %seller %newhigh has just set a high bid for auction ID %id 
  } 
  if $istok($2-,%highbidder,32) { 
    .notice %oldhigh You have been outbid on auction ID %id $+ . Current bid is %price
  } 
  .disable #bid_notice 
} 
#bid_notice end 
on *:text:!list:*:{ 
  var %a = 1, %b = $hget(Auction,0).item 
  .msg $nick There are $bytes(%b,b) auctions 
  while %a <= %b { 
    var %auction = $hget(Auction,%a).item 
    var %item = $numtok($hget(Auction,%auction),32) 
    dec %item 
    %item = $gettok($hget(Auction,%auction),$+(1-,%item),32) 
    var %price = $gettok($hget(Auction,%auction),-1,32) 
    var %time = $timer(%auction).secs 
    .timer 1 %a .msg $nick Auction: %auction - Item: %item - Price: %price - Time Remaining: $duration(%time) 
    inc %a 
  } 
} 
alias -l end_auction { 
  var %seller = $1 
  var %auction = $+($1,.,$2) 
  %highbidder = $gettok($hget(Auction,%auction),-1,32) 
  %price = $gettok($hget(Auction,%auction),-2,32) 
  if %highbidder == %seller { 
    .notice %seller Sorry but your item didn't sell 
  } 
  else { 
    .enable #auction_end 
    .ison %seller %highbidder 
  } 
} 
#auction_end off
raw 303:*:{ 
  if $istok($2-,%seller,32) { 
    .notice %seller Congratulations, %highbidder has made the highest bid of %price for %item (Auction ID: %auction) 
  } 
  if $istok($2-,%highbidder,32) { 
    .notice %highbidder Congratulations, You have won auction ID %auction by %seller for %item 
  } 
  .hdel Auction %auction
  .disable #auction_end 
} 
#auction_end end 

Comments

Sign in to comment.
Quick   -  Jun 22, 2010

/me prods RusselB to hopefully find some time to rework this plz.

 Respond  
dashh   -  Feb 19, 2009

-> Neptune

if %price !isnum <---

You put 32,000 <- here is a token "," isnum return true when is only numbers.

=)

try $remove(%price,$chr(36),$chr(46),$chr(44)) <-

!sell lol $32,000.000 = 32000000

^^

alias test {
%price = $remove($1,$chr(36),$chr(46),$chr(44))
if ( %price !isnum ) {
echo -a %price
}
else {
echo -a
%price
}
;unset %price
}

 Respond  
^Neptune   -  Jan 07, 2009

Cool. I'm trying to make my own at the moment, it's going pretty well.

 Respond  
RusselB   -  Jan 07, 2009

Due to the fact that I was unable to find any kind of consistancy regarding when the script worked and when it didn't, I stopped working on it, and as you can tell from the date of my last post here, it's been over a year.

I have a couple of other projects on the go right now, but once I have them completed, or if I find myself needing a break, I will see about re-doing this project.

 Respond  
^Neptune   -  Jan 07, 2009

Would it be possible to maybe incorporate a "buy it now!" feature when you're putting an item up for auction?

I'm also really confused at this:

[09:49:16] <~Neptune> !sell moon 32,000
[09:49:17] -X- You didn't specify the minimum selling amount
[09:50:10] <~Neptune> !sell moon 32,000 40,000
[09:50:12] -X- You didn't specify the minimum selling amount

The help topics show nothing of a minimum amount. :O

 Respond  
RusselB   -  Sep 29, 2007

My apologies to those that have had problems with this script.
I\'ve had other people show the same problems, and yet, other people haven\'t had any problems.
I am still trying to get this worked out.
I realize that this has been a long time working on it, but there have been several other things that have come up and required my attention, but I have not forgotten about this.

 Respond  
BrainBryce   -  Apr 21, 2007

oh yeh and...

  • /hinc: no such table \'Auction\' (line 343, Good restaursant !!)
  • /msg: insufficient parameters
  • No text to send
    No text to send

  • /hinc: no such table \'Auction\' (line 343, Good restaursant !!)

    .hinc Auction $+($nick,.0)

WTF

 Respond  
BrainBryce   -  Apr 21, 2007
!sell Mountain Bike 500 -bryce123456789- You didn\'t specify the minimum selling amount !sell Mountain Bike $500 -bryce123456789- You didn\'t specify the minimum selling amount What happenes there? i tried just plain 500 but it didnt work... How?
 Respond  
BrainBryce   -  Apr 21, 2007

How do you get the auction to start?

 Respond  
Scar-Face   -  Feb 07, 2007

bot You didn\'t specify the minimum selling amount

:-| Is there nothing more to do, after loading into remotes? (not txt files created or anything?)

 Respond  
fitzi01   -  Dec 25, 2006

Hmm the time is not displaying for time left, it also shows a bid twice for me and you should have a way to cancel the bid, but im loving it man excellent job

 Respond  
RoninWarrior   -  Nov 13, 2006

bid history?

 Respond  
RusselB   -  Nov 13, 2006

It\'ll be nicer once I get some details that currently elude me worked out. Please keep your eyes open for updates.

 Respond  
RoninWarrior   -  Nov 11, 2006

i guess i never exspected ebay to cme to mirc nice russleB

 Respond  
ZabuzaMomochi   -  Nov 10, 2006

Its like a mini ebay! o_o;

 Respond  
RusselB   -  Nov 10, 2006

Definetly not. I\'ll pull the code and get some people to help me test it on the weekend, and try to figure out why it\'s displaying like that.
My apologies to all that have tried this code and experienced problems.
I guess I didn\'t test it enough before posting.

 Respond  
Cherish   -  Nov 10, 2006

\"Auction: Cherish.2 - Item: test 100 86400 - Price: Cherish - Time Remaining:\" - this way is it supposed to be?

 Respond  
AustenWood   -  Nov 09, 2006

/hinc: no such table \'Auction\' (line 60, Market Script) now apeears

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.