Jump to content
MakeWebGames

[Mcodes V2]Auction Cron Fix[Needed]


HITMAN 17

Recommended Posts

Guys i need an auction cron fix as at the moment the auction is going into -1 day

This is the cron at the moment

<?php
include "config.php";
global $_CONFIG;
if($_GET['code'] != $_CONFIG['code']) { die(""); }
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$db->query("update auctions set time=time-1",$c);
$query = mysql_query("SELECT * FROM auctions WHERE time=0 OR time<0") or die(mysql_error());
while($soc = mysql_fetch_assoc($query))
{

$time=$win['time'];
$item=$win['itemname'];
$winner=$win['bidder'];
$owner=$win['owner'];

$iname=mysql_result($db->query("SELECT itmname FROM items WHERE itmid={$item}", $c), 0, 0);
if($win['bids']>0)
{
$db->query("insert into inventory VALUES('',$item,$winner,1)",$c) or die(mysql_error());
event_add($winner,"You won the auction of the {$iname} for \${$win['current']}",$c);
event_add($owner, "Your {$iname} sold succesfully on the auction market with {$win['bids']} bids. You have been paid \${$win['current']}", $c);
$db->query("update users set money=money+{$win['current']},auctionquota=auctionquota-1 where userid=$owner", $c);
}
if($win['bids']==0)
{
event_add($win['owner'],"Your auction has ended with no bidders. Your {$iname} has been returned to your inventory.",$c);

$winner=$win['owner'];

$db->query("insert into inventory VALUES('',$item,$winner,1)",$c) or die(mysql_error());

}
}
$db->query("delete from auctions where time=0", $c);

?>
Link to comment
Share on other sites

Re: [Mcodes V2]Auction Cron Fix[Needed]

should

$db->query("delete from auctions where time=0", $c);

be

$db->query("DELETE FROM 'auctions' WHERE 'time' <0", $c);

or

$db->query("DELETE FROM 'auctions' WHERE time ==0", $c);

Keep in mind I am a total noob and I am probably way wrong!!!

Link to comment
Share on other sites

Re: [Mcodes V2]Auction Cron Fix[Needed]

 

<?php
/*-----------------------------------------------------
-- Psychotic Insanity
-- A product of iMatters Game and Web Design
-- Copyright held 2008 by ~Spooky~
-- E-mail: sexysalemchickgamer[AT]hotmail[DOT]com
-----------------------------------------------------*/
include "config.php";
if($_GET['code'] != $_CONFIG['code']) { die(""); }
require "mysql.php";

mysql_query("UPDATE auctions SET time=time-1 WHERE time>0",$c);
$qqq=mysql_query("SELECT * FROM auctions WHERE time=0",$c);
while($win=mysql_fetch_array($qqq))
{

$time=$win['time'];
$item=$win['itemname'];
$winner=$win['bidder'];
$owner=$win['owner'];

$iname=mysql_result(mysql_query("SELECT itmname FROM items WHERE itmid={$item}", $c), 0, 0);
if($win['bids']>0)
{
mysql_query("insert into inventory VALUES('',$item,$winner,1)",$c) or die(mysql_error());

mysql_query("INSERT INTO events VALUES('',$winner,UNIX_TIMESTAMP(),0,'You won the auction of the {$iname} for \${$win['current']}')",$c) or die(mysql_error());
mysql_query("INSERT INTO events VALUES('',$owner,UNIX_TIMESTAMP(),0,'Your {$iname} sold succesfully on the auction market with {$win['bids']} bids. You have been paid \${$win['current']}')",$c) or die(mysql_error());
mysql_query("UPDATE users SET new_events=new_events+1 WHERE owner={$userid}", $c);
mysql_query("UPDATE users SET new_events=new_events+1 WHERE winner={$userid}", $c);
mysql_query("update users set money=money+{$win['current']},auctionquota=auctionquota-1 where userid=$owner", $c);
}
if($win['bids']==0)
{
$owner=$win['owner'];
mysql_query("INSERT INTO events VALUES('',$owner,UNIX_TIMESTAMP(),0,'Your auction has ended with no bidders. Your {$iname} has been returned to your inventory.')",$c) or die(mysql_error());
$winner=$win['owner'];

mysql_query("insert into inventory VALUES('',$item,$winner,1)",$c) or die(mysql_error());

}
}
mysql_query("DELETE FROM auctions WHERE time=0", $c);
print "Done!";
?>

 

Try that code. Works on my game.

May need to edit little I do run both V1 and V2 games. If you add the mysql to your V2 it be just fine.

Link to comment
Share on other sites

  • 2 weeks later...

Re: [Mcodes V2]Auction Cron Fix[Needed]

 

should

$db->query("delete from auctions where time=0", $c);

be

$db->query("DELETE FROM 'auctions' WHERE 'time' <0", $c);

or

$db->query("DELETE FROM 'auctions' WHERE time ==0", $c);

Keep in mind I am a total noob and I am probably way wrong!!!

$db->query('DELETE FROM `auctions` WHERE `time` <= 0');

i would use that

Link to comment
Share on other sites

  • 5 weeks later...

Re: [Mcodes V2]Auction Cron Fix[Needed]

 

<?php

include "config.php";
if($_GET['code'] != $_CONFIG['code']) { die(""); }
require "mysql.php";
require "global_func.php";

