= 30)) { if(mysql_query("UPDATE `inventory` SET `text` = '".mysql_real_escape_string($_POST['count'])."' WHERE `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '".(int)$_POST['set']."' AND `setsale` = 0 LIMIT 1")) { $user['money'] -= 30; mysql_query("UPDATE `users` SET `money` = '".$user['money']."' WHERE id = {$user['id']} LIMIT 1"); } } if($_GET['rep'] && ($_GET['sid'] == 2)) { mysql_query("UPDATE `inventory` SET `text` = '' WHERE `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '".(int)$_GET['rep']."' LIMIT 1"); } if($_GET['sid'] && $_GET['rep']) { switch($_GET['sid']) { case 1: $row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `type` < 12 AND `isrep` = 1 AND `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '".(int)$_GET['rep']."' LIMIT 1")); if($row['duration'] > 0) { $onecost = 0.1; if($onecost <= $user['money']) { if(mysql_query("UPDATE `inventory` SET `duration` = `duration`-1 WHERE `id` = '".(int)$_GET['rep']."' LIMIT 1")) { $err = "Произведен ремонт предмета \"{$row['name']}\" за ".round($onecost, 2)." кр. "; $user['money'] -= round($onecost, 2); mysql_query("UPDATE `users` SET `money` = '".$user['money']."' WHERE `id` = {$user['id']} LIMIT 1"); $newduration = $row['duration']-1; mysql_query("INSERT INTO `delo` (`author`, `pers`, `text`, `type`, `date`) VALUES ('0', '{$user['id']}', 'Отремонтирован предмет \"".$row['name']."\" id:(cap".$row['id'].") [".$newduration."/".$row['maxdur']."] у \"".$user['login']."\" за ".round($onecost,2)." кр. ',1,'".time()."')"); if(rand(1, 10) == 1) { $err .= "К сожалению максимальная долговечность предмета из-за ремонта уменьшилась."; mysql_query("UPDATE `inventory` SET `maxdur` = `maxdur`-1 WHERE `id` = '".(int)$_GET['rep']."' LIMIT 1"); } } } else { $err = "Недостаточно денег."; } } break; case 10: $row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `isrep` = 1 AND `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '{$_GET['rep']}' LIMIT 1;")); if($row['duration'] >= 10) { //$onecost=$row['cost']/($row['maxdur']*10); //if($onecost < 0.1) {$onecost=0.1;} $onecost=0.1; if(($onecost*10) <= $user['money']) { if(mysql_query("UPDATE `inventory` SET `duration` = `duration`-10 WHERE `id` = {$_GET['rep']}")) { $err = "Произведен ремонт предмета \"{$row['name']}\" за ".(round($onecost,2)*10)." кр. "; mysql_query("UPDATE `users` set `money` = `money`- '".(round($onecost,2)*10)."' WHERE id = {$user['id']}"); $newduration=$row['duration']-10; mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$user['id']}','Отремонтирован предмет \"".$row['name']."\" id:(cap".$row['id'].") [".$newduration."/".$row['maxdur']."] у \"".$user['login']."\" за ".(round($onecost,2)*10)." кр. ',1,'".time()."');"); $user['money']=$user['money'] - (round($onecost,2)*10); if(rand(1,7)==1) { $err .= "К сожалению максимальная долговечность предмета из-за ремонта уменьшилась."; mysql_query("UPDATE `inventory` SET `maxdur` = `maxdur`-1 WHERE `id` = {$_GET['rep']}"); } } } else { $err = "Недостаточно денег."; } } break; case 'full': $row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `isrep` = 1 AND `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '{$_GET['rep']}' AND `setsale`=0 LIMIT 1;")); $full = $row['duration']; if($row['duration'] >1) { //$onecost=$row['cost']/($row['maxdur']*10); //if($onecost < 0.1) {$onecost=0.1;} $onecost=0.1; if(round($onecost*$full) <= $user['money']) { if(mysql_query("UPDATE `inventory` SET `duration` = '0' WHERE `id` = {$_GET['rep']}")) { $err = "Произведен ремонт предмета \"{$row['name']}\" за ".(round($onecost,2)*$full)." кр. "; mysql_query("UPDATE `users` set `money` = `money`- '".(round($onecost,2)*$full)."' WHERE id = {$user['id']}"); mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$user['id']}','Отремонтирован предмет \"".$row['name']."\" id:(cap".$row['id'].") [0/".$row['maxdur']."] у \"".$user['login']."\" за ".(round($onecost,2)*$full)." кр. ',1,'".time()."');"); $user['money']=$user['money'] - (round($onecost,2)*$full); if(rand(1,5)==1) { $err .= "К сожалению максимальная долговечность предмета из-за ремонта уменьшилась."; mysql_query("UPDATE `inventory` SET `maxdur` = `maxdur`-1 WHERE `id` = {$_GET['rep']}"); } } } else { $err = "Недостаточно денег."; } } break; } } ?>