Potrebujem sa poradiť, ako zapísať následovný príkaz, ktorý je napísaný čierno, ten funguje ok, ale potrebujem pod neho toto ako podmienku:
- if($user['fraction'] == 0 $attacked_user['fraction'] == 3 OR $attacked_user['fraction'] == 5 echo nemôžeš zaútočiť na spojeneckú frakciu
- if($user['fraction'] == 3 $attacked_user['fraction'] == 0 OR $attacked_user['fraction'] == 5 echo nemôžeš zaútočiť na spojeneckú frakciu
- if($user['fraction'] == 5 $attacked_user['fraction'] == 0 OR $attacked_user['fraction'] == 3 echo nemôžeš zaútočiť na spojeneckú frakciu
- if($user['fraction'] == 1 $attacked_user['fraction'] == 2 OR $attacked_user['fraction'] == 4 echo nemôžeš zaútočiť na spojeneckú frakciu
- if($user['fraction'] == 2 $attacked_user['fraction'] == 1 OR $attacked_user['fraction'] == 4 echo nemôžeš zaútočiť na spojeneckú frakciu
- if($user['fraction'] == 4 $attacked_user['fraction'] == 1 OR $attacked_user['fraction'] == 2 echo nemôžeš zaútočiť na spojeneckú frakciu
Neviem ako to zapísať, user fraction predstavuje frakciu za akú hrá hráč v hre a attacked_user predstavuje frakciu, ktorú má hráč, na ktorého útočím, neviem ako to zapísať, lebo ak to zapisujem takýmto typom tak dostanem echo nemôžeš zaútočiť na spojeneckú frakciu, no i tak bojovníci začnú útok. Neviem ako to mám urobiť, aby sa nevykonala podmienka pod else... Ďakujem všetkým za pomoc
if(isset($_POST['attack2'])){
if($user['fraction'] == $attacked_user['fraction']){
echo("Nemôžeš zaútočiť na svoju frakciu!");
}
elseif($stats['battery'] >= 10 && $timer['atime'] == 0 && $stats['attack'] >= 10 && $_POST['attack1'] != "" && $_POST['attack1'] != $_SESSION['uid'] && is_numeric($_POST['attack1']) && $_POST['attack1'] <= $id['MAX(`id`)'] && $_POST['attack1'] > 0){
echo("Bojovníci začali útok!");
$azarobok1 = 0;
$azarobok2 = 0;
$atime = time();
$working['ayes'] = $atime;
$stats['battery'] -= 10;
$stats['rank'] += 4;
$timer['atime'] = 1;
$info1 = mysqli_query($con,"SELECT `id` FROM `stats` WHERE `id`='".$_POST['attack1']."'") or die(mysqli_error($con));
$info2 = mysqli_fetch_assoc($info1);
$info3 = $info2['id'];
$update_working = mysqli_query($con,"UPDATE `working` SET `ayes`='".$working['ayes']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
$update_stats = mysqli_query($con,"UPDATE `stats` SET `battery`='".$stats['battery']."',`rank`='".$stats['rank']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
$update_timer = mysqli_query($con,"UPDATE `timer` SET `atime`='".$timer['atime']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
$update_ranking = mysqli_query($con,"UPDATE `ranking` SET `number`='".$info3."' WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
}elseif((time() - $working['ayes']) >= 600 && $timer['atime'] == 1){
$info1 = mysqli_query($con,"SELECT `number` FROM `ranking` WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
$info2 = mysqli_fetch_assoc($info1);
$info3 = $info2['number'];
$info4 = mysqli_query($con,"SELECT `defense`,`food`,`gold` FROM `stats` WHERE `id`='".$info3."'") or die(mysqli_error($con));
$info5 = mysqli_fetch_assoc($info4);
if($stats['attack'] > $info5['defense']){
$azarobok1 = round($info5['food'] / 2);
$azarobok2 = round($info5['gold'] / 2);
echo("Získal si ".$azarobok1." jedla a ".$azarobok2." zlata!");
$atime = 0;
$working['ayes'] = $atime;
$stats['food'] += $azarobok1;
$stats['gold'] += $azarobok2;
if($azarobok1 > 0){
$stats['rank'] += 1;
}
if($azarobok2 > 0){
$stats['rank'] += 1;
}
$info5['food'] -= $azarobok1;
$info5['gold'] -= $azarobok2;
$azarobok1 = 0;
$azarobok2 = 0;
$timer['atime'] = 0;
$update_working = mysqli_query($con,"UPDATE `working` SET `ayes`='".$working['ayes']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
$update_stats = mysqli_query($con,"UPDATE `stats` SET `food`='".$stats['food']."',`gold`='".$stats['gold']."',`rank`='".$stats['rank']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
$update_stats = mysqli_query($con,"UPDATE `stats` SET `food`='".$info5['food']."',`gold`='".$info5['gold']."' WHERE `id`='".$info3."'") or die(mysqli_error($con));
$update_timer = mysqli_query($con,"UPDATE `timer` SET `atime`='".$timer['atime']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
}elseif($stats['attack'] <= $info5['defense']){
echo("Bojovníci sa vzdali!");
$atime = 0;
$working['ayes'] = $atime;
$timer['atime'] = 0;
$update_working = mysqli_query($con,"UPDATE `working` SET `ayes`='".$working['ayes']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
$update_timer = mysqli_query($con,"UPDATE `timer` SET `atime`='".$timer['atime']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($con));
}
}elseif($timer['atime'] == 0){
if($stats['attack'] == 0){
echo("Nemáš žiaden útok!");
}elseif($stats['battery'] < 10){
echo("Nemáš dostatok baterky!");
}elseif($_POST['attack1'] == "" | $_POST['attack1'] == $_SESSION['uid'] | !is_numeric($_POST['attack1']) | $_POST['attack1'] > $id['MAX(`id`)'] | $_POST['attack1'] <= 0){
echo ("Toto nieje dobré ID majora!");
}
}else{
$zostava = (600 - (time() - $working['ayes']));
echo("Musíš počkať ".$zostava." sekúnd.");
}
}