Jump to content
MakeWebGames

Recommended Posts

Sim hasn't replied to me yet but he said he will check everything. 

 

Having a crazy issue with battle ladder

<?php

include __DIR__."/config.php";

global $_CONFIG;

$code = null;

if (isset($argv)) {

    parse_str($argv[1], $params);

    $code = $params['code'];

} else {

    $code = array_key_exists('code', $_GET) && ctype_alnum($_GET['code']) ? $_GET['code'] : null;

}

if($code != $_CONFIG['code']) { exit; }

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;

include "global_func.php";

   $fetch = $db->query("SELECT * FROM `battle_ladders` ORDER BY `ladderLevel` ASC");

   while($ft = $db->fetch_row($fetch))

    {

      $count = 0;

      $sql = $db->query(sprintf("SELECT * FROM `battle_members` LEFT JOIN `users` ON `userid` = `bmemberUser` WHERE `bmemberLadder` = '%u' ORDER BY `bmemberScore` DESC LIMIT 10", $ft['ladderId']));

      while($r = $db->fetch_row($sql))

       {

         $count ++;

         $cash = ((((rand(50, 75) / 10) * $r['level']) / $count) * ($ft['ladderLevel'] + 1));

         $points = ((((rand(1, 2) / 10) * $r['level']) / $count) * ($ft['ladderLevel'] + 1));

         if($r['userid'])

          {

            $db->query(sprintf("UPDATE `users` SET `money` = `money` + '%d', `crystals` = `crystals` + '%d' WHERE `userid` = '%u'", $cash, $points, $r['bmemberUser']));

            event_add($r['bmemberUser'], 'You have earned $'.number_format($cash).' and '.number_format($points).' Points for achieveing rank #'.$count.' in the '.$ft['ladderName'].' ladder!');

          }

       }

    }

   $db->query("TRUNCATE TABLE battle_members;");

   


   

?>

 

This is my battle Cron and somehow it's awarding over 100million crystals. 

Link to post
Share on other sites

Well I think i found the bug .. that's causing the doubling issue . I think it's docrime.php there's a queries that is doubling. 

 

$db->query("UPDATE users SET money=money+{$r['crimeSUCCESSMUNY']}, crystals=crystals+{$r['crimeSUCCESSCRYS']}, exp=exp+$formula, crimexp=crimexp+{$r['crimeXP']}, crimes=crimes+1 WHERE userid=$userid");
           

I'm not sure if this is the error but I think it is ..

Link to post
Share on other sites
On 6/14/2021 at 10:37 AM, athena26 said:

Well I think i found the bug .. that's causing the doubling issue . I think it's docrime.php there's a queries that is doubling. 

 

$db->query("UPDATE users SET money=money+{$r['crimeSUCCESSMUNY']}, crystals=crystals+{$r['crimeSUCCESSCRYS']}, exp=exp+$formula, crimexp=crimexp+{$r['crimeXP']}, crimes=crimes+1 WHERE userid=$userid");
           

I'm not sure if this is the error but I think it is ..

No, that’s not it. It’s only updating 1 time

Edited by KyleMassacre
Link to post
Share on other sites
32 minutes ago, Sim said:

Mind telling us what it was

mainmenu.php
Not 100% sure what was doing it, guessing its the clock function maybe.
Rewrote and bug gone 🙂

