collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: patch: Bid.php configurable MinBid  (Read 6971 times)

0 Members and 1 Guest are viewing this topic.

Offline laen

  • BeBot User
  • **
  • Posts: 24
  • Karma: +0/-0
patch: Bid.php configurable MinBid
« on: January 05, 2009, 12:27:17 am »
As the Bid.php version packaged with 0.6.1 had a hardcoded minimum bid value of 2, and people on meh bot requesting to lower it, i made some minimum changes to it which allows you to set the minimum bid value. Could offcourse gone rewriting the whole thing to give it more options, but didn't feel like it at the moment.

http://ao.onedot.nl/patches/Bid.php-laen-090104234849.patch

Usage: place in your bots directory..
Code: [Select]
patch -p0 < Bid.php-laen-090104234849.patch

Offline Allisande

  • BeBot User
  • **
  • Posts: 68
  • Karma: +0/-0
Re: patch: Bid.php configurable MinBid
« Reply #1 on: January 09, 2009, 04:55:36 am »
Is there any way I could set this up to just do a check on the total points a player has then announce the winner?  and not actually do an action?

something like

Admin : !bid start 30 (value of the item)
Player 1 : !bid (P1 has 220 points)
Player 2 : !bid (P2 has 127 points)
Player 3 : !bid (P3 has 221 points)
Admin : !bid end
<botname> Player 3 has won the item.  Woot!!
<botname> has removed 30 points from Player 3's poiints.

If not I can continue to do this manually, but it would be a great addition to the mod. 

Thanks

Offline Vain

  • BeBot User
  • **
  • Posts: 57
  • Karma: +0/-0
Re: patch: Bid.php configurable MinBid
« Reply #2 on: January 15, 2009, 03:40:04 am »
Here is the Bid.php that I am using.

In our Guild we use a closed bidding system.
When someone bids the bot will only announce that someone has bid, it will not announce how much.

Commands:
Admin: !bid start <item>
Admin: !bid status = shows who is bidding on the item
Admin: !bid end = ends the bid
player: !bid <points>
player: !bid 0 = cancels your bid.
player: !bind info = shows info on the current item up for bid.

If someone bids for an item and then later decides he/she doesnt want it they can bid again with a 0 value to removed from the bid.


Thanks to Temar for making these changes.

Code: [Select]
<?php
/*
* Bid.php - Raid bidding.
*
* BeBot - An Anarchy Online & Age of Conan Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Copyright (C) 2005-2007 Thomas Juberg StensÃ¥s, ShadowRealm Creations and the BeBot development team.
*
* Developed by:
* - Alreadythere (RK2)
* - Blondengy (RK1)
* - Blueeagl3 (RK1)
* - Glarawyn (RK1)
* - Khalem (RK1)
* - Naturalistic (RK1)
* - Temar (RK1)
*
* See Credits file for all aknowledgements.
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; version 2 of the License only.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*  USA
*
* File last changed at $LastChangedDate: 2008-11-30 17:09:06 -0500 (Sun, 30 Nov 2008) $
* Revision: $Id: Bid.php 1833 2008-11-30 22:09:06Z alreadythere $
*/


$bid = new Bid($bot);



