Обучение/Помощь новичкам | Код
Куда в ставить етот код чтоб выпадали ключи к сундукам на арене и за 1бой и за слив за 1золота
chanse=rand(1,100);
if($chanse<10){ mysql_Query("UPDATE `users` SET `key`=`key`+'1' WHERE `id`='".$user['id']."'");
chanse=rand(1,100);
if($chanse<10){ mysql_Query("UPDATE `users` SET `key`=`key`+'1' WHERE `id`='".$user['id']."'");
<?php
require_once ('system/func.php');
$title = 'Арена';
require_once ('system/header.php');
auth(); // Закроем от гостей
$quest_1 = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '1'"));
$q_1 = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest_1[id]' AND `id_user` = '$myID'"));
$quest_2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '2'"));
$q_2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest_2[id]' AND `id_user` = '$myID'"));
$batle = mysql_query("SELECT * FROM `arena` WHERE `id_user` = '".$myID."' ORDER BY `id` LIMIT 1");
$batle = mysql_fetch_array($batle);
if(!$batle){
mysql_query("INSERT INTO `arena` SET `id_user` = '$user[id]', `last` = '".time()."'");
header('Location: /arena');
exit();
}
if(isset($_GET['max_energy']) == true and $batle['last'] <= time() and $user['level'] >= 7){
$_hp = ceil($user['max_health']*10/100);
if($user['gold'] < 1){
$_SESSION['msg'] = 'Для нападения необходимо '.ico('icons','gold.png').' 1 золота';
header("Location: ?");
exit();
}
if($user['energy'] < 30 or $user['health'] < $_hp){
$_SESSION['msg'] = "Для нападения необходимо минимум ".ico('icons','health.png')." 10% жизни и ".ico('icons','energy.png')." 30 энергии<br><a href='/rinok?koldun&url=/arena' class='btn2' data-ajax>Восстановить ".ico('icons','gold.png')." 15</a>";
header('Location: /arena?'.$random.'');
exit();
}else{
$koll = num($user['energy']/30);
$exp = 0;
$crystals = 0;
$win = 0;
$los = 0;
for($kolls = 0; $kolls <= $koll; $kolls++) {
$opponent = mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]' AND `str`+`def`+`max_health` >= '".ceil($user[str]+$user[def]+$user[max_health]*40/100)."' AND `str`+`def`+`max_health` <= '".ceil($user[str]+$user[def]+$user[max_health]*110/100)."' ORDER BY RAND() LIMIT 1");
$opponent = mysql_fetch_array($opponent);
if(!$opponent){
$opponent = mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]' AND `str`+`def`+`max_health` >= '".ceil($user[str]+$user[def]+$user[max_health]*20/100)."' AND `str`+`def`+`max_health` <= '".ceil($user[str]+$user[def]+$user[max_health]*110/100)."' ORDER BY RAND() LIMIT 1");
$opponent = mysql_fetch_array($opponent);
}
if(!$opponent){
$opponent = mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]' AND `str`+`def`+`max_health` <= '".($user[str]+$user[def]+$user[max_health])."' ORDER BY RAND() LIMIT 1");
$opponent = mysql_fetch_array($opponent);
}
$_str = 0;
$_str_opp = 0;
for($round = 1; $round < 6; $round++){
$_str += rand(round($user['str']/6), round($user['str']/4));
$_str -= rand(round($opponent['def']/12), round($opponent['def']/7));
$_str_opp += rand(round($opponent['str']/6), round($opponent['str']/4));
$_str_opp -= rand(round($user['def']/12), round($user['def']/7));
if($_str_opp < 0)$_str_opp = 0;
if($_str < 0)$_str = 0;
if(mt_rand(0,100) < $user['krit']){
$krit = true;
}
if($krit)$_str *= 2;
$_str_opp += $_str_opp_1;
if(mt_rand(0,100) < $opponent['krit']){
$krit_opp = true;
}
if($krit_opp)$_str_opp *= 2;
}
if($_str > $_str_opp){
$exp += num(rand(4,6)*$user[level]);
$crystals += num(rand(3,5)*$opponent[level]);
$win += 1;
}elseif($_str_opp > $_str){
$exp += 1;
$crystals += 1;
$los += 1;
}
}
if($effect_2['on'] == 1)$exp = $exp+ceil($exp*25/100);
$exp = exp_koll($exp);
mysql_query("update `users` set
`exp` = '".($user['exp']+$exp)."',
`crystals` = '".($user['crystals']+$crystals)."',
`health` = '".($user['health']-$_str_opp)."',
`energy` = '".($user['energy']-$koll*30)."',
`gold` = '".($user['gold']-1)."'
where (`id` = '".$user['id']."')");
if($user[id_clan] > 0){
mysql_query("UPDATE `users` SET `clan_exp` = '".($user['clan_exp']+clan_exp_koll($exp))."', `clan_exp_24` = '".($user['clan_exp_24']+clan_exp_koll($exp))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".clan_exp_koll($exp)."' WHERE `id` = '".$user['id_clan']."' LIMIT 1");
}
if($q_1['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'$kolls' where (`id` = '".$q_1['id']."')");
if($q_2['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'$win' where (`id` = '".$q_2['id']."')");
mysql_query("update `arena` set `last` = '".(time()+1)."' where (`id` = '".$batle['id']."')");
require_once ('modules/arena_item_rand_full.php');
$_SESSION['msg'] = ico('icons','sum_stat.png')." <b class='info'>Проведено $kolls боев</b> ".ico('icons','sum_stat.png')."<hr>
<font color='green'>Побед: <b>$win</b></font> | <font color='red'>Поражений: <b>$los</b></font><hr>
Награда: ".ico('icons','exp.png')." ".n_f($exp)." опыта и ".ico('icons','crystal.png')." ".n_f($crystals)." кристаллов
".($item_rand == 7 ? "<hr>Новые вещи в твоей сумке:<br><img src='/images/items/$item[tip]/$item[item].png'> <img src='/images/items/$item2[tip]/$item2[item].png'> " : "")."".($inv+2 >= 21 ? "<br>Вы не смогли поднять вещи, ваша сумка переполнена!" : "")."";
header('Location: /arena?'.$random.'');
exit();
}
}
if(isset($_GET['attack']) == true and $batle['last'] <= time()){
$id = num($_GET['attack']);
$_hp = ceil($user['max_health']*10/100);
require_once ('system/func.php');
$title = 'Арена';
require_once ('system/header.php');
auth(); // Закроем от гостей
$quest_1 = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '1'"));
$q_1 = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest_1[id]' AND `id_user` = '$myID'"));
$quest_2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '2'"));
$q_2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest_2[id]' AND `id_user` = '$myID'"));
$batle = mysql_query("SELECT * FROM `arena` WHERE `id_user` = '".$myID."' ORDER BY `id` LIMIT 1");
$batle = mysql_fetch_array($batle);
if(!$batle){
mysql_query("INSERT INTO `arena` SET `id_user` = '$user[id]', `last` = '".time()."'");
header('Location: /arena');
exit();
}
if(isset($_GET['max_energy']) == true and $batle['last'] <= time() and $user['level'] >= 7){
$_hp = ceil($user['max_health']*10/100);
if($user['gold'] < 1){
$_SESSION['msg'] = 'Для нападения необходимо '.ico('icons','gold.png').' 1 золота';
header("Location: ?");
exit();
}
if($user['energy'] < 30 or $user['health'] < $_hp){
$_SESSION['msg'] = "Для нападения необходимо минимум ".ico('icons','health.png')." 10% жизни и ".ico('icons','energy.png')." 30 энергии<br><a href='/rinok?koldun&url=/arena' class='btn2' data-ajax>Восстановить ".ico('icons','gold.png')." 15</a>";
header('Location: /arena?'.$random.'');
exit();
}else{
$koll = num($user['energy']/30);
$exp = 0;
$crystals = 0;
$win = 0;
$los = 0;
for($kolls = 0; $kolls <= $koll; $kolls++) {
$opponent = mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]' AND `str`+`def`+`max_health` >= '".ceil($user[str]+$user[def]+$user[max_health]*40/100)."' AND `str`+`def`+`max_health` <= '".ceil($user[str]+$user[def]+$user[max_health]*110/100)."' ORDER BY RAND() LIMIT 1");
$opponent = mysql_fetch_array($opponent);
if(!$opponent){
$opponent = mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]' AND `str`+`def`+`max_health` >= '".ceil($user[str]+$user[def]+$user[max_health]*20/100)."' AND `str`+`def`+`max_health` <= '".ceil($user[str]+$user[def]+$user[max_health]*110/100)."' ORDER BY RAND() LIMIT 1");
$opponent = mysql_fetch_array($opponent);
}
if(!$opponent){
$opponent = mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]' AND `str`+`def`+`max_health` <= '".($user[str]+$user[def]+$user[max_health])."' ORDER BY RAND() LIMIT 1");
$opponent = mysql_fetch_array($opponent);
}
$_str = 0;
$_str_opp = 0;
for($round = 1; $round < 6; $round++){
$_str += rand(round($user['str']/6), round($user['str']/4));
$_str -= rand(round($opponent['def']/12), round($opponent['def']/7));
$_str_opp += rand(round($opponent['str']/6), round($opponent['str']/4));
$_str_opp -= rand(round($user['def']/12), round($user['def']/7));
if($_str_opp < 0)$_str_opp = 0;
if($_str < 0)$_str = 0;
if(mt_rand(0,100) < $user['krit']){
$krit = true;
}
if($krit)$_str *= 2;
$_str_opp += $_str_opp_1;
if(mt_rand(0,100) < $opponent['krit']){
$krit_opp = true;
}
if($krit_opp)$_str_opp *= 2;
}
if($_str > $_str_opp){
$exp += num(rand(4,6)*$user[level]);
$crystals += num(rand(3,5)*$opponent[level]);
$win += 1;
}elseif($_str_opp > $_str){
$exp += 1;
$crystals += 1;
$los += 1;
}
}
if($effect_2['on'] == 1)$exp = $exp+ceil($exp*25/100);
$exp = exp_koll($exp);
mysql_query("update `users` set
`exp` = '".($user['exp']+$exp)."',
`crystals` = '".($user['crystals']+$crystals)."',
`health` = '".($user['health']-$_str_opp)."',
`energy` = '".($user['energy']-$koll*30)."',
`gold` = '".($user['gold']-1)."'
where (`id` = '".$user['id']."')");
if($user[id_clan] > 0){
mysql_query("UPDATE `users` SET `clan_exp` = '".($user['clan_exp']+clan_exp_koll($exp))."', `clan_exp_24` = '".($user['clan_exp_24']+clan_exp_koll($exp))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".clan_exp_koll($exp)."' WHERE `id` = '".$user['id_clan']."' LIMIT 1");
}
if($q_1['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'$kolls' where (`id` = '".$q_1['id']."')");
if($q_2['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'$win' where (`id` = '".$q_2['id']."')");
mysql_query("update `arena` set `last` = '".(time()+1)."' where (`id` = '".$batle['id']."')");
require_once ('modules/arena_item_rand_full.php');
$_SESSION['msg'] = ico('icons','sum_stat.png')." <b class='info'>Проведено $kolls боев</b> ".ico('icons','sum_stat.png')."<hr>
<font color='green'>Побед: <b>$win</b></font> | <font color='red'>Поражений: <b>$los</b></font><hr>
Награда: ".ico('icons','exp.png')." ".n_f($exp)." опыта и ".ico('icons','crystal.png')." ".n_f($crystals)." кристаллов
".($item_rand == 7 ? "<hr>Новые вещи в твоей сумке:<br><img src='/images/items/$item[tip]/$item[item].png'> <img src='/images/items/$item2[tip]/$item2[item].png'> " : "")."".($inv+2 >= 21 ? "<br>Вы не смогли поднять вещи, ваша сумка переполнена!" : "")."";
header('Location: /arena?'.$random.'');
exit();
}
}
if(isset($_GET['attack']) == true and $batle['last'] <= time()){
$id = num($_GET['attack']);
$_hp = ceil($user['max_health']*10/100);
278059298 (22.12.2017 в 20:04)
Куда в ставить етот код чтоб выпадали ключи к сундукам на арене и за 1бой и за слив за 1золота
$ chanse=rand(1,100);
if($chanse<10){ mysql_Query("UPDATE `users` SET `key`=`key`+'1' WHERE `id`='".$user['id']."'");
Куда в ставить етот код чтоб выпадали ключи к сундукам на арене и за 1бой и за слив за 1золота
$ chanse=rand(1,100);
if($chanse<10){ mysql_Query("UPDATE `users` SET `key`=`key`+'1' WHERE `id`='".$user['id']."'");
IndiS (22.12.2017 в 20:05)
278059298 (22.12.2017 в 20:04)
Куда в ставить етот код чтоб выпадали ключи к сундукам на арене и за 1бой и за слив за 1золота
$ chanse=rand(1,100);
if($chanse<10){ mysql_Query("UPDATE `users` SET `key`=`key`+'1' WHERE `id`='".$user['id']."'");
278059298 (22.12.2017 в 20:04)
Куда в ставить етот код чтоб выпадали ключи к сундукам на арене и за 1бой и за слив за 1золота
$ chanse=rand(1,100);
if($chanse<10){ mysql_Query("UPDATE `users` SET `key`=`key`+'1' WHERE `id`='".$user['id']."'");
Это что-то изменит?
IndiS (22.12.2017 в 20:05)
278059298 (22.12.2017 в 20:04)
Куда в ставить етот код чтоб выпадали ключи к сундукам на арене и за 1бой и за слив за 1золота
$ chanse=rand(1,100);
if($chanse<10){ mysql_Query("UPDATE `users` SET `key`=`key`+'1' WHERE `id`='".$user['id']."'");
278059298 (22.12.2017 в 20:04)
Куда в ставить етот код чтоб выпадали ключи к сундукам на арене и за 1бой и за слив за 1золота
$ chanse=rand(1,100);
if($chanse<10){ mysql_Query("UPDATE `users` SET `key`=`key`+'1' WHERE `id`='".$user['id']."'");
я спрашивал куда етот код в файле арены вставить чтоб ключи выпадали
в условии отправки пост запроса
IndiS (22.12.2017 в 20:14)
в условии отправки пост запроса
в условии отправки пост запроса
ето где я не кодер
вродь так
if(isset($_GET['max_energy']) ==
true and $batle['last'] <= time()
and $user['level'] >= 7){
$chanse=rand(1,100);
if($chanse<10){ mysql_Query
("UPDATE `users` SET
`key`=`key`+'1' WHERE `id`='".
$user['id']."'");
}
$_hp = ceil($user
['max_health']*10/100);
if($user['gold'] < 1){
$_SESSION['msg'] = 'Для
нападения необходимо '.ico
('icons','gold.png').' 1 золота';
header("Location: ?");
exit();
}
IndiS (22.12.2017 в 20:30)
вродь так
вродь так
if(isset($_GET['max_energy']) ==
true and $batle['last'] <= time()
and $user['level'] >= 7){
$chanse=rand(1,100);
if($chanse<10){ mysql_Query
("UPDATE `users` SET
`key`=`key`+'1' WHERE `id`='".
$user['id']."'");
}
$_hp = ceil($user
['max_health']*10/100);
if($user['gold'] < 1){
$_SESSION['msg'] = 'Для
нападения необходимо '.ico
('icons','gold.png').' 1 золота';
header("Location: ?");
exit();
} не роботает