<?php     
global $db,$c,$ir, $set, $userid;
$hc = $db->query("SELECT * FROM users WHERE hospital > 0");
$hospitalcount = $db->num_rows($hc);
$jc = $db->query("SELECT * FROM users WHERE jail > 0");
$jailcount = $db->num_rows($jc);
$worksho = $db->query("SELECT * FROM itemscreated WHERE iUSER=$userid");
$workshop = $db->num_rows($worksho);
$ec=$ir['new_events'];
$mc=$ir['new_mail'];
if($ir['hospital'])
{
print "

<div class='navipart'>
<div class='navitop'><p>
<img src='images/navi_txt.gif' alt='' />
</p></div>

<div class='navi_mid'><ul>



<li> <a class='link1' href='index.php'>Home</a></li>
<li> <a class='link1' href='shops.php'>Medical Shop</a></li>
<li><a class='link1' href='jail.php'>Jail ({$jailcount})</a></li>
<li> <a class='link1' href='hospital.php'>Hospital ({$hospitalcount})</a></li> 
<li> <a class='link1' href='inventory.php'>Inventory</a></li>
<li> <a class='link1' href='workshop.php'>Workshop ($workshop)</a></li>";
}
elseif($ir['jail'])
{

print "

<div class='navipart'>
<div class='navitop'><p>
<img src='images/navi_txt.gif' alt='' />
</p></div>

<div class='navi_mid'><ul>


<li><a class='link1' href='jail.php'>Jail ({$jailcount})</a></li>";
}
else
{
    
print "


<div class='navipart'>
<div class='navitop'><p>
<img src='images/navi_txt.gif' alt='' />
</p></div>

<div class='navi_mid'><ul>


<li><a class='link1' href='index.php'>Home</a></li>
<li><a class='link1' href='inventory.php'>Inventory</a></li>
<li><a class='link1' href='workshop.php'>Workshop ($workshop)</a></li>";
}
if($ec > 0) { print "<li> <a class='link1' href='events.php'>Events ($ec)</a></li>"; }
else { print "<li> <a class='link1' href='events.php'>Events (0)</a></li>"; }
if($mc > 0) { print "<li> <a class='link1' href='mailbox.php'>Mailbox ($mc)</a></li>"; }
else { print "<li> <a class='link1' href='mailbox.php'>Mailbox (0)</a></li>";
}
if($ir['chathide'] == 1){
    print"<li><a class='link1' href='chat.php'>Chat</a></li>";
}
if($ir['new_announcements'])
{
print "<li> <a class='link1' href='announcements.php' style='font-weight: 800;'>Announcements ({$ir['new_announcements']})</a></li>";
}
else
{
print "<li> <a class='link1' href='announcements.php'>Announcements (0)</a></li>";
}


if($ir['jail'] and !$ir['hospital'])
{
print "<li> <a class='link1' href='gym.php'>Jail Gym</a></li>
<li><a class='link1' href='inventory.php'>Inventory</a></li>

<li> <a class='link1' href='hospital.php'>Hospital({$hospitalcount})</a></li>";
}
else if (!$ir['hospital'])
{
print "<li> <a class='link1' href='explore.php'>Explore</a></li>
<li> <a class='link1' href='gym.php'>Gym</a></li>
<li> <a class='link1' href='criminal.php'>Crimes</a></li>
<li> <a class='link1' href='gta.php'>GTA</a></li>
<li> <a class='link1' href='job.php'>Your Job</a></li>
<li> <a class='link1' href='business_home.php'>Your Business</a></li>
<li> <a class='link1' href='stocks.php'>Stock Market</a></li>  
<li> <a class='link1' href='competition.php'>Game Events</a></li>

<li> <a class='link1' href='contest.php'>Contest</a></li>
<li> <a class='link1' href='hospital.php'>Hospital  ({$hospitalcount})</a></li>
<li> <a class='link1' href='jail.php'>Jail ({$jailcount})</a></li>";
}
else
{
print "<li> <a class='link1' href='jail.php'>Jail ({$jailcount})</a></li>";
}
print "<li> <a class='link1' href='forums.php'>Forums</a></li>";

