Файл: gardener1.php
Строк: 216
<?php
ob_start();
date_default_timezone_set('Europe/Moscow');
$time=time();
include_once 'inc/system/start_sess.php';
$x=mysql_query("SELECT * FROM `kolhoz_user` WHERE `gardener` = '3' AND `gardener_time` > '$time'");
while($ku=mysql_fetch_array($x))
{
include_once 'inc/system/functions.php';
include_once 'inc/system/tehnika.php';
$harvest=1;
$cultivate=1;
$seat=1;
$soils=1;
/////Вызаф ведралоетаф////
$mcu =mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"));
$heli=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_user` = '$ku[id]' AND `id_collective` = '$mcu[id_collective]'"));
$gaz=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_user` = '$ku[id]' AND `id_collective` = '$mcu[id_collective]' AND `heli` = '4' AND `gaz` > '0' LIMIT 1"));
if($heli['heli']==4 && $gaz['gaz']>0)
{
$timee=3600;
$ogran = $time+3600*2;
if($ku['time_shmel']<$ogran)mysql_query("UPDATE `kolhoz_user` SET `time_shmel` = '".($ku["time_shmel"]>$time?"".($ku["time_shmel"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
if($ku['time_yastreb']<$ogran)mysql_query("UPDATE `kolhoz_user` SET `time_yastreb` = '".($ku["time_yastreb"]>$time?"".($ku["time_yastreb"]+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
if($ku['time_drakon']<$ogran)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` = `gaz` - '25' WHERE `id_user` = '$ku[id]' AND `heli` = '4' AND `id_collective` = '$mcu[id_collective]' AND `gaz` > '0' LIMIT 1");
}
$ogran = $time+3600*2;
$gaz1=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_user` = '$ku[id]' AND `id_collective` = '$mcu[id_collective]' AND `heli` = '1' AND `gaz` > '0' LIMIT 1"));
if($heli['heli']==1 && $ku['time_shmel']<$ogran && $gaz1['gaz']>0)
{
$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` = `gaz` - '10' WHERE `id_user` = '$ku[id]' AND `heli` = '1' AND `id_collective` = '$mcu[id_collective]' AND `gaz` > '0' LIMIT 1");
}
$ogran = $time+3600*2;
$gaz2=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_user` = '$ku[id]' AND `id_collective` = '$mcu[id_collective]' AND `heli` = '2' AND `gaz` > '0' LIMIT 1"));
if($heli['heli']==2 && $ku['time_yastreb']<$ogran && $gaz2['gaz']>0)
{
$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` = `gaz` - '10' WHERE `id_user` = '$ku[id]' AND `heli` = '2' AND `id_collective` = '$mcu[id_collective]' AND `gaz` > '0' LIMIT 1");
}
$ogran = $time+3600*2;
$gaz3=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_heli` WHERE `id_user` = '$ku[id]' AND `id_collective` = '$mcu[id_collective]' AND `heli` = '3' AND `gaz` > '0' LIMIT 1"));
if($heli['heli']==3 && $ku['time_dragon']<$ogran && $gaz3['gaz']>0)
{
$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` = `gaz` - '10' WHERE `id_user` = '$ku[id]' AND `heli` = '3' AND `id_collective` = '$mcu[id_collective]' AND `gaz` > '0' LIMIT 1");
}
/////вскопать//////
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=1;
$rat_drakon_act=0;
$rat_sc_act=0;
$rat_lib_act=0;
$rat_gardener_act=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
$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;
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"));
$rat_school_act=(($rat/100)*100);
if(isset($gardener_act))$rat_gardener_act=(($plant['rating']/100)*300);
if(isset($shmel_act))$rat_cultivator_act=$rat_cultivator_act*2;
$ratt=$rat_drakon_act+$rat_medal+$rat_sc_act+$rat_gardener_act+$rat_cultivator_act+$rat_school_act+$rat_lib_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
$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)
{
$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_gardener_act=0;
$rat_school_act=0;
if(isset($sc_act))$rat_sc_act=$rat*2;
if(isset($gardener_act))$rat_gardener_act=(($plant['rating']/100)*300);
if(isset($drakon_act))$rat_drakon_act=(($plant['rating']/100)*300);
if(isset($seeder_act))$rat_seeder_act=(($rat/100)*$seeder_act);
if(isset($school_act))$rat_school_act=$rat/2;
if(isset($shmel_act))$rat_seeder_act=$rat_seeder_act*2;
$ratt=$rat_drakon_act+$rat_medal+$rat_sc_act+$rat_seeder_act+$rat_school_act+$rat_gardener_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
if($gos['id_plant']==$plant['id'] && $gos['type']=='rating' && isset($mc))$rat=$rat*2;
if($ku['money']>=$sc)
{
$q1=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($q1))
{
$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);
}
}
////////полить///////
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=5;
$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;
$rat_gardener_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($gardener_act))$rat_gardener_act=(($plant['rating']/100)*300);
if(isset($irregate_act))$rat_irregate_act=(($rat/100)*$irregate_act);
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=$rat_hp_act+$rat_sc_act+$rat_gardener_act+$rat_drakon_act+$rat_medal+$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;
$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-($irregate_act_mnp*60);
$ntt=$ntt+($irregate_act_m*60);
}
$orat=0;
$q2=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($q2))
{
$vc=$vc+1;
mysql_query("UPDATE `kolhoz_ground` SET `time_water` = '".($time+$nt)."', `time` = '".($post['time']-$ntt)."' 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 `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;
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)*$soiler_act);
if(isset($school_act))$rat_school_act=$rat*2;
if(isset($lib_act))$rat_lib_act=$rat*2;
if($mc['MedalRating']>0)$rat_medal=(($rat/100)*($mc['MedalRating']*0.5));
if(isset($shmel_act))$rat_soiler_act=$rat_soiler_act*2;
if(isset($shmel_act))$rat_hp_act=$rat_hp_act*2;
$ratt=$rat_mc_hp_act+$rat_sc_act+$rat_hp_act+$rat_drakon_act+$rat_medal+$rat_soiler_act+$rat_school_act+$rat_lib_act;
if($ratt==0)$rat=$rat;
else $rat=$ratt;
if(isset($dexp))$rat=$rat*2;
$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)*$soiler_act;
$st=$st_hp_act+$st_soiler_act+$st+$st_mc_hp_act;
$q3=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($q3))
{
$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` = '".$sc."', `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]'");
$_SESSION['rating']=$orat;
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)
{
$q4=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($q4))
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$ku[last_plant]'"));
$gos=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_gos` WHERE `active` = '1' ORDER BY `time` DESC LIMIT 1"));
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;
}
{
$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;
$mcu =mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"));
mysql_query("INSERT INTO `kolhoz_collective_rating_gos` SET `id_user` = '$ku[id]', `id_collective` = '$mcu[id_collective]', `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=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($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_user` SET `sadovod` = '".($ku['sadovod']+$count)."' WHERE `id` = '$ku[id]'");
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]'");
mysql_query("INSERT INTO `kolhoz_journal` SET `works` = 'собрал урожай в амбар', `id_user` = '$ku[id]', `garden` = 'Ярило', `time` = '$time'");
}
}
?>