Файл: vkolhoze.com/sadovnik_cron.php
Строк: 286
<?php
$t=microtime(1);
$time=time();
require_once'inc/start_sess.php';
$user_select=mysql_query("SELECT `id` FROM `kolhoz_user` WHERE `garden_time` > '$time' ");
WHILE($ku=mysql_fetch_array($user_select)){
$ku=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$ku[id]'"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`id_plant` = '0' OR `time_water` = '$time' OR `time` = '$time' OR `time_water` < '$time' OR `time` < '$time' OR (`time_soil` = '$time' AND `soil` = '0') OR (`time_soil` < '$time' AND `soil` = '0'))"),0)>0
){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"),0)!=0)
{
$mcu=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"));
$mc=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective` WHERE `id` = '$mcu[id_collective]'"));
$mc['users']=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_user` WHERE `id_collective` = '$mc[id]'"),0);
}
require_once'inc/functions.php';
//require_once'/home/httpd/vhosts/vkolhoze.com/httpdocs/inc/start.php';
include'inc/tehnika.php';
if($ku['expdouble']==date("D"))$dexp=1;
$gos=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_gos` WHERE `active` = '1' ORDER BY `time` DESC LIMIT 1"));
if($ku['gardener']==1)$water=1;$name='Молчан';$harvest=0;$cultivate=0;$seat=0;$soil=0;
if($ku['gardener']==2){$water=1;$name='Казимир';
$harvest=1;
$cultivate=1;
$seat=1;
$soil=0;}
if($ku['gardener']==3){$water=1;$name='Ярило';
$harvest=1;
$cultivate=1;
$seat=1;
$soil=1;
$vert=1;
}
if($water==1 AND mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` != '0' AND (`time_water` = '$time' OR `time_water` < '$time') AND `time` > '$time' AND (`soil` = '0' AND `time_soil` > '$time' OR `soil` = '1')LIMIT 1"),0)!=0){
$nt=1800;
$rat=ir($ku['level']);
$rat_hp_act=0; //гидра
$rat_hp_pit=0; // MsPit //+
$rat_mc_hp_act=0; //ороситель
$rat_sc_act=0; //пугало
$rat_dog_act=0;
$house_act=0;
$rat_drakon_act=0; //дракон
$rat_irregate_act=0; //оПроситель
$rat_school_act=0; //школа
$rat_lib_act=0;
$arena_rat=0; //арена
if(isset($hp_act))$rat_hp_act=(($rat/100)*$hp_ps);
if(isset($mc_hp_act))$rat_mc_hp_act=(($rat/100)*$mc_hp_ps);
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($dog_type))$rat_dog_act=(($rat/100)*$dog_type);
if(isset($irregate_act))$rat_irregate_act=(($rat/100)*$irregate_act);
if($ms['level']>1)$rat_hp_pit=floor(($rat/100)*($ms['level']*2.5));
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
if(isset($shmel_act))$rat_irregate_act=$rat_irregate_act*2;
if(isset($shmel_act))$rat_hp_act=$rat_hp_act*2;
if(isset($house_act))$rat=$rat+(($rat/100)*($ku['house']*10));
if($ku['arena_rating']>1000)$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/20));
$ratt=$rat+$rat_hp_act+$rat_sc_act+$rat_drakon_act+$rat_irregate_act+$rat_mc_hp_act+$rat_school_act+$rat_lib_act+$rat_dog_act+$arena_rat+$rat_hp_pit+$house_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp) AND !isset($dexp3))$rat=$rat*2; elseif(isset($dexp3))$rat=$rat*3;
$ntt=15*60;
$ntt_hp_act=0;
$ntt_mc_hp_act=0;
if(isset($hp_act))$ntt_hp_act=(($ntt/100)*$hp_ps);
if(isset($mc_hp_act))$ntt_mc_hp_act=(($ntt/100)*$mc_hp_ps);
$ntt=$ntt_hp_act+$ntt_mc_hp_act;
if(isset($irregate_act))
{
$nt=$nt-(round($irregate_act_mnp*60));
$ntt=$ntt+($irregate_act_m*60);
}
$orat=0;
$q=mysql_query("SELECT * FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` != '0' AND (`time_water` = '".time()."' OR `time_water` < '".time()."') AND `time` > '".time()."' AND (`soil` = '0' AND `time_soil` > '".time()."' OR `soil` = '1')");
$vc=0;
while($post=mysql_fetch_array($q))
{
$vc=$vc+1;
mysql_query("UPDATE `kolhoz_ground` SET `time_water` = '".(time()+$nt)."', `time` = '".($post['time']-$ntt)."' WHERE `id` = '$post[id]' LIMIT 1");
$orat=$rat+$orat;
}
$ku['rating']=$ku['rating']+$orat;
mysql_query("UPDATE `kolhoz_user` SET `rating` = '$ku[rating]' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `day_rating` = '".($ku['day_rating']+$orat)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `vodoley` = '".($ku['vodoley']+$vc)."' WHERE `id` = '$ku[id]'");
update_mc($orat);
}
if($soil==1 AND mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `soil` = '0' AND (`time_soil` = '$time' OR `time_soil` < '$time') AND `id_plant` != '0' AND `time` > '$time' LIMIT 1"),0)!=0){
if($ku['last_soil']!=0)
{
$soil=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_soil` WHERE `id` = '$ku[last_soil]'"));
$cg=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `soil` = '0' AND (`time_soil` = '$time' OR `time_soil` < '$time') AND `id_plant` != '0' AND `time` > '$time'"),0);
$sc=$cg*$soil['cena'];
if($ku['money']>=$sc)
{
$rat=$soil['rating'];
$rat_sc_act=0;
$rat_dog_act=0;
$rat_hp_act=0;
$rat_mc_hp_act=0;
$rat_drakon_act=0;
$rat_soiler_act=0;
$rat_school_act=0;
$house_act=0;
$rat_lib_act=0;
$arena_rat=0;
if(isset($hp_act))$rat_hp_act=(($rat/100)*$hp_ps);
if(isset($mc_hp_act))$rat_mc_hp_act=(($rat/100)*$mc_hp_ps);
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($dog_type))$rat_dog_act=(($rat/100)*$dog_type);
if(isset($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($soiler_act))$rat_soiler_act=(($rat/100)*$soiler_act);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
if(isset($shmel_act))$rat_soiler_act=$rat_soiler_act*2;
if(isset($shmel_act))$rat_hp_act=$rat_hp_act*2;
if($ku['arena_rating']>1000){$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/20));}
if(isset($house_act))$rat=$rat+(($rat/100)*($ku['house']*10));
$ratt=$rat_mc_hp_act+$rat_sc_act+$rat_hp_act+$rat_drakon_act+$rat_soiler_act+$rat_school_act+$rat_lib_act+$rat_dog_act+$arena_rat+$house_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp) AND !isset($dexp3))$rat=$rat*2; elseif(isset($dexp3))$rat=$rat*3;
$st=$soil['time'];
$st_hp_act=0;
$st_mc_hp_act=0;
$st_soiler_act=0;
if(isset($hp_act))$st_hp_act=($st/100)*$hp_ps;
if(isset($mc_hp_act))$st_mc_hp_act=($st/100)*$mc_hp_ps;
if($soiler_act)$st_soiler_act=($st/100)*$soiler_act;
$st=$st_hp_act+$st_soiler_act+$st+$st_mc_hp_act;
$q=mysql_query("SELECT * FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `soil` = '0' AND (`time_soil` = '$time' OR `time_soil` < '$time') AND `id_plant` != '0' AND `time` > '$time'");
$orat=0;
$vc=0;
while($post=mysql_fetch_array($q))
{
$orat=$orat+$rat;
mysql_query("UPDATE `kolhoz_ground` SET `time` = '".($post['time']-$st)."', `soil` = '1' WHERE `id` = '$post[id]' LIMIT 1");
$vc=$vc+1;
}
$ku['rating'] = $ku['rating']+$orat;
mysql_query("UPDATE `kolhoz_user` SET `day_rating` = '".($ku['day_rating']+$orat)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `agronom` = '".($ku['agronom']+$vc)."',`money` = '".($ku['money']-$sc)."',`rating` = '$ku[rating]' WHERE `id` = '$ku[id]'");
update_mc($orat);
}
}
}
if($harvest==1 AND mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0' LIMIT 1"),0)!=0){
$q=mysql_query("SELECT * FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0'");
$ohv=0;
$expa=0;
while($post=mysql_fetch_array($q))
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"));
if($plant['id']==$gos['id_plant'] && $mc)
{
$harv=(isset($harvester_act)?$harvester_act/100:0);
$hawk=(isset($yastreb_act)?3:0);
$exp=$plant['time_soil']+($plant['time_soil']*$harv)+($plant['time_soil']*$hawk);
if($gos['type']=='harvest')$exp=$exp*2;
$expa=$expa+$exp;
}
$count=$plant['count'];
$count_harvester_act=0;
$count_yastreb_act=0;
$count_greenhouse_act=0;
if(isset($harvester_act))$count_harvester_act=floor(($count/100)*$harvester_act);
if(isset($yastreb_act))$count_yastreb_act=(($count/100)*300);
if(isset($greenhouse_act))$count_greenhouse_act=(($count/100)*$greenhouse_ps);
$count=$count_harvester_act+$count_yastreb_act+$count+$count_greenhouse_act;
$count=floor($count);
if($ku['last_zadanie']==$plant['id'])mysql_query("UPDATE `kolhoz_user` SET `zad_count` = '".($ku['zad_count']+$count)."' WHERE `id` = '$ku[id]'");
$a = mt_rand(0,500);
if($a == 5){
$b = mt_rand(0,6);
if($b == 1 or $b == 3){
$text="Вы нашли ключ";
$lol=$time+60*60*24*3;
mysql_query("INSERT INTO `kolhoz_box` SET `id_user` = '$ku[id]', `key` = '1', `time` = '$lol' ");
mysql_query("INSERT INTO `kolhoz_mail` SET `id_user` = '$ku[id]', `id_kont` = '0', `msg` = '$text', `time` = '".time()."', `type` = 'to'");
echo 'Ключ';
}else{
$text="Вы нашли сундук";
$lol=$time+60*60*24*3;
mysql_query("INSERT INTO `kolhoz_box` SET `id_user` = '$ku[id]', `time` = '$lol' ");
mysql_query("INSERT INTO `kolhoz_mail` SET `id_user` = '$ku[id]', `id_kont` = '0', `msg` = '$text', `time` = '".time()."', `type` = 'to'");
echo 'Сундук';
}
}
if($pw=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id_plant` = '$plant[id]' AND `arena` = '0'")))
{
mysql_query("UPDATE `kolhoz_warehouse` SET `count` = '".($pw['count']+$count)."' WHERE `id` = '$pw[id]'");
}
else mysql_query("INSERT INTO `kolhoz_warehouse` SET `id_plant` = '$plant[id]', `id_user` = '$ku[id]', `count` = '$count', `arena` = '0'");
$ohv=$ohv+$count;
}
if($expa>0){
mysql_query("UPDATE `kolhoz_collective` SET `rating_gos` = '$mc[rating_gos]'+'$expa' WHERE `id`='$mc[id]'");
mysql_query("UPDATE `kolhoz_collective_user` SET `rating_gos` = '$mcu[rating_gos]'+'$expa' WHERE `id_user`='$ku[id]'");
}
mysql_query("UPDATE `kolhoz_ground` SET `id_plant` = '0', `soil` = '0', `cultivator` = '0' WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0'");
mysql_query("INSERT INTO `kolhoz_joirnal` SET `gardener` = '$ku[gardener]', `id_user` = '$ku[id]', `time` = '$time', `count` = '$ohv'");
mysql_query("UPDATE `kolhoz_user` SET `sadovod` = '".($ku['sadovod']+$ohv)."' WHERE `id` = '$ku[id]'");
$ohv = 0;
}
if($cultivate==1 AND mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND (`time` = '$time' OR `time` < '$time') AND `cultivator` = '0' LIMIT 1"),0)!=0){
$level = $ku['level'];
if($level>=0 && $level<=10)$rat = 2;
else if($level>=11 && $level<=20)$rat = 5;
else if($level>=21 && $level<=30)$rat = 15;
else if($level>=31 && $level<=40)$rat = 40;
else if($level>=41 && $level<=50)$rat = 100;
else if($level>=51 && $level<=60)$rat = 500;
else if($level>=61)$rat = 1000;
unset($level);
$rat_drakon_act=0;
$rat_sc_act=0;
$rat_dog_act=0;
$rat_lib_act=0;
if(!isset($cultivator_act))$cultivator_act=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($dog_type))$rat_dog_act=(($rat/100)*$dog_type);
$rat_cultivator_act=(($rat/100)*$cultivator_act);
if(isset($drakon_act))$rat_drakon_act=((2/100)*300);
if(isset($lib_act))$rat_lib_act=$rat/2;
if(isset($shmel_act))$rat_cultivator_act=$rat_cultivator_act*2;
$ratt=$rat_drakon_act+$rat_sc_act+$rat_cultivator_act+$rat_lib_act+$rat_dog_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp) AND !isset($dexp3))$rat=$rat*2; elseif(isset($dexp3))$rat=$rat*3;
$orat=0;
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND (`time` = '$time' OR `time` < '$time') AND `cultivator` = '0'"),0);
$orat=$rat*$q;
$ku['rating'] = $ku['rating']+$orat;
mysql_query("UPDATE `kolhoz_user` SET `day_rating` = '".($ku['day_rating']+$orat)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '$ku[rating]' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_ground` SET `cultivator` = '1' WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND (`time` = '$time' OR `time` < '$time') AND `cultivator` = '0'");
update_mc($orat);
}
if($seat==1 AND mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1' LIMIT 1"),0)!=0 AND $ku['last_plant']!=0){
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"));
$cg=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'"),0);
$mon=($plant['cena']/100)*$seeder_act_skid;
$money=floor($plant['cena']-$mon);
$sc=$money*$cg;
$rat=$plant['rating'];
$rat_sc_act=0;
$rat_dog_act=0;
$house_act=0;
$rat_drakon_act=0;
$rat_seeder_act=0;
$rat_cultivator_seat_soil=0;
$rat_school_act=0;
$arena_rat=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($dog_type))$rat_dog_act=(($rat/100)*$dog_type);
if(isset($drakon_act))$rat_drakon_act=(($plant['rating']/100)*300);
if(isset($seeder_act))$rat_seeder_act=(($rat/100)*$seeder_act);
if(isset($house_act))$rat=$rat+(($rat/100)*($ku['house']*10));
if(isset($school_act))$rat_school_act=$rat/2;
if(isset($shmel_act))$rat_seeder_act=$rat_seeder_act*2;
if(isset($cultivator_seat_soil))$rat_cultivator_seat_soil=(($rat/100)*$cultivator_seat_soil);
if($ku['arena_rating']>1000){$arena_rat=floor(($rat/100)*(($ku['arena_rating']-1000)/20));}
$ratt=$rat+$rat_drakon_act+$rat_sc_act+$rat_seeder_act+$rat_school_act+$rat_cultivator_seat_soil+$rat_dog_act+$arena_rat+$house_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp) AND !isset($dexp3))$rat=$rat*2; elseif(isset($dexp3))$rat=$rat*3;
if($gos['id_plant']==$plant['id'] && $gos['type']=='rating' && isset($mc))$rat=$rat*2;
if($ku['money']>=$sc)
{
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'"),0);
$orat=$rat*$q;
mysql_query("UPDATE `kolhoz_ground` SET `id_plant` = '$plant[id]', `time_soil` = '".(time()+$plant['time_soil'])."', `time_water` = '".(time()+120)."', `soil` = '0', `time` = '".($plant['time']+time())."' WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'");
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$sc)."',`rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
update_mc($orat);
}
}
if(isset($mc))
{
/////////////////////////////////////////////////////ВЕРТЫ////////////////////
if($vert==2){
$smelhel=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '1' AND `gaz` >= '10'"));
$arendsmel=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '1'"));
if($smelhel['id'] AND (!$arendsmel || $arendsmel['time']<$time) AND $ku['time_shmel']<$time)
{//Вызов шмеля
$heli=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` != '0' AND `id` = '$smelhel[id]'"));
$type=7;$gaz=10;
$arend=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '1'"));
$count_tt=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '1'"),0);
$tl=round($mc['users']/($type*$count_tt),2);
$t2=0;
if($tl2=explode('.',$tl))
{
if(!isset($tl2[1]))$tl2[1]='0';
if(strlen2($tl2[1])<2)$tl2[1]=$tl2[1]."0";
$t1=$tl2[0];
$tl2=$tl2[1];
$dil=100/60;
$t2=floor($tl2/$dil);
}
$nt=$time+($t1*3600)+($t2*60);
if(!$arend)mysql_query("INSERT INTO `kolhoz_collective_ahlist` SET `id_user` = '$ku[id]', `heli` = '1', `time` = '$nt'");
else mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '$nt' WHERE `id` = '$arend[id]'");
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku["time_shmel"]>$time?"".($ku["time_shmel"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli['gaz']-$gaz)."' WHERE `id` = '$heli[id]'");
}
$smelhel=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '2' AND `gaz` >= '10'"));
$arendsmel=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '2'"));
if($smelhel['id'] AND (!$arendsmel || $arendsmel['time']<$time) AND $ku['time_yastreb']<$time)
{//Вызов ястреба
$heli=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` != '0' AND `id` = '$smelhel[id]'"));
$type=7;$gaz=10;
$arend=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '2'"));
$count_tt=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '2'"),0);
$tl=round($mc['users']/($type*$count_tt),2);
$t2=0;
if($tl2=explode('.',$tl))
{
if(!isset($tl2[1]))$tl2[1]='0';
if(strlen2($tl2[1])<2)$tl2[1]=$tl2[1]."0";
$t1=$tl2[0];
$tl2=$tl2[1];
$dil=100/60;
$t2=floor($tl2/$dil);
}
$nt=$time+($t1*3600)+($t2*60);
if(!$arend)mysql_query("INSERT INTO `kolhoz_collective_ahlist` SET `id_user` = '$ku[id]', `heli` = '2', `time` = '$nt'");
else mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '$nt' WHERE `id` = '$arend[id]'");
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_yastreb` = '".($ku["time_yastreb"]>$time?"".($ku["time_yastreb"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli['gaz']-$gaz)."' WHERE `id` = '$heli[id]'");
}
$smelhel=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '3' AND `gaz` >= '10'"));
$arendsmel=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '3'"));
if($smelhel['id'] AND (!$arendsmel || $arendsmel['time']<$time) AND $ku['time_drakon']<$time)
{//Вызов дракона
$heli=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` != '0' AND `id` = '$smelhel[id]'"));
$type=7;$gaz=10;
$arend=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '3'"));
$count_tt=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '3'"),0);
$tl=round($mc['users']/($type*$count_tt),2);
$t2=0;
if($tl2=explode('.',$tl))
{
if(!isset($tl2[1]))$tl2[1]='0';
if(strlen2($tl2[1])<2)$tl2[1]=$tl2[1]."0";
$t1=$tl2[0];
$tl2=$tl2[1];
$dil=100/60;
$t2=floor($tl2/$dil);
}
$nt=$time+($t1*3600)+($t2*60);
if(!$arend)mysql_query("INSERT INTO `kolhoz_collective_ahlist` SET `id_user` = '$ku[id]', `heli` = '3', `time` = '$nt'");
else mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '$nt' WHERE `id` = '$arend[id]'");
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_drakon` = '".($ku["time_drakon"]>$time?"".($ku["time_drakon"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli['gaz']-$gaz)."' WHERE `id` = '$heli[id]'");
}
$smelhel=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '4' AND `gaz` >= '25'"));
$arendsmel=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '4'"));
if($smelhel['id'] AND (!$arendsmel || $arendsmel['time']<$time) AND ($ku['time_shmel']<$time OR $ku['time_yastreb']<$time OR $ku['time_drakon']<$time))
{//Вызов грома
$heli=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` != '0' AND `id` = '$smelhel[id]'"));
$type=9;$gaz=25;
$arend=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '$ku[id]' AND `heli` = '4'"));
$count_tt=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '4'"),0);
$tl=round($mc['users']/($type*$count_tt),2);
$t2=0;
if($tl2=explode('.',$tl))
{
if(!isset($tl2[1]))$tl2[1]='0';
if(strlen2($tl2[1])<2)$tl2[1]=$tl2[1]."0";
$t1=$tl2[0];
$tl2=$tl2[1];
$dil=100/60;
$t2=floor($tl2/$dil);
}
$nt=$time+($t1*3600)+($t2*60);
if(!$arend)mysql_query("INSERT INTO `kolhoz_collective_ahlist` SET `id_user` = '$ku[id]', `heli` = '4', `time` = '$nt'");
else mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '$nt' WHERE `id` = '$arend[id]'");
$timee=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku["time_shmel"]>$time?"".($ku["time_shmel"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `time_yastreb` = '".($ku["time_yastreb"]>$time?"".($ku["time_yastreb"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `time_drakon` = '".($ku["time_drakon"]>$time?"".($ku["time_drakon"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli['gaz']-$gaz)."' WHERE `id` = '$heli[id]'");
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
}
echo '<br/> '.number_format(microtime(1)-$t,3).' сек.';
?>