print "
<li> <a class='link1' href='newspaper.php'>Newspaper</a></li>
<li> <a class='link1' href='search.php'>Search</a></li>";
if(!$ir['jail'] && $ir['gang'])
{
print "<li> <a class='link1' href='zFamily.php?p=myFam'><font color = green>Your Gang</a></li>


</div>

<div><img src='images/navi_btm.gif' alt='' /></div>
</div>  


";
}
if($ir['user_level'] > 1)
{
print "


<div class='navipart'>
<div class='navitop'><p>
<img src='images/staff_links.gif' alt='' /> 
</p></div>
<div class='navi_mid'><ul>


<li> <a class='link1' href='staff.php'>Staff Panel</a></li>

";

if ($userid == '1') {
    echo "<li> <a class='link1' href='ownerpanel.php'>Owner Panel</a></li>";;
}

print "

</div>
<div><img src='images/navi_btm.gif' alt='' /></div>
</div>";


print "

<div class='navipart'>
<div class='navitop'><p>
<img src='images/staff_online.gif' alt='' />
</p></div>
<div class='navi_mid'><ul> 
";
$q=$db->query("SELECT * FROM users WHERE laston>(unix_timestamp()-15*60) AND user_level>1 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
$la=time()-$r['laston'];
$unit="secs";
if($la >= 60)
{
$la=(int) ($la/60);
$unit="mins";
}
if($la >= 60)
{
$la=(int) ($la/60);
$unit="hours";
if($la >= 24)
{
$la=(int) ($la/24);
$unit="days";
}
}
print "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> ($la $unit)<br>
</div><div><img src='images/navi_btm.gif' alt='' /></div> </div>  

";
}
}
if($ir['donatordays'])
{
print "


<div class='navipart'>
<div class='navitop'><p>
<img src='images/donators_only.gif' alt='' />
</p></div>
<div class='navi_mid'><ul> 

<li> <a class='link1' href='friendslist.php'>Friends List</a></li>
<li> <a class='link1' href='blacklist.php'>Black List</a></li>
<li> <a class='link1' href='ddreward.php'>Daily Rewards</a></li>
<li> <a class='link1' href='vipgym.php'>VIP Gym</a></li>

</div>

<div><img src='images/navi_btm.gif' alt='' /></div>
</div>  


";
}
print "


<div class='navipart'>
<div class='navitop'><p>
<img src='images/other_links.gif' alt='' />
</p></div>
<div class='navi_mid'><ul> 


<li> <a class='link1' href='preferences.php'>Preferences</a></li>
<li> <a class='link1' href='preport.php'>Player Report</a></li>
<li> <a class='link1' href='helptutorial.php'>Help Tutorial</a></li>
<li> <a class='link1' href='gamerules.php'>Game Rules</a></li>
<li> <a class='link1' href='viewuser.php?u={$ir['userid']}'>My Profile</a></li>
<li> <a class='link1' href='logout.php'>Logout</a></li>

</div>

<div><img src='images/navi_btm.gif' alt='' /></div>
</div>  


" ; 