/*
The Class itself...
*/
class Bid extends BaseActiveModule
{
var $help;
var $bid;
var $maxbid;
var $secondbid;
var $highestbidder;
var $announce;
var $announced;
var $end;



/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function __construct(&$bot)
{
parent::__construct(&$botget_class($this));

$this -> bid "";

$this -> register_command('tell''bid''MEMBER');

$this -> help['description'] = "Handles auctions using raid points";
$this -> help['command']['bid start <item>'] = "Starts an auction for <item>. <item> can be text or an item ref.";
$this -> help['command']['bid end'] = "Ends the current auction.";
$this -> help['command']['bid <points>'] = "Bid <points> raid points for the item currently on auction.";
$this -> help['command']['bid info'] = "Shows information about the current auction.";
$this -> help['command']['bid status'] = "Shows bids on current/last auction.";
}



/*
This gets called on a tell with the command
*/
function command_handler($name$msg$origin)
{
$msg explode(" "$msg3);
Switch($msg[1])
{
case 'start':
$this -> start_bid($name$msg[2]);
Break;
case 'info':
$this -> info_bid($name);
Break;
case 'end':
$this -> end_bid($name);
Break;
case 'bids':
case 'status':
$this -> bid_list($name);
Break;
Default:
if(is_numeric($msg[1]))
$this -> place_bid($name$msg[1]);
else
$this -> bot -> send_help($name);
}
}



/*
Starts the bidding
*/
function start_bid($name$item)
{
if ($this -> bot -> core("security") -> check_access($name"leader"))
{
$this -> bid $item;
$this -> maxbid 1;
// $this -> secondbid = 1;
// $this -> highestbidder = "";
$this -> bidders = array();
$this -> announce time() + 15;
$this -> announced false;
//$this -> end = time() + 120;
//$this -> register_event("cron", "2sec");
$msg "\n##highlight##-------------------------------------##end##\n";
$msg .= "##highlight##$name##end## started auction ";
$msg .= "on ##highlight##$item##end##! :: " $this -> info() ."\n";
$msg .= "Note: ##red##Your MAX BID will be deducted##end##! ";
$msg .= "\n##highlight##-------------------------------------##end##";
$this -> bot -> send_output(""$msg"both");
}
else
$this -> bot -> send_tell($name"You must be a raidleader to do this");
}



/*
Place a bid
*/
function place_bid($name$amount)
{
$update true;

if (empty($this -> bid))
{
$this -> bot -> send_tell($name"No auction in progress.");
return false;
}
else if ($amount 30 && $amount != 0)
{
$this -> bot -> send_tell($name"Min bid is set to ##highlight##30##end## raidpoints.");
return false;
}

$result $this -> bot -> db -> select("SELECT points FROM #___raid_points WHERE id = " $this -> points_to($name));
if (empty($result))
{
$this -> bot -> send_tell($name"You appear to not have any points yet. No points table entry found.");
return false;
}

$result $result[0][0];

//$currenthigh = (($this -> maxbid == $this -> secondbid) ? ($this -> maxbid) : ($this -> secondbid + 1));

if ($result $amount)
{
$this -> bot -> send_tell($name"You only have ##highlight##" $result .
"##end## raidpoints. Please place bid again.");
return false;
}
//else if ($this -> maxbid == $amount)
//{
// $this -> secondbid = $amount;
//}
//else if ($this -> maxbid < $amount)
//{
// if ($name != $this -> highestbidder)
// {
//     $this -> secondbid = $amount;
//     $this -> maxbid = $amount;
  
//     $this -> highestbidder = $name;
// }

// $this -> maxbid = $amount;
//}
//else if ($currenthigh < $amount)
//{
// if ($name != $this -> highestbidder)
// $this -> secondbid = $amount;
//}

//$highest = (($this -> maxbid == $this -> secondbid) ? ($this -> maxbid) : ($this -> secondbid + 1));

//if ($highest != $currenthigh)
//{
// $secs = $this -> end - time();

// if ($secs < 10)
// {
// $secs = 10;
// $this -> end = time() + 10;
// }
if(!isset($this -> bidders[$name]) && $amount == 0)
{
Return("Unable to Remove bid as you have not Bid!");
}
elseif(!isset($this -> bidders[$name]))
{
$this -> bidders[$name] = array($amounttime());
$this -> bot -> send_output("""##highlight## Someone Has Bid! ##end## :: " $this -> info(), "both");
}
elseif($this -> bidders[$name][0] < $amount)
{
$this -> bidders[$name] = array($amounttime());
$this -> bot -> send_output("""##highlight## Someone Has Increased there Bid! ##end## :: " $this -> info(), "both");
}
elseif($amount == 0)
{
$this -> bidders[$name] = array($amounttime());
$this -> bot -> send_output("""##highlight## Someone Has Removed there Bid! ##end## :: " $this -> info(), "both");
}
elseif($this -> bidders[$name][0] < $amount)
{
$this -> bidders[$name] = array($amounttime());
$this -> bot -> send_output("""##highlight## Someone Has Decreased there Bid! ##end## :: " $this -> info(), "both");
}
//}
}



/*
Gets called on a cronjob...
*/
function end_bid($name)
{
if ($this -> bot -> core("security") -> check_access($name"leader"))
{
if(empty($this -> bid))
{
$this -> bot -> send_output("""Auction is not running.""both");
}
elseif (empty($this -> bidders))
{
$this -> bot -> send_output("""Auction is over. No bids where placed. Item is FFA.""both");
}
else
{
//$highest = (($this -> maxbid == $this -> secondbid) ? ($this -> maxbid) : ($this -> secondbid + 1));
$high = array(00"");
foreach($this -> bidders as $name => $bid)
{
if($bid[0] > $high[0])
$high = array($bid[0], $bid[1], $name);
elseif($bid[0] == $high[0] && $bid[1] > $high[1])
$high = array($bid[0], $bid[1], $name);
}
if($high[0] == 0)
{
$this -> bot -> send_output("""Auction is over. No bids where placed. Item is FFA.""both");
}
else
{
$this -> bot -> send_output("""##highlight##".$high[2]."##end## has won the auction for ##highlight##" .
$this -> bid "##end##. ##highlight##".$high[0]."##end## points are being deduced from his account.""both");
$this -> bot -> db -> query("UPDATE #___raid_points SET points = points - " $high[0] .
" WHERE id = " $this -> points_to($high[2]));
}
}
$this -> bid FALSE;
//$this -> unregister_event("cron", "2sec");
}
}

function bid_list($name)
{
if ($this -> bot -> core("security") -> check_access($name"SuperAdmin"))
{
if(empty($this -> bid))
$inside " :: Bidders for Last Auction :: \n\n";
else
$inside " :: Current Bids :: \n\n";
if(!empty($this -> bidders))
{
foreach($this -> bidders as $user => $bid)
{
$inside .= "##highlight##$user##end## has bid ##highlight##".$bid[0]."##end##\n";
}
}

if(empty($this -> bid))
$msg "Bidders for Last Auction :: ";
else
$msg "Current Bids :: ";
$msg .= $this -> bot -> core("tools") -> make_blob("Click to View"$inside);
$this -> bot -> send_tell($name$msg);
}
}



/*
Show info about bidding
*/
function info_bid($name)
{
$inside "##blob_title##::::: Bidding info :::::##end##\n\n";
$inside .= "To place a bid write:\n";
$inside .= "##blob_text##/tell <botname> <pre>bid &lt;points&gt;##end##\n";
$inside .= "(Replace &lt;points&gt; with the number of points you would like to bid)\n\n";
$inside .= "First you may place your bids as stated above.\n";
$inside .= "but please try to bid the highest you're willing to pay right from the start to not make auctions last too long.\n\n";
$inside .= "If two people bid the same amount, the first of the two who placed a bid will get the item. ";
$inside .= "So it really does help bidding the max you're willing to spend right from the start instead of trying \n";
$inside .= "to correct later on.\n";
$this -> bot -> send_tell ($name"Infomation about bidding :: " $this -> bot -> core("tools") -> make_blob("click for info"$inside));
}



/*
Show info about bidding
*/
function info()
{
$inside "##blob_title##::::: Bidding info :::::##end##\n\n";
$inside .= "To place a bid write:\n";
$inside .= "##highlight##/tell <botname> <pre>bid &lt;points&gt;##end##\n";
$inside .= "(Replace &lt;points&gt; with the number of points you would like to bid)\n";
return $this -> bot -> core("tools") -> make_blob("click for info"$inside);
}



/*
Get correct char for points
*/
function points_to($name)
{
return $this -> bot -> commands["tell"]["points"] -> points_to($name);
}
}
?>

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 168
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal