Файл: cron/yarilo.php
Строк: 270
<?php
define('ROOTPATH', realpath(dirname(__FILE__)));
include_once __DIR__.'/connect.php';
include(dirname(__DIR__).'/inc/system/functions.php');
$time=time();
$x=mysql_query("SELECT * FROM `kolhoz_user` WHERE `garden_yarilo_time` > '".$time."' ");
while($ku=mysql_fetch_array($x))
{
$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);
include(dirname(__DIR__).'/inc/system/tehnika.php');
$heli_s_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '1'"),0);
$heli_y_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '2'"),0);
$heli_d_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '3'"),0);
$heli_g_ct=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '4'"),0);
$arend_s=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '1'"));
$arend_y=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '2'"));
$arend_d=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '3'"));
$arend_g=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_ahlist` WHERE `id_user` = '".$ku['id']."' AND `heli` = '4'"));
if
(
(
(($ku["time_shmel"]<($time+7200)) && $heli_s_ct != '0' && $arend_s['time']<$time)
||
(($ku["time_yastreb"]<($time+7200)) && $heli_y_ct != '0' && $arend_y['time']<$time)
||
(($ku["time_drakon"]<($time+7200)) && $heli_d_ct != '0' && $arend_d['time']<$time)
||
(
(
($heli_s_ct=='0' || $arend_s['time'] > $time)
&&
($heli_y_ct=='0' || $arend_y['time'] > $time)
&&
($heli_d_ct=='0' || $arend_d['time'] > $time)
)
&&
(
(
$ku["time_shmel"]<($time+7200)
||
$ku["time_yastreb"]<($time+7200)
||
$ku["time_drakon"]<($time+7200)
)
&&
$heli_g_ct != '0' && $arend_g['time']<$time
)
)
)
)
{
if(($ku["time_shmel"]<($time+7200)) && $heli_s_ct != '0' && $arend_s['time']<$time)
{
$type1=7;
$count_tt1=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '1'"),0);
$tl1=round($mc['users']/($type1*$count_tt1),2);
$t21=0;
if($tl21=explode('.',$tl1))
{
if(strlen2($tl21[1])<2)$tl21[1]=$tl21[1]."0";
$t11=$tl21[0];
$tl21=$tl21[1];
$dil1=100/60;
$t21=floor($tl21/$dil1);
}
$nt1=$time+($t11*3600)+($t21*60);
mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '".$nt1."' WHERE `id` = '".$arend_s['id']."'");
$timee1=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku["time_shmel"]>$time?"".($ku["time_shmel"]+$timee1)."":"".($time+$timee1)."")."' WHERE `id` = '".$ku['id']."'");
$heli1=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '1' AND `gaz` > '10'"));
$gaz1=10;
if(!$heli1)
{
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli1['gaz']-$gaz1)."' WHERE `id_collective` = '".$mc['id']."' AND `heli` = '1' LIMIT 1");
}
}
if(($ku["time_yastreb"]<($time+7200)) && $heli_y_ct != '0' && $arend_y['time']<$time)
{
$type2=7;
$count_tt2=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '2'"),0);
$tl2=round($mc['users']/($type2*$count_tt2),2);
$t22=0;
if($tl22=explode('.',$tl2))
{
if(strlen2($tl22[1])<2)$tl22[1]=$tl22[1]."0";
$t12=$tl22[0];
$tl22=$tl22[1];
$dil2=100/60;
$t22=floor($tl22/$dil2);
}
$nt2=$time+($t12*3600)+($t22*60);
mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '".$nt2."' WHERE `id` = '".$arend_y['id']."'");
$timee2=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_yastreb` = '".($ku["time_yastreb"]>$time?"".($ku["time_yastreb"]+$timee2)."":"".($time+$timee2)."")."' WHERE `id` = '".$ku['id']."'");
$heli2=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '2' AND `gaz` > '10'"));
$gaz2=10;
if(!$heli2)
{
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli2['gaz']-$gaz2)."' WHERE `id_collective` = '".$mc['id']."' AND `heli` = '2' LIMIT 1");
}
}
if(($ku["time_drakon"]<($time+7200)) && $heli_d_ct != '0' && $arend_d['time']<$time)
{
$type3=7;
$count_tt3=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '3'"),0);
$tl3=round($mc['users']/($type3*$count_tt3),2);
$t23=0;
if($tl23=explode('.',$tl3))
{
if(strlen2($tl23[1])<2)$tl23[1]=$tl23[1]."0";
$t13=$tl23[0];
$tl23=$tl23[1];
$dil3=100/60;
$t23=floor($tl23/$dil3);
}
$nt3=$time+($t13*3600)+($t23*60);
mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '".$nt3."' WHERE `id` = '".$arend_d['id']."'");
$timee3=3600;
mysql_query("UPDATE `kolhoz_user` SET `time_drakon` = '".($ku["time_drakon"]>$time?"".($ku["time_drakon"]+$timee3)."":"".($time+$timee3)."")."' WHERE `id` = '".$ku['id']."'");
$heli3=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '".$mc['id']."' AND `heli` = '3' AND `gaz` > '10'"));
$gaz3=10;
if(!$heli3)
{
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli3['gaz']-$gaz3)."' WHERE `id_collective` = '".$mc['id']."' AND `heli` = '3' LIMIT 1");
}
}
if
(
(
($heli_s_ct=='0' || $arend_s['time'] > $time)
&&
($heli_y_ct=='0' || $arend_y['time'] > $time)
&&
($heli_d_ct=='0' || $arend_d['time'] > $time)
)
&&
(
(
$ku["time_shmel"]<($time+7200)
||
$ku["time_yastreb"]<($time+7200)
||
$ku["time_drakon"]<($time+7200)
)
&&
$heli_g_ct != '0' && $arend_g['time']<$time
)
)
{
$type4=7;
$count_tt4=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '4'"),0);
$tl4=round($mc['users']/($type4*$count_tt4),2);
$t24=0;
if($tl24=explode('.',$tl4))
{
if(strlen2($tl24[1])<2)$tl24[1]=$tl24[1]."0";
$t14=$tl24[0];
$tl24=$tl24[1];
$dil4=100/60;
$t24=floor($tl24/$dil4);
}
$nt4=$time+($t14*3600)+($t24*60);
mysql_query("UPDATE `kolhoz_collective_ahlist` SET `time` = '$nt4' WHERE `id` = '$arend_g[id]'");
$timee4=3601;
if($ku["time_shmel"]<($time+7200))
{
mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku["time_shmel"]>$time?"".($ku["time_shmel"]+$timee4)."":"".($time+$timee4)."")."' WHERE `id` = '$ku[id]'");
}
if($ku["time_yastreb"]<($time+7200))
{
mysql_query("UPDATE `kolhoz_user` SET `time_yastreb` = '".($ku["time_yastreb"]>$time?"".($ku["time_yastreb"]+$timee4)."":"".($time+$timee4)."")."' WHERE `id` = '$ku[id]'");
}
if($ku["time_drakon"]<($time+7200))
{
mysql_query("UPDATE `kolhoz_user` SET `time_drakon` = '".($ku["time_drakon"]>$time?"".($ku["time_drakon"]+$timee4)."":"".($time+$timee4)."")."' WHERE `id` = '$ku[id]'");
}
$heli4=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_collective` = '$mc[id]' AND `heli` = '4' AND `gaz` > '10'"));
$gaz4=10;
if(!$heli4)
{
mysql_query("UPDATE `kolhoz_collective_heli` SET `gaz` = '".($heli4['gaz']-$gaz4)."' WHERE `id_collective` = '$mc[id]' AND `heli` = '4' LIMIT 1");
}
}
}
//////////удобрить///////////
if(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)!=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);
if($soil['rub'])
{
$z="rubies";
}
else
{
$z="money";
}
$sc=$cg*$soil['cena'];
if($ku[$z]>=$sc)
{
$rat=$soil['rating'];
$rat_sc_act=0;
$rat_hp_act=0;
$rat_mc_hp_act=0;
$rat_drakon_act=0;
$rat_soiler_act=0;
$rat_school_act=0;
$rat_lib_act=0;
$rat_medal=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($drakon_act))$rat_drakon_act=(($rat/100)*300);
if(isset($soiler_act))$rat_soiler_act=(($rat/100)*(40+(20*$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($mc['MedalRating']>0)$rat_medal=(($rat/100)*($mc['MedalRating']*0.5));
$ratt=round($rat_mc_hp_act+$rat_sc_act+$rat_hp_act+$rat_drakon_act+$rat_soiler_act+$rat_school_act+$rat_lib_act+$rat_medal);
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
if(isset($exp3))$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(isset($soiler_act))$st_soiler_act=($st/100)*(40+(20*$soiler_act));
if(isset($mc_soiler_act))$st_soiler_act=($st/100)*((40+(20*$soiler_act))+(((40+(20*$soiler_act))/100)*$mc_soiler_ps));
$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;
}
mysql_query("UPDATE `kolhoz_user` SET `agronom` = '".($ku['agronom']+$vc)."' WHERE `id` = '$ku[id]'");
if($soil['rub'])
{
mysql_query("UPDATE `kolhoz_user` SET `rubies` = '".($ku['rubies']-$sc)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `info_user` SET `id_user` = '$ku[id]', `status` = '-', `many` = '$sс', `kuda` = 'покупка удобрения', `time` = '$time'");
}
else
{
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$sc)."' WHERE `id` = '$ku[id]'");
}
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
update_mc($orat);
}
}
}
////////полить///////
if(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')"),0)!=0)
{
$nt=1800;
$rat=10;
$rat_hp_act=0; //гидра
$rat_mc_hp_act=0; //ороситель
$rat_sc_act=0; //пугало
$rat_drakon_act=0; //дракон
$rat_irregate_act=0; //оПроситель
$rat_school_act=0; //школа
$rat_lib_act=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($irregate_act))$rat_irregate_act=($rat*(40+(20*$irregate_act)))/100 ;
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;
$ratt=round($rat_hp_act+$rat_sc_act+$rat_drakon_act+$rat_irregate_act+$rat_mc_hp_act+$rat_school_act+$rat_lib_act);
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
if(isset($exp3))$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=round($nt-(29*(1-(pow(0.8,$irregate_act))))*60);
$ntt=$ntt+(4+(2*$irregate_act))*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)-1800)."' WHERE `id` = '$post[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
$orat=$rat+$orat;
}
mysql_query("UPDATE `kolhoz_user` SET `vodoley` = '".($ku['vodoley']+$vc)."' WHERE `id` = '$ku[id]'");
update_mc($orat);
}
/////////собрать//////////
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND (`time` < '$time' OR `time` = '$time') AND `id_plant` != '0'"),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;
while($post=mysql_fetch_array($q))
{
$gos=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_gos` WHERE `active` = '1' ORDER BY `time` DESC LIMIT 1"));
$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;
mysql_query("INSERT INTO `kolhoz_collective_rating_gos` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$exp', `time` = '$time'");
}
$count=$plant['count'];
$count_harvester_act=0;
$count_yastreb_act=0;
$count_greenhouse_act=0;
if(isset($harvester_act))$count_harvester_act=($count*(40+(20*$harvester_act)))/100;
if(isset($yastreb_act))$count_yastreb_act=(($count/100)*300);
if(isset($greenhouse_act))$count_greenhouse_act=(($count/100)*$greenhouse_ps);
if(isset($expcount))$count=$count*2;
$count=$count_harvester_act+$count_yastreb_act+$count+$count_greenhouse_act;
$count=round($count);
$assUser = mysql_fetch_array(mysql_query("SELECT * FROM `assignments_user` WHERE `id_user` = '$ku[id]'"));
$ass = mysql_fetch_array(mysql_query("SELECT * FROM `assignments` WHERE `id` = '$assUser[assignment]'"));
if($plant['id']==$ass['plant1'] && $assUser['assignment']>0)
{
mysql_query("UPDATE `assignments_user` SET `plant1` = '".($assUser['plant1']+$count)."' WHERE `id_user` = '$ku[id]'");
}
if($plant['id']==$ass['plant2'] && $assUser['assignment']>0)
{
mysql_query("UPDATE `assignments_user` SET `plant2` = '".($assUser['plant2']+$count)."' WHERE `id_user` = '$ku[id]'");
}
if($plant['id']==$ass['plant3'] && $assUser['assignment']>0)
{
mysql_query("UPDATE `assignments_user` SET `plant3` = '".($assUser['plant3']+$count)."' WHERE `id_user` = '$ku[id]'");
}
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'");
mysql_query("UPDATE `kolhoz_ground` SET `id_plant` = '0', `soil` = '0', `cultivator` = '0' WHERE `id` = '$post[id]' LIMIT 1");
$ohv=$ohv+$count;
}
mysql_query("UPDATE `kolhoz_user` SET `sadovod` = '".($ku['sadovod']+$ohv)."' WHERE `id` = '$ku[id]'");
}
/////вскопать//////
if(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)!=0)
{
$rat=$ku['level'];
$rat_drakon_act=0;
$rat_sc_act=0;
$rat_cultivator_act=0;
$rat_school_act=0;
$rat_lib_act=0;
$rat_medal=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($cultivator_act))$rat_cultivator_act=($rat*(80+(40*$cultivator_act)))/100;
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_cultivator_act=$rat_cultivator_act*2;
if($mc['MedalRating']>0)$rat_medal=(($rat/100)*($mc['MedalRating']*0.5));
$ratt=floor($rat_drakon_act+$rat_sc_act+$rat_cultivator_act+$rat_school_act+$rat_lib_act+$rat_medal);
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
if(isset($exp3))$rat=$rat*3;
$orat=0;
$q=mysql_query("SELECT * FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND (`time` = '$time' OR `time` < '$time') AND `cultivator` = '0'");
while($post=mysql_fetch_array($q))
{
mysql_query("UPDATE `kolhoz_ground` SET `cultivator` = '1' WHERE `id` = '$post[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$rat)."' WHERE `id` = '$ku[id]'");
$orat=$rat+$orat;
}
update_mc($orat);
}
/////////посадить////////////////
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'"),0)!=0)
{
if($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'"),0);
$mon=($plant['cena']/100)*$seeder_act_skid;
$money=floor($plant['cena']-$mon);
$sc=$money*$cg;
$rat=$plant['rating'];
$rat_sc_act=0;
$rat_drakon_act=0;
$rat_seeder_act=0;
$rat_cultivator_act=0;
$rat_school_act=0;
$rat_lib_act=0;
$rat_medal=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($drakon_act))$rat_drakon_act=($rat/100)*300;
if(isset($seeder_act))$rat_seeder_act=($rat*(40+(20*$seeder_act)))/100;
if(isset($cultivator_act))$rat_cultivator_act=5*(4+(2*$cultivator_act));
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat/2;
if(isset($shmel_act))$rat_seeder_act=$rat_seeder_act*2;
if($mc['MedalRating']>0)$rat_medal=(($rat/100)*($mc['MedalRating']*0.5));
$ratt=floor($rat_drakon_act+$rat_sc_act+$rat_cultivator_act+$rat_seeder_act+$rat_school_act+$rat_lib_act+$rat_medal);
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
if(isset($exp3))$rat=$rat*3;
if($gos['id_plant']==$plant['id'] && $gos['type']=='rating' && isset($mc))$rat=$rat*2;
if($ku['money']>=$sc)
{
$q=mysql_query("SELECT * FROM `kolhoz_ground` WHERE `id_user` = '$ku[id]' AND `id_plant` = '0' AND `cultivator` = '1'");
$orat=0;
while($post=mysql_fetch_array($q))
{
$orat=$rat+$orat;
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` = '$post[id]' LIMIT 1");
}
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']-$sc)."' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `rating` = '".($ku['rating']+$orat)."' WHERE `id` = '$ku[id]'");
update_mc($orat);
}
}
}
}
?>