echo("<table border='1' width='85%' bordercolor='white'>
<tr style='background: url('.$bimage.');'><th><font color=gold>Time and Date</th></tr><tr><td style='background:  url('.$bimage.');'><font color=gold>".date ('F j, Y')."<br />".date('g:i  a')."</td></tr></table>");



?>

Welcome to see if you can figure it out, This is the before i fixed it mainmenu.php

After looking through it i still cant see the issue lol.
All i know is i removed and rewrote and bang, double issue fixed.
Spooky.

Link to post
Share on other sites
<?php

require_once('globals_nonauth.php');

if(!isset($_GET['code']) || $_GET['code'] !== $_CONFIG['code'])
	exit;
else 
{
	$con6 = $db->query("SELECT `contest_status` FROM `contest_config` WHERE `id` = 6");
	if($db->fetch_single($con6) == 'Disabled')
		exit;
	# - Top Monthly Stats - #
	$config = $db->query("SELECT `rtype`,`first`,`second`,`third`,`group`,`lvlgroup` FROM `contest_config` WHERE `group` = 'TMS' AND `lvlgroup` = '10-35'");
	$ret = $db->fetch_row($config);
	$config2 = $db->query("SELECT `rtype`,`first`,`second`,`third`,`group`,`lvlgroup` FROM `contest_config` WHERE `group` = 'TMS' AND `lvlgroup` = '36-99'");
	$ret2 = $db->fetch_row($config2);
	$config3 = $db->query("SELECT `rtype`,`first`,`second`,`third`,`group`,`lvlgroup` FROM `contest_config` WHERE `group` = 'TMS' AND `lvlgroup` = '100+'");
	$ret3 = $db->fetch_row($config3);
	# - Top Monthly Levelers - #
	$config4 = $db->query("SELECT `rtype`,`first`,`second`,`third`,`group`,`lvlgroup` FROM `contest_config` WHERE `id` = 4");
	$ret4 = $db->fetch_row($config4);
	# - Top Monthly Refferals - #
	$config5 = $db->query("SELECT `rtype`,`first`,`second`,`third`,`group`,`lvlgroup` FROM `contest_config` WHERE `id` = 5");
	$ret5 = $db->fetch_row($config5);
	
	$groupone = $db->query("SELECT `userid`,`statsgained` FROM `users` WHERE `level` > 9 AND `level` < 36 ORDER BY `statsgained` DESC LIMIT 3");
	$i = 0;
	while($row = $db->fetch_row($groupone)) 
	{
   		if($row['statsgained'] == 0) {} 
   		else 
		{
	   		$i++;
        		if($i == 1) 
			{
				if($ret['rtype'] == 'crystals')
				{
					$prize = $ret['first'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$row['userid']);
					event_add($row['userid'], 'You came 1st in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded 
					'.$ret['first'].' Crystals.');
				}
				else if($ret['rtype'] == 'money')
				{
					$prize = $ret['first'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$row['userid']);
					event_add($row['userid'], 'You came 1st in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded $'.$ret['first'].'.');
				}
				else if($ret['rtype'] == 'item')
				{
					$prize = $ret['first'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($row['userid'], 'You came 1st in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded
					'.itemname($ret['first']).'.');
					item_add($row['userid'], $ret['first'], 1);
				}
				else if($ret['rtype'] == 'exp')
				{
					$prize = $ret['first'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$row['userid']);
					event_add($row['userid'], 'You came 1st in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded '.$ret['first'].' exp.');
				}
        		} 
			else if($i == 2) 
			{
				if($ret['rtype'] == 'crystals')
				{
					$prize = $ret['second'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$row['userid']);
					event_add($row['userid'], 'You came 2nd in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded 
					'.$ret['second'].' Crystals.');
				}
				else if($ret['rtype'] == 'money')
				{
					$prize = $ret['second'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$row['userid']);
					event_add($row['userid'], 'You came 2nd in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded $'.$ret['second'].'.');
				}
				else if($ret['rtype'] == 'item')
				{
					$prize = $ret['second'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($row['userid'], 'You came 2nd in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded 
					'.itemname($ret['second']).'.');
					item_add($row['userid'], $ret['second'], 1);
				}
				else if($ret['rtype'] == 'exp')
				{
					$prize = $ret['second'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$row['userid']);
					event_add($row['userid'], 'You came 2nd in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded '.$ret['second'].' exp.');
				}
        		} 
			else if($i == 3) 
			{
				if($ret['rtype'] == 'crystals')
				{
					$prize = $ret['third'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$row['userid']);
					event_add($row['userid'], 'You came 3rd in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded 
					'.$ret['third'].' Crystals.');
				}
				else if($ret['rtype'] == 'money')
				{
					$prize = $ret['third'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$row['userid']);
					event_add($row['userid'], 'You came 3rd in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded $'.$ret['third'].'.');
				}
				else if($ret['rtype'] == 'item')
				{
					$prize = $ret['third'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($row['userid'], 'You came 3rd in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded 
					'.itemname($ret['third']).'.');
					item_add($row['userid'], $ret['third'], 1);
				}
				else if($ret['rtype'] == 'exp')
				{
					$prize = $ret['third'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$row['userid']);
					event_add($row['userid'], 'You came 3rd in '.$ret['group'].' '.$ret['lvlgroup'].' and been awarded '.$ret['third'].' exp.');
				}
        		}
        		$db->query("INSERT INTO `cwinners` VALUES 
        			('','topstats','".$row['userid']."','".$row['statsgained']."','".time()."','10-35','".$prize."','".$ret['rtype']."')");
        	}
	}
    	/* Top Monthly Stats Level 36-99 */
   	$grouptwo = $db->query("SELECT `userid`,`statsgained` FROM `users` WHERE `level` > 35 AND `level` < 100 ORDER BY `statsgained` DESC LIMIT 3");	
	$i = 0;
	while($row2 = $db->fetch_row($grouptwo)) 
	{
		if($row2['statsgained'] == 0) {}
		else 
		{
			$i++;
        		if($i == 1) 
			{
				if($ret2['rtype'] == 'crystals')
				{
					$prize = $ret2['first'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$row2['userid']);
					event_add($row2['userid'], 'You came 1st in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					'.$ret2['first'].' Crystals.');
				}
				else if($ret2['rtype'] == 'money')
				{
					$prize = $ret2['first'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$row2['userid']);
					event_add($row2['userid'], 'You came 1st in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded $'.$ret2['first'].'.');
				}
				else if($ret2['rtype'] == 'item')
				{
					$prize = $ret2['first'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($row2['userid'], 'You came 1st in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					'.itemname($ret2['first']).'.');
					item_add($row2['userid'], $ret2['first'], 1);
				}
				else if($ret['rtype'] == 'exp')
				{
					$prize = $ret2['first'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$row2['userid']);
					event_add($row2['userid'], 'You came 1st in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					'.$ret2['first'].' exp.');
				}
        		} 
			else if($i == 2) 
			{
				if($ret2['rtype'] == 'crystals')
				{
					$prize = $ret2['second'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$row2['userid']);
					event_add($row2['userid'], 'You came 2nd in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					'.$ret2['second'].' Crystals.');
				}
				else if($ret2['rtype'] == 'money')
				{
					$prize = $ret2['second'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$row2['userid']);
					event_add($row2['userid'], 'You came 2nd in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					$'.$ret2['second'].'.');
				}
				else if($ret2['rtype'] == 'item')
				{
					$prize = $ret2['second'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($row2['userid'], 'You came 2nd in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					'.itemname($ret2['second']).'.');
					item_add($row2['userid'], $ret2['second'], 1);
				}
				else if($ret2['rtype'] == 'exp')
				{
					$prize = $ret2['second'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$row2['userid']);
					event_add($row2['userid'], 'You came 2nd in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					'.$ret2['second'].' exp.');
				}
        		} 
			else if($i == 3) 
			{
				if($ret2['rtype'] == 'crystals')
				{
					$prize = $ret2['third'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$row2['userid']);
					event_add($row2['userid'], 'You came 3rd in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					'.$ret2['third'].' Crystals.');
				}
				else if($ret2['rtype'] == 'money')
				{
					$prize = $ret2['third'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$row2['userid']);
					event_add($row2['userid'], 'You came 3rd in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded $'.$ret2['third'].'.');
				}
				else if($ret2['rtype'] == 'item')
				{
					$prize = $ret2['third'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($row2['userid'], 'You came 3rd in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					'.itemname($ret2['third']).'.');
					item_add($row2['userid'], $ret2['third'], 1);
				}
				else if($ret2['rtype'] == 'exp')
				{
					$prize = $ret2['third'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$row2['userid']);
					event_add($row2['userid'], 'You came 3rd in '.$ret2['group'].' '.$ret2['lvlgroup'].' and been awarded 
					'.$ret2['third'].' exp.');
				}
        		}
        		$db->query("INSERT INTO `cwinners` VALUES 
        			('','topstats','".$row2['userid']."','".$row2['statsgained']."','".time()."','36-99','".$prize."','".$ret2['rtype']."')");	
		}
	}
	/* Top Monthly Stats Level 100+ */
    	$groupthree = $db->query("SELECT `userid`,`statsgained` FROM `users` WHERE `level` > 99 ORDER BY `statsgained` DESC LIMIT 3");	
	$i = 0;
	while($row3 = $db->fetch_row($groupthree)) 
	{
		if($row3['statsgained'] == 0) {}
		else 
		{
			$i++;
			if($i == 1) 
			{
				if($ret3['rtype'] == 'crystals')
				{
					$prize = $ret3['first'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$row3['userid']);
					event_add($row3['userid'], 'You came 1st in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded 
					'.$ret3['first'].' Crystals.');
				}
				else if($ret3['rtype'] == 'money')
				{
					$prize = $ret3['first'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$row3['userid']);
					event_add($row3['userid'], 'You came 1st in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded $'.$ret3['first'].'.');
				}
				else if($ret3['rtype'] == 'item')
				{
					$prize = $ret3['first'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($row3['userid'], 'You came 1st in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded
					'.itemname($ret3['first']).'.');
					item_add($row3['userid'], $ret3['first'], 1);
				}
				else if($ret3['rtype'] == 'exp')
				{
					$prize = $ret3['first'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$row3['userid']);
					event_add($row3['userid'], 'You came 1st in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded 
					'.$ret3['first'].' exp.');
				}
        		}
			else if($i == 2) 
			{
				if($ret3['rtype'] == 'crystals')
				{
					$prize = $ret3['second'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$row3['userid']);
					event_add($row3['userid'], 'You came 2nd in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded 
					'.$ret3['second'].' Crystals.');
				}
				else if($ret3['rtype'] == 'money')
				{
					$prize = $ret3['second'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$row3['userid']);
					event_add($row3['userid'], 'You came 2nd in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded 
					$'.$ret3['second'].'.');
				}
				else if($ret3['rtype'] == 'item')
				{
					$prize = $ret3['second'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($row3['userid'], 'You came 2nd in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded 
					'.itemname($ret3['second']).'.');
					item_add($row3['userid'], $ret3['second'], 1);
				}
				else if($ret3['rtype'] == 'exp')
				{
					$prize = $ret3['second'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$row3['userid']);
					event_add($row3['userid'], 'You came 2nd in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded 
					'.$ret3['second'].' exp.');
				}
        		} 
			else if($i == 3) 
			{
				if($ret3['rtype'] == 'crystals')
				{
					$prize = $ret3['third'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$row3['userid']);
					event_add($row3['userid'], 'You came 3rd in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded 
					'.$ret3['third'].' Crystals.');
				}
				else if($ret3['rtype'] == 'money')
				{
					$prize = $ret3['third'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$row3['userid']);
					event_add($row3['userid'], 'You came 3rd in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded $'.$ret3['third'].'.');
				}
				else if($ret3['rtype'] == 'item')
				{
					$prize = $ret3['third'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($row3['userid'], 'You came 3rd in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded 
					'.itemname($ret3['third']).'.');
					item_add($row3['userid'], $ret3['third'], 1);
				}
				else if($ret3['rtype'] == 'exp')
				{
					$prize = $ret3['third'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$row3['userid']);
					event_add($row3['userid'], 'You came 3rd in '.$ret3['group'].' '.$ret3['lvlgroup'].' and been awarded 
					'.$ret3['third'].' exp.');
				}
        		}
        		$db->query("INSERT INTO `cwinners` VALUES 
        			('','topstats',".$row3['userid'].",".$row3['statsgained'].",".time().",'100+',".$prize.",'".$ret3['rtype']."')");	
		}
	}
	/* Top Monthly Leveler */
	$topl = $db->query("SELECT `userid`,`levelsgained` FROM `users` ORDER BY `levelsgained` DESC LIMIT 3");	
	$i = 0;
	while($l = $db->fetch_row($topl)) 
	{
		if($l['levelsgained'] == 0) {}
		else 
		{
			$i++;
			if($i == 1) 
			{
				if($ret4['rtype'] == 'crystals')
				{
					$prize = $ret4['first'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$l['userid']);
					event_add($l['userid'], 'You came 1st in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded 
					'.$ret4['first'].' Crystals.');
				}
				else if($ret4['rtype'] == 'money')
				{
					$prize = $ret4['first'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$l['userid']);
					event_add($l['userid'], 'You came 1st in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded $'.$ret4['first'].'.');
				}
				else if($ret4['rtype'] == 'item')
				{
					$prize = $ret4['first'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($l['userid'], 'You came 1st in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded 
					'.itemname($ret4['first']).'.');
					item_add($l['userid'], $ret4['first'], 1);
				}
				else if($ret4['rtype'] == 'exp')
				{
					$prize = $ret4['first'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$l['userid']);
					event_add($l['userid'], 'You came 1st in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded '.$ret4['first'].' exp.');
				}
        		} 
			else if($i == 2) 
			{
				if($ret4['rtype'] == 'crystals')
				{
					$prize = $ret4['second'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$l['userid']);
					event_add($l['userid'], 'You came 2nd in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded '.$ret4['second'].'
					 Crystals.');
				}
				else if($ret4['rtype'] == 'money')
				{
					$prize = $ret4['second'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$l['userid']);
					event_add($l['userid'], 'You came 2nd in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded $'.$ret4['second'].'.');
				}
				else if($ret4['rtype'] == 'item')
				{
					$prize = $ret4['second'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($l['userid'], 'You came 2nd in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded 
					'.itemname($ret4['second']).'.');
					item_add($l['userid'], $ret4['second'], 1);
				}
				else if($ret4['rtype'] == 'exp')
				{
					$prize = $ret4['second'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$l['userid']);
					event_add($l['userid'], 'You came 2nd in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded '.$ret4['second'].' 
					exp.');
				}
        		} 
			else if($i == 3) 
			{
				if($ret4['rtype'] == 'crystals')
				{
					$prize = $ret4['third'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$l['userid']);
					event_add($l['userid'], 'You came 3rd in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded 
					'.$ret4['third'].' Crystals.');
				}
				else if($ret4['rtype'] == 'money')
				{
					$prize = $ret4['third'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$l['userid']);
					event_add($l['userid'], 'You came 3rd in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded $'.$ret4['third'].'.');
				}
				else if($ret4['rtype'] == 'item')
				{
					$prize = $ret4['third'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($l['userid'], 'You came 3rd in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded 
					'.itemname($ret4['third']).'.');
					item_add($l['userid'], $ret4['third'], 1);
				}
				else if($ret4['rtype'] == 'exp')
				{
					$prize = $ret4['third'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$l['userid']);
					event_add($l['userid'], 'You came 3rd in '.$ret4['group'].' '.$ret4['lvlgroup'].' and been awarded '.$ret4['third'].' exp.');
				}
        		}
        		$db->query("INSERT INTO `cwinners` VALUES 
        			('','topleveler',".$l['userid'].",".$l['levelsgained'].",".time().",'N/A',".$prize.",'".$ret4['rtype']."')");	
		}
	}
	/* Top Monthly Refferals */
	$topr = $db->query("SELECT `userid`,`refferalsgained` FROM `users` ORDER BY `refferalsgained` DESC LIMIT 3");	
	$i = 0;
	while($r = $db->fetch_row($topr)) 
	{
		if($r['refferalsgained'] == 0) {}
		else 
		{
			$i++;
			if($i == 1) 
			{
				if($ret5['rtype'] == 'crystals')
				{
					$prize = $ret5['first'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$r['userid']);
					event_add($r['userid'], 'You came 1st in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded 
					'.$ret5['first'].' Crystals.');
				}
				else if($ret5['rtype'] == 'money')
				{
					$prize = $ret5['first'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$r['userid']);
					event_add($r['userid'], 'You came 1st in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded $'.$ret5['first'].'.');
				}
				else if($ret5['rtype'] == 'item')
				{
					$prize = $ret5['first'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($r['userid'], 'You came 1st in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded 
					'.itemname($ret5['first']).'.');
					item_add($r['userid'], $ret5['first'], 1);
				}
				else if($ret5['rtype'] == 'exp')
				{
					$prize = $ret5['first'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$r['userid']);
					event_add($r['userid'], 'You came 1st in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded '.$ret5['first'].' exp.');
				}
        		} 
			else if($i == 2) 
			{
				if($ret5['rtype'] == 'crystals')
				{
					$prize = $ret5['second'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$r['userid']);
					event_add($r['userid'], 'You came 2nd in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded 
					'.$ret5['second'].' Crystals.');
				}
				else if($ret5['rtype'] == 'money')
				{
					$prize = $ret5['second'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$r['userid']);
					event_add($r['userid'], 'You came 2nd in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded $'.$ret5['second'].'.');
				}
				else if($ret5['rtype'] == 'item')
				{
					$prize = $ret5['second'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($r['userid'], 'You came 2nd in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded 
					'.itemname($ret5['second']).'.');
					item_add($r['userid'], $ret5['second'], 1);
				}
				else if($ret5['rtype'] == 'exp')
				{
					$prize = $ret5['second'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$r['userid']);
					event_add($r['userid'], 'You came 2nd in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded 
					'.$ret5['second'].' exp.');
				}
        		} 
			else if($i == 3) 
			{
				if($ret5['rtype'] == 'crystals')
				{
					$prize = $ret5['third'];
					$db->query("UPDATE `users` SET `crystals` = `crystals` + '$prize' WHERE `userid` = ".$r['userid']);
					event_add($r['userid'], 'You came 3rd in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded 
					'.$ret5['third'].' Crystals.');
				}
				else if($ret5['rtype'] == 'money')
				{
					$prize = $ret5['third'];
					$db->query("UPDATE `users` SET `money` = `money` + '$prize' WHERE `userid` = ".$r['userid']);
					event_add($r['userid'], 'You came 3rd in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded $'.$ret5['third'].'.');
				}
				else if($ret5['rtype'] == 'item')
				{
					$prize = $ret5['third'];
					$item = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` = ".$prize."");
					event_add($r['userid'], 'You came 3rd in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded 
					'.itemname($ret5['third']).'.');
					item_add($r['userid'], $ret5['third'], 1);
				}
				else if($ret5['rtype'] == 'exp')
				{
					$prize = $ret5['third'];
					$db->query("UPDATE `users` SET `exp` = `exp` + '$prize' WHERE `userid` = ".$r['userid']);
					event_add($r['userid'], 'You came 3rd in '.$ret5['group'].' '.$ret5['lvlgroup'].' and been awarded '.$ret5['third'].' exp.');
				}
        		}
        		$db->query("INSERT INTO `cwinners` VALUES 
        			('','topreferals',".$r['userid'].",".$r['refferalsgained'].",".time().",'N/A',".$prize.",'".$ret5['rtype']."')");
		}
	}
	$db->query("UPDATE `users` SET `statsgained` = 0,`levelsgained` = 0,`refferalsgained` = 0");
	event_add(1, "The contest has ended all stats and been reset back to 0");
	$db->query("UPDATE `contest_config` SET `contest_status` = 'Disabled' WHERE `id` = 6");
}
?>

For some reason my contest Cron ain't working I purchased this mod from here 

Link to post
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...