tfer['id']) && $u->info['align'] != 2) { if($u->tfer['finish1']==0 && $u->tfer['finish2']==0) { $js = ''; $mn = 0; if(isset($_POST['cancel2'])) { $u->tfer['r0'] = time(); $u->tfer['good1'] = 0; $u->tfer['good2'] = 0; $_POST['id'] = 'reflesh'; mysql_query('UPDATE `transfers` SET `r0` = "'.$u->tfer['r0'].'",`r1` = "0",`r2` = "0",`good1` = "0",`good2` = "0" WHERE `id` = "'.$u->tfer['id'].'" LIMIT 1'); }elseif(isset($_POST['start2'])) { //сохраняем обмен if( $u->info['admin'] == 0 || 1 == 1) { echo 'Передачи временно недоступны.'; }elseif($u->tfer['good1']>0 && $u->tfer['good2']>0) { //завершаем обмен $u->tfer['cancel1'] = time(); $u->tfer['cancel2'] = time(); $u->tfer['finish1'] = time(); $u->tfer['finish2'] = time(); //меняем вещи + передаем КР и завершаем передачи, переход на лог передач $upd2 = mysql_query('UPDATE `transfers` SET `cancel1` = "'.$u->tfer['cancel1'].'",`cancel2` = "'.$u->tfer['cancel2'].'",`finish1` = "'.$u->tfer['finish1'].'",`finish2` = "'.$u->tfer['finish2'].'" WHERE `id` = "'.$u->tfer['id'].'" LIMIT 1'); //Обмениваем деньги $mn1 = 0; $mn2 = 0; $inf = array(); $inf[$u->tfer['uid1']] = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$u->tfer['uid1'].'" LIMIT 1')); $inf[$u->tfer['uid2']] = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$u->tfer['uid2'].'" LIMIT 1')); if($inf[$u->tfer['uid1']]['money']<$u->tfer['money1']) { $u->tfer['money1'] = $inf[$u->tfer['uid1']]['money']; } if($inf[$u->tfer['uid2']]['money']<$u->tfer['money2']) { $u->tfer['money2'] = $inf[$u->tfer['uid2']]['money']; } $mn1 = $u->tfer['money1']; $mn2 = $u->tfer['money2']; if($mn1<0){ $mn1 = 0; } if($mn2<0){ $mn2 = 0; } if($mn1>0) { //игрок 1 передает деньги игроку 2 $upd = mysql_query('UPDATE `users` SET `money` = `money` - "'.$mn1.'" WHERE `id` = "'.$inf[$u->tfer['uid1']]['id'].'" LIMIT 1'); if($upd) { $upd = mysql_query('UPDATE `users` SET `money` = `money` + "'.$mn1.'" WHERE `id` = "'.$inf[$u->tfer['uid2']]['id'].'" LIMIT 1'); if($upd) { $u->addDelo(2,$inf[$u->tfer['uid1']]['id'],'"System.transfer.MONEY": Передано '.$mn1.' кр. персонажу "'.$inf[$u->tfer['uid2']]['login'].'" ('.$inf[$u->tfer['uid2']]['id'].').',time(),$u->info['city'],'System.transfer',0,0); $u->addDelo(2,$inf[$u->tfer['uid2']]['id'],'"System.transfer.MONEY": Получено '.$mn1.' кр. от персонажа "'.$inf[$u->tfer['uid1']]['login'].'" ('.$inf[$u->tfer['uid1']]['id'].').',time(),$u->info['city'],'System.transfer',0,0); }else{ $u->addDelo(2,$inf[$u->tfer['uid1']]['id'],'"System.transfer.MONEY": Передано '.$mn1.' кр. персонажу "'.$inf[$u->tfer['uid2']]['login'].'" ('.$inf[$u->tfer['uid2']]['id'].'), ошибка во время передачи.',time(),$u->info['city'],'System.transfer',0,0); } } } if($mn2>0) { //игрок 2 передает деньги игроку 1 $upd = mysql_query('UPDATE `users` SET `money` = `money` - "'.$mn2.'" WHERE `id` = "'.$inf[$u->tfer['uid2']]['id'].'" LIMIT 1'); if($upd) { $upd = mysql_query('UPDATE `users` SET `money` = `money` + "'.$mn2.'" WHERE `id` = "'.$inf[$u->tfer['uid1']]['id'].'" LIMIT 1'); if($upd) { $u->addDelo(2,$inf[$u->tfer['uid2']]['id'],'"System.transfer.MONEY": Передано '.$mn2.' кр. персонажу "'.$inf[$u->tfer['uid1']]['login'].'" ('.$inf[$u->tfer['uid1']]['id'].').',time(),$u->info['city'],'System.transfer',0,0); $u->addDelo(2,$inf[$u->tfer['uid1']]['id'],'"System.transfer.MONEY": Получено '.$mn2.' кр. от персонажа "'.$inf[$u->tfer['uid2']]['login'].'" ('.$inf[$u->tfer['uid2']]['id'].').',time(),$u->info['city'],'System.transfer',0,0); }else{ $u->addDelo(2,$inf[$u->tfer['uid2']]['id'],'"System.transfer.MONEY": Передано '.$mn2.' кр. персонажу "'.$inf[$u->tfer['uid1']]['login'].'" ('.$inf[$u->tfer['uid1']]['id'].'), ошибка во время передачи.',time(),$u->info['city'],'System.transfer',0,0); } } } //Обмениваем предметы $sp = mysql_query('SELECT * FROM `items_users` WHERE (`uid`="'.$u->tfer['uid1'].'" OR `uid`="'.$u->tfer['uid2'].'") AND `delete`="0" AND `inOdet`="0" AND `inShop`="0" AND `inTransfer` > "0"'); $nalog = 0; $fu = 0; $x = 0; $uus = array(); while($pl = mysql_fetch_array($sp)) { $x = $u->itemsX($pl['id'],$pl['uid']); $fu = $pl['uid']; if($pl['uid']==$u->tfer['uid1']) { $pl['uid'] = $u->tfer['uid2']; }elseif($pl['uid']==$u->tfer['uid2']) { $pl['uid'] = $u->tfer['uid1']; } $us = $inf[$pl['uid']]; $uus = $inf[$fu]; if($pl['inTransfer']==1) { //подарок $pl['gift'] = $uus['login']; }else{ //налог $nalog += 1; } $upd = mysql_query('UPDATE `items_users` SET `uid` = "'.$pl['uid'].'",`gift` = "'.$pl['gift'].'" WHERE `id` = "'.$pl['id'].'" AND `inShop` = "0" AND `delete` = "1000" AND `inOdet` = "0" LIMIT '.$x.''); if($upd) { mysql_query('UPDATE `items_users` SET `uid` = "'.$pl['uid'].'",`gift` = "'.$pl['gift'].'" WHERE `inGroup` = "'.$pl['id'].'"'); //заносим в личные дела $u->addDelo(2,$fu,'"System.transfer": Предмет "'.$pl['name'].' (x'.$x.')" [itm:'.$pl['id'].'] был передан персонажу "'.$us['login'].'"('.$pl['uid'].'), Тип передачи: '.$pl['inTransfer'].'.',time(),$u->info['city'],'System.transfer',0,0); $u->addDelo(2,$pl['uid'],'"System.transfer": Персонаж "'.$uus['login'].'"('.$uus['id'].') передал предмет "'.$pl['name'].' (x'.$x.')" [itm:'.$pl['id'].'], Тип передачи: '.$pl['inTransfer'].'.',time(),$u->info['city'],'System.transfer',0,0); } } $upd1 = mysql_query('UPDATE `items_users` SET `inTransfer` = "0" WHERE (`uid`="'.$u->tfer['uid1'].'" OR `uid`="'.$u->tfer['uid2'].'") AND `delete`="0" AND `inOdet`="0" AND `inShop`="0" AND `inTransfer` > "0"'); if($upd1 && $upd2) { $js .= 'location = location;'; } unset($upd1,$upd2,$fu,$nalog,$x,$us,$uus,$inf); }else{ //подтверждение обмена $u->tfer['r0'] = time(); if($u->tfer['uid1']==$u->info['id']) { $u->tfer['good1'] = time(); $mn = 1; mysql_query('UPDATE `transfers` SET `r0` = "'.$u->tfer['r0'].'",`r1` = "0",`r2` = "0",`good1` = "'.$u->tfer['good1'].'" WHERE `id` = "'.$u->tfer['id'].'" LIMIT 1'); }else{ $u->tfer['good2'] = time(); $mn = 1; mysql_query('UPDATE `transfers` SET `r0` = "'.$u->tfer['r0'].'",`r1` = "0",`r2` = "0",`good2` = "'.$u->tfer['good2'].'" WHERE `id` = "'.$u->tfer['id'].'" LIMIT 1'); } $_POST['id'] = 'reflesh'; } }elseif($_POST['id']=='sale' && isset($_POST['cancelid']) && $u->tfer['good1']==0 && $u->tfer['good2']==0) { $upd = mysql_query('UPDATE `items_users` SET `inTransfer` = "0" WHERE `id` = "'.mysql_real_escape_string($_POST['cancelid']).'" AND `uid`="'.$u->info['id'].'" AND `delete`="0" AND `inOdet`="0" AND `inShop`="0" AND `inTransfer` > "0" LIMIT 1'); if($upd) { $u->tfer['r0'] = time(); mysql_query('UPDATE `transfers` SET `r0` = "'.$u->tfer['r0'].'" WHERE `id` = "'.$u->tfer['id'].'" LIMIT 1'); $_POST['id'] = 'reflesh'; } }elseif($_POST['id']=='sale' && isset($_POST['itemid']) && $u->tfer['good1']==0 && $u->tfer['good2']==0) { $g = 1; $itm = mysql_fetch_array(mysql_query('SELECT `im`.*,`iu`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`id` = "'.mysql_real_escape_string($_POST['itemid']).'" AND `iu`.`uid`="'.$u->info['id'].'" AND `iu`.`delete`="0" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" AND `iu`.`inTransfer` = "0" LIMIT 1')); if(isset($itm['id'])) { $po = $u->lookStats($itm['data']); if(isset($po['sudba']) && $po['sudba']!='0') { $g = 0; } if($itm['inTransfer']>0) { $g = 0; } }else{ $g = 0; } if($g==1) { if($_POST['saletype']==2) { $g = 2; }else{ $g = 1; } mysql_query('UPDATE `items_users` SET `inTransfer` = "'.((int)$g).'" WHERE `id` = "'.$itm['id'].'" LIMIT 1'); $u->tfer['r0'] = time(); mysql_query('UPDATE `transfers` SET `r0` = "'.$u->tfer['r0'].'" WHERE `id` = "'.$u->tfer['id'].'" LIMIT 1'); $_POST['id'] = 'reflesh'; } } if($_POST['id']=='reflesh') { //обновление инвентаря $i = 1; while($i<=6) { $itmAll = ''; $itmAllSee = ''; $itmAll = $u->genInv(5,'`iu`.`uid`="'.$u->info['id'].'" AND `iu`.`delete`="0" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" AND `im`.`inRazdel`="'.$i.'" AND `iu`.`inTransfer` = "0" ORDER BY `lastUPD` DESC'); if($itmAll[0]==0) { $itmAllSee = '
'.$r.' |