<?
#########################################
# Скрипт онлайн игры "Стритрейсинг"_____#
# Автор: -=FеST=-(СиК)__________________#
# ICQ : 345-22-23_______________________#
# Все права принадлежат автору(-=FeST=-)#
#########################################
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/adm_check.php';
include_once '../sys/inc/user.php';
$set['title']='Стритрейсинг';
include_once '../sys/inc/thead.php';
title();
err();
aut();

if(!isset($user)){
echo 'Вы неавторизованы';
include_once '../sys/inc/tfoot.php';
exit;
}
function sictime($timediff){

$oneMinute=60;
$oneHour=60*60;
$oneDay=60*60*24;
$dayfield=floor($timediff/$oneDay);
$hourfield=floor(($timediff-$dayfield*$oneDay)/$oneHour);
$minutefield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour)/$oneMinute);
$secondfield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour-$minutefield*$oneMinute));
$time_1="$hourfield ч. $minutefield м. $secondfield c";
return $time_1;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `racing` WHERE `id_u`='".$user['id']."'"),0)==0)
mysql_query("INSERT INTO `racing`(`id_u`) VALUES('".$user['id']."')");
  $arr=mysql_fetch_array(mysql_query("SELECT * FROM `racing` WHERE `id_u`='".$user['id']."'"));
   $car=mysql_fetch_array(mysql_query("SELECT * FROM `racing_car` WHERE `id`='".$arr['car']."'"));
   if($arr['color']!='0'){
if($arr['color']==1)
$color='red_';
elseif($arr['color']==2)
$color='blue_';
elseif($arr['color']==3)
$color='green_'; 
}
echo "
<div class='aut'>
<img src='ico/exp.gif' alt=''/>".$arr['exp']."
<img src='ico/level.gif' alt=''/>".$arr['level']."
<img src='ico/money.gif' alt=''/>".$arr['money']."
<img src='ico/resp.gif' alt=''/>".$arr['resp']."</div>

<center><img src='car/".$color."".$car['screen']."' alt=''/> <br/>".$car['name']."</center>
";
if($arr['race_kol']>5){
$newtime=time()+60*60*12;
mysql_query("UPDATE `racing` SET `race_kol`='0', `race_last`='".$newtime."' WHERE `id_u`='".$user['id']."'");
msg('Вы устали и не сможете гонятся ближайшие 12 часов');
}
if(isset($_GET['a'])){
if($arr['race_last']<time()){
if(isset($_GET['b'])){
$rand=rand(1,2);
if($rand==1){
mysql_query("UPDATE `racing` SET `race_kol`=`race_kol`+1, `win`=`win`+1, `exp`=`exp`+3, `money`=`money`+500, `resp`=`resp`+200, `samoobl`=`samoobl`+250, `reak`=`reak`+310 WHERE `id_u`='".$user['id']."'");
msg('Поздравляем! Вы выиграли гонку!');
}
else
{
mysql_query("UPDATE `racing` SET `race_kol`=`race_kol`+1, `lose`=`lose`+1 WHERE `id_u`='".$user['id']."'");
msg('К сожалению вы проиграли');

}
}}
else
{
msg("Вы устали и не сможете гонятся ближайшие ".sictime($arr['race_last']-time())."");
$t=1;
}


   $cars=mysql_fetch_array(mysql_query("SELECT * FROM `racing_car` WHERE `class`='".$car['class']."' ORDER BY RAND() DESC LIMIT 1"));
if($t!=1){
echo "<br/>Случайный гонщик :<br/>
<img src='car/".$cars['screen']."' alt=''/> <br/>".$cars['name']."<br/>
-> <a href='bot_race.php?a&amp;b'>Вызвать на гонку</a>";}
}
echo "<br/>
- <a href='bot_race.php?a'>Искать гонщиков</a><br/>";
echo "<div class='aut'><a style='display:block;' href='index.php'><img src='ico/back.png' alt=''/> Назад</a></div>";






include_once '../sys/inc/tfoot.php';
?>