if ($randomnumber == 1){ if ($randomnumber2 == 1){ if ($randomnumber3 == 1){ $lose = 1; $wincalc = $invest*$mal1; $win = $wincalc;
if ($_POST['play'] == $_POST['play']){ if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); } else { if ($lose == 1){ $smarty->assign('winorlosetest','Dude, you win!'); } else { $smarty->assign('winorlosetest','Oh no, you lose!'); } } }
} } } if ($randomnumber == 2){ if ($randomnumber2 == 2){ if ($randomnumber3 == 2){ $lose = 1; $wincalc = $invest * $mal1; $win = $wincalc; if ($_POST['play'] == $_POST['play']){ if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); } else { if ($lose == 1){ $smarty->assign('winorlosetest','Dude, you win!'); } else { $smarty->assign('winorlosetest','Oh no, you lose!'); } } } } } } if ($randomnumber == 3){ if ($randomnumber2 == 3){ if ($randomnumber3 == 3){ $lose = 1; $wincalc = $invest * $mal2; $win = $wincalc; if ($_POST['play'] == $_POST['play']){ if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); } else { if ($lose == 1){ $smarty->assign('winorlosetest','Dude, you win!'); } else { $smarty->assign('winorlosetest','Oh no, you lose!'); } } } } } } if ($randomnumber == 4){ if ($randomnumber2 == 4){ if ($randomnumber3 == 4){ $lose = 1; $wincalc = $invest * $mal4; $win = $wincalc; if ($_POST['play'] == $_POST['play']){ if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); } else { if ($lose == 1){ $smarty->assign('winorlosetest','Dude, you win!'); } else { $smarty->assign('winorlosetest','Oh no, you lose!'); } } } } } } if ($randomnumber == 5){ if ($randomnumber2 == 5){ if ($randomnumber3 == 5){ $lose = 1; $wincalc = $invest * $mal5; $win = $wincalc; if ($_POST['play'] == $_POST['play']){ if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); } else { if ($lose == 1){ $smarty->assign('winorlosetest','Dude, you win!'); } else { $smarty->assign('winorlosetest','Oh no, you lose!'); } } } } } } if ($randomnumber == 6){ if ($randomnumber2 == 6){ if ($randomnumber3 == 6){ $lose = 1; $wincalc = $invest * $mal6; $win = $wincalc; if ($_POST['play'] == $_POST['play']){ if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); } else { if ($lose == 1){ $smarty->assign('winorlosetest','Dude, you win!'); } else { $smarty->assign('winorlosetest','Oh no, you lose!'); } } } } } } if ($randomnumber == 7){ if ($randomnumber2 == 7){ if ($randomnumber3 == 7){ $lose = 1; $wincalc = $invest * $mal7; $win = $wincalc; if ($_POST['play'] == $_POST['play']){ if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); } else { if ($lose == 1){ $smarty->assign('winorlosetest','Dude, you win!'); } else { $smarty->assign('winorlosetest','Oh no, you lose!'); } } } } } } if ($randomnumber == 8){ if ($randomnumber2 == 8){ if ($randomnumber3 == 8){ $lose = 1; $wincalc = $invest * $mal8; $win = $wincalc; if ($_POST['play'] == $_POST['play']){ if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); } else { if ($lose == 1){ $smarty->assign('winorlosetest','Dude, you win!'); } else { $smarty->assign('winorlosetest','Oh no, you lose!'); } } } } } } if ($randomnumber == 9){ if ($randomnumber2 == 9){ if ($randomnumber3 == 9){ $lose = 1; $win = $invest*$mal9; if ($_POST['play'] == $_POST['play']){ if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); } else { if ($lose == 1){ $smarty->assign('winorlosetest','Dude, you win!'); } else { $smarty->assign('winorlosetest','Oh no, you lose!'); } } } } } }
$db->queryres("select * from tbl_config where header='timer'"); $timer=NOW+($db->res['value']*60); $db->query("update tbl_user set credit=credit+'".$_SESSION['prize']."',reset='$timer',ip='$ip' where user_id='$uid'"); $rid=$userdet['parent_id'];
if($rid){ $db->queryres("select * from tbl_config where header='referral_percent'"); $profit=($_SESSION['prize']*$db->res['value'])/100; $db->query("update tbl_user set credit=credit+'$profit' where user_id='$rid'"); }
if(isset($_SESSION['user']['win'])){ $db->queryres("select * from tbl_config where header='currency'"); $smarty->assign('prize',$_SESSION['user']['win']); $smarty->assign('curency',$db->res['value']);
$db->queryres("select reset from tbl_user where user_id='$uid' or ip='$ip' order by reset desc"); if($db->res['reset']-time() > 0){ $smarty->assign('timer',true); $smarty->assign('timer_amount',$db->res['reset']-time()); }
$with=array(); $db->query("select * from tbl_donate where status=2 order by rand() limit 20"); while($res=$db->fetchArray()){ $ar=array('link'=>$res['link']); array_push($with,$ar); } $smarty->assign('with',$with);
</Div> {if !$notlogged} <center> This is only to demonstrate the game. The full version of this will be online soon!<br>Information: If you visit this game in a new Session, it will automatically show you, that you lost; but no Credits are gone.<br>_________________________________________________________________________<br><br> <table > <tr> <td width="40%"> <center> <div class="alert alert-info"><h3>You roll:</h3><br><img src='img/slots_{$randomnumber}.png' ><img src='img/slots_{$randomnumber2}.png' ><img src='img/slots_{$randomnumber3}.png' ><br></div> </center> </td> <td width="20%"> </td> <td width="40%"> <center> <div class="alert alert-info"><b>{$winorlose}</b></div> <b>Bet:</b> {$slots_bet}<br><br> <form action="bm_slots.php" method="post"> <input name="betvalue" type="text" class="btn btn-success" size="10" placeholder="0.00000000"> <button type="submit" name="bet" class="btn btn-success">Set new bet</button> </form><br><br> <form> <button type="submit" value="play" name="play" class="btn btn-success">Roll!</button> </form>
Ich persönlich mag Smarty nicht, selber benutze ich Twig als Template Engine.
- Wieso hast du 2 Tabellen mit je einer Row ? (wieso so gelöst o.O ?)
- Bei den Images hast du überall die selbe Größe etc. wieso nutzt du da nicht eine Class die überall dran kommt ?
- Wieso hast du dort eine Form wenn die nichts macht ?
- Deine Variablen namen sind nicht grade gut gewählt (randomnumber(1/2) etc...)- Wieso nimmst du bei der $lose Variable die 1 statt true/false ?
- Was soll der Check
PHP Code:
$_POST['play'] == $_POST['play']
wenn du zwei mal das gleiche mit einander vergleist muss es logischer weiße gleich sein.
- Du hast den Check
PHP Code:
if ($lose == 1)
drin, obwohl an der Stelle es nur 1 sein kann.
- Solche Checks :
PHP Code:
if ($userdet['credit'] < $userdet['slots_bet']){ $smarty->assign('cashcheck','Sorry, you got not enaught BTC to play.'); }
am besten immer am Anfang machen, bevor du etwas berechnest o.ä.. Das ganze spart einfach Berechnungszeit die unnötig ist weil es nachher eh nicht gebraucht wird (bei so ein Projekt wahrscheinlich eh egal, dennoch direkt angewöhnen ordentlichen Code zu schreiben.- Wenn du dennoch mal fälle hast wo du mehrere Ifs nacheinander hast und immer die gleiche Variable nutzt dann benutzt elseif(s).
Wenn in deinem Beispiel z.b. die Variable 'randomnumber ' eine 1 ist dann KÖNNEN die anderen 8 Abfragen nicht mehr treffen, daher elseif nutzen(zeit Ersparung).
- Weitere kleine Sachen die man optimieren könnte :