$time = ("UPDATE auctions SET time = time - 1 WHERE time > 0");
mysql_query($time);

$getit = sprintf("SELECT * FROM autctions WHERE time = '%d' ",
(0));
	$doit = mysql_query($getit);
while ($win = mysql_fetch_arrya($doit)
{
$time=$win['time'];
$item=$win['itemname'];
$winner=$win['bidder'];
$owner=$win['owner'];

$iname=mysql_result(mysql_query("SELECT itmname FROM items WHERE itmid={$item}", $c), 0, 0);

if($win['bids'] > 0)
{
	item_add($winner,$item,1); //amazing how much easier item add is huh?
	event_add($winner, "You won the auction of the {$iname} for \${$win['current']}."); //another amazing feature
	event_add($owner, "Your {$iname} sold succesfully on the auction market with {$win['bids']} bids. You have been paid \${$win['current']}.");
	$do1 = ("UPDATE users SET new_events = new_events + 1 WHERE owner = ".$userid." ");
	$do2 = ("UPDATE users SET new_events = new_events + 1 WHERE winner = ".$userid." ");
	$do3 = ("UPDATE users SET money = money + ".$win['current'].", auctionquota = auctionquota - 1 WHERE userid = $owner");
		mysql_query($do1);
		mysql_query($do2);
		mysql_query($do3);
}

	if($win['bids'] == 0)
	{
		$owner = $win['owner'];
		event_add($owner, "Your auction has ended with no bidders. Your {$iname} has been returned to your inventory.");
		item_add($owner,$item,1);
	}
}

$delete = ("DELETE FROM auctions WHERE time <= 0");
mysql_query($delete);

print "Done!";
?>
Link to comment
Share on other sites

Re: [Mcodes V2]Auction Cron Fix[Needed]

 

[code]
<?php

include "config.php";
global $_CONFIG;
if($_GET['code'] != $_CONFIG['code']) { die(""); }
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
require "global_func.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$set=array();
$settq=$db->query("SELECT * FROM settings");
while($r=$db->fetch_row($settq))
{
$set[$r['conf_name']]=$r['conf_value'];
}

$time = ("UPDATE auctions SET time = time - 1 WHERE time > 0");
mysql_query($time);

$getit = sprintf("SELECT * FROM autctions WHERE time = '%d' ",
(0));
	$doit = mysql_query($getit);
while ($win = mysql_fetch_arrya($doit)
{
$time=$win['time'];
$item=$win['itemname'];
$winner=$win['bidder'];
$owner=$win['owner'];

$iname=mysql_result(mysql_query("SELECT itmname FROM items WHERE itmid={$item}", $c), 0, 0);

if($win['bids'] > 0)
{
	item_add($winner,$item,1); //amazing how much easier item add is huh?
	event_add($winner, "You won the auction of the {$iname} for \${$win['current']}."); //another amazing feature
	event_add($owner, "Your {$iname} sold succesfully on the auction market with {$win['bids']} bids. You have been paid \${$win['current']}.");
	$do1 = ("UPDATE users SET new_events = new_events + 1 WHERE owner = ".$userid." ");
	$do2 = ("UPDATE users SET new_events = new_events + 1 WHERE winner = ".$userid." ");
	$do3 = ("UPDATE users SET money = money + ".$win['current'].", auctionquota = auctionquota - 1 WHERE userid = $owner");
		mysql_query($do1);
		mysql_query($do2);
		mysql_query($do3);
}

	if($win['bids'] == 0)
	{
		$owner = $win['owner'];
		event_add($owner, "Your auction has ended with no bidders. Your {$iname} has been returned to your inventory.");
		item_add($owner,$item,1);
	}
}

$delete = ("DELETE FROM auctions WHERE time <= 0");
mysql_query($delete);

print "Done!";
?>

 

if that dont work, I don't have any idea....

[/code]

Link to comment
Share on other sites

  • 10 months later...

This works 1000%

 

<?php
include "config.php";
global $_CONFIG;
if($_GET['code'] != $_CONFIG['code']) { die(""); }
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$db->query("update auctions set time=time-1",$c);
$qqq=$db->query("select * from auctions where time=0",$c);
while($win=$db->fetch_row($qqq))
{

$time=$win['time'];
$item=$win['itemname'];
$winner=$win['bidder'];
$owner=$win['owner'];

$iname=$db->result(
$db->query("SELECT itmname FROM items WHERE itmid={$item}", $c), 0, 0);
if($win['bids']>0)
{

$db->query("insert into inventory VALUES('',$item,$winner,1)",$c) or die(mysql_error());
event_add($winner,"You won the auction of the {$iname} for \${$win['current']}",$c);
event_add($owner, "Your {$iname} sold succesfully on the auction market with {$win['bids']} bids. You have been paid \${$win['current']}", $c);

$db->query("update users set money=money+{$win['current']},auctionquota=auctionquota-1 where userid=$owner", $c);
}
if($win['bids']==0)
{
event_add($win['owner'],"Your auction has ended with no bidders. Your {$iname} has been returned to your inventory.",$c);

$winner=$win['owner'];


$db->query("insert into inventory VALUES('',$item,$winner,1)",$c) or die(mysql_error());

}
}
$delete = ("DELETE FROM auctions WHERE time <= 0");
mysql_query($delete);

?>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...