info['admin'] > 0 */ ) { $need_count = 0; $actions = array(); $resource = array(); $action = explode('|',$file[1]); foreach( $action as $value ) { $temp = explode(':',$value); $actions[$temp[0]]= $temp[1]; } if( isset($actions['resource']) ){ $action = explode( ',',$actions['resource'] ); foreach( $action as $value ) { $temp = explode( 'x', $value ); $resource[] = array( 'item' => (int)$temp[0], 'count' => (int)$temp[1] ); $need_count = $need_count+(int)$temp[1]; } } $actions['resource'] = $resource; unset($action, $temp, $value, $resource); # Обьекты для строительства if(isset($_GET['buildend'])) { //identid $obj = mysql_fetch_array(mysql_query('SELECT * FROM `dungeon_obj` WHERE `id` = "'.mysql_real_escape_string($actions['identid']).'" LIMIT 1')); $txt = ''; if( !isset($obj['id']) ) { $txt = 'Объект строительства был поврежден темной магией...'; }else{ if( $obj['x'] == $u->info['x'] && $obj['y'] == $u->info['y'] ) { $txt = 'Объект уже был построен ранее! Вернитесь на клетку назад для использования объекта!'; }else{ mysql_query('UPDATE `dungeon_obj` SET `x` = "'.$u->info['x'].'", `y` = "'.$u->info['y'].'" WHERE `id` = "'.$obj['id'].'" LIMIT 1'); mysql_query('UPDATE `dungeon_obj` SET `x` = "'.$u->info['x'].'", `y` = "'.$u->info['y'].'" WHERE `dn` > 0 AND `name` = "'.$obj['name'].'" AND `img` = "'.$obj['img'].'" AND `action` = "'.$obj['action'].'" AND `x` = "'.$obj['x'].'" AND `y` = "'.$obj['y'].'"'); $txt = 'Строительство "'.$obj['name'].'" завершилось, вернитесь на клетку назад...'; $u->send('','','','','','Игрок "' . $u->info['login'] . '" завершил строительство объекта "'.mysql_real_escape_string($actions['name']).'".',time(),6,0,0,0,1,0); } } echo '
'.$txt.'
'; } # пожертвование if( isset($_POST['itemid'],$_POST['action']) ){ $help = mysql_fetch_assoc(mysql_query('SELECT COUNT(`id`) as count, item_id FROM `items_users` WHERE `item_id` = '.$_POST['itemid'].' AND `uid` = '.$u->info['id'].' AND (`delete` = "0" OR `delete` = "1000") AND `inOdet` = "0" AND `inShop` = "0" LIMIT 1')); if($help){ $item = mysql_fetch_assoc(mysql_query('SELECT im.`name`, im.`img` FROM `items_main` as im WHERE im.`id` = '.$help['item_id'].' LIMIT 1')); if( isset($item) && $item['name'] != '' ) { foreach( $actions['resource'] as $key=>$val) { if($_POST['itemid'] == $val['item']){ $current = mysql_fetch_assoc(mysql_query('SELECT SUM(b.`count`) as count, im.`name`, im.`img` FROM `items_main` as im LEFT JOIN `building` as `b` ON b.item_id = im.id WHERE b.`building` = "'.$actions['ident'].'" AND im.`id` = '.$val['item'].' LIMIT 1')); if($current['count']==NULL) $current['count']=0; else $current['count']=(int)$current['count']; if($current['count']+(int)$help['count'] <= $val['count']) { # Если ваших ресурсов меньше чем требуется. } else { # Если ваших ресурсов больше чем требуется. $help['count'] = +($val['count']-$current['count']); } if($help['count'] > 0) { mysql_query('UPDATE `items_users` SET `delete` = "'.time().'" WHERE `item_id` = '.$help['item_id'].' AND `uid` = '.$u->info['id'].' AND (`delete` = "0" OR `delete` = "1000") AND `inOdet` = "0" AND `inShop` = "0" ORDER BY `delete` DESC LIMIT '.$help['count'].''); mysql_query('INSERT INTO building (id, building, uid, clan_id, item_id, count) VALUES (NULL, "'.$actions['ident'].'", '.$u->info['id'].', '.$u->info['clan'].', '.$help['item_id'].', '.$help['count'] .')'); $d->error = 'Вы пожертвовали на строительство ['.$item['name'].'] в количестве '.$help['count'].'шт.'; } } } # # mysql_query('INSERT INTO `dungeon_actions` (`dn`,`time`,`x`,`y`,`uid`,`vars`,`vals`) VALUES ("'.$u->info['dnow'].'","'.time().'","'.$u->info['x'].'","'.$u->info['y'].'","'.$u->info['id'].'","building_resource","count_'.$help.'")'); # #("'.$u->info['dnow'].'","'.time().'","'.$u->info['x'].'","'.$u->info['y'].'","'.$u->info['id'].'","building_resource","count_'.$help.'")'); } } } unset($_POST,$help, $item); # отображение $count = mysql_fetch_array(mysql_query('SELECT SUM(count) as count FROM `building` WHERE `building` = "'.$actions['ident'].'" LIMIT 1')); if( isset($count[0]) and $count[0]!=NULL ) $count = $count[0]; else $count = 0; $r = ''; # Текущее состояние строительства. foreach( $actions['resource'] as $key=>$val) { if($count==0){ $current = mysql_fetch_assoc(mysql_query('SELECT im.`name`, im.`img` FROM `items_main` as im WHERE im.`id` = '.$val['item'].' LIMIT 1')); $current['count'] = 0; } else { $current = mysql_fetch_assoc(mysql_query('SELECT SUM(b.`count`) as count, im.`name`, im.`img` FROM `items_main` as im LEFT JOIN `building` as `b` ON b.item_id = im.id WHERE b.`building` = "'.$actions['ident'].'" AND im.`id` = '.$val['item'].' LIMIT 1')); } if( isset($current) && $current['name'] != '' ) { $actions['resource'][$key]['current'] = (int)$current['count']; $actions['resource'][$key]['name'] = $current['name']; $actions['resource'][$key]['img'] = $current['img']; } else { $actions['resource'][$key]['current'] = 0; $actions['resource'][$key]['name'] = "Неизвестный предмет"; $actions['resource'][$key]['img'] = ""; } } unset($key,$val,$current); foreach( $actions['resource'] as $row) { $current_uid = mysql_fetch_assoc(mysql_query('SELECT COUNT(`id`) as count FROM `items_users` WHERE `item_id` = '.$row['item'].' AND `uid` = '.$u->info['id'].' AND (`delete` = "0" OR `delete` = "1000") AND `inOdet` = "0" AND `inShop` = "0" LIMIT 1')); if(isset($current_uid) && $current_uid['count'] == NULL) $current_uid['count'] = 0; // Сколько можем внести $r .= ''; if($row['current'] >= $row['count']){ $input = ''; } else{ $input = ''; } $r .= ''; unset($input,$current_uid); } if( round($count/($need_count/100)) >= 100 ) { $r .= ''; } $r .= '
Прогресс строительства %
'.round($count/($need_count/100)).'/'.(100).'

'; $r .= '
['.$row['name'].']
'.$input.''; $r .='
'.round($row['current']/($row['count']/100)).'/'.(100).'

'; $r .= '

'; unset($row); /* *
Прогресс строительства */ # Идет строительство "'.$actions['name'].'", но нам нехватает ресурсов, помоги добрый странник. $d->information = '
'.$r; }