astralreb Posted January 14, 2012 Share Posted January 14, 2012 Hello i need help with the battle ladder mod in my game. What i want is to make every battle ladder to take place in a specific city. So what i have in my mind is from the staff battle ladder creation, to be an option to set in which city the ladder will take place and also to be a restriction if a user wants to take part in a battle ladder, he has to be in the city that the ladder takes place. Here is the code : battle_ladder.php <?php include_once ('globals.php'); switch($_GET['page']) { case 'signup': ladder_signup(); break; default: ladder_index(); break; } function ladder_index() { global $ir, $db; if(!isset($_GET['id'])) { echo ' <div class="generalinfo_txt"> <div><img src="images/info_left.jpg" alt="" /></div> <div class="info_mid"><h2 style="padding-top:10px;"> Μάχη για τις πόλεις</h2></div> <div><img src="images/info_right.jpg" alt="" /></div> </div> <div class="generalinfo_simple"><br> <br><br> <a href="battle_ladder.php?page=signup"><b>Κάνε κλίκ για να ξεκινήσεις</b></a><br />Πάρε μέρος στην μάχη για τις πόλεις..<br /> Ο μαφιόζος με το μεγαλύτερο σκορ θα ανακυρηχθεί Μαφιόζος της Πόλης <br /> <br /> <table width=80% cellspacing=1 class="table"><tr style="background: gray; "><th>ID</th> <th>Μάχη</th> <th>Απαιτούμενο Επίπεδο</th> </tr> '; $fetch = $db->query("SELECT * FROM `battle_ladders` ORDER BY `ladderLevel` ASC"); while ($r = $db->fetch_row($fetch)) { $count ++; echo ' <tr><td> '.$count.'. </td><td><a href="battle_ladder.php?id='.$r['ladderId'].'">'.stripslashes($r['ladderName']).'</a></td><td> '.$r['ladderLevel'].' '; } echo '</td></tr></table> </div><div><img src="images/generalinfo_btm.jpg" alt="" /></div><br></div></div></div></div></div>'; } else { $fetch = $db->query(sprintf("SELECT * FROM `battle_members` LEFT JOIN `users` ON `userid` = `bmemberUser` WHERE `bmemberLadder` = '%u' ORDER BY `bmemberScore` DESC", abs((int) $_GET['id']))); if(!$db->num_rows($fetch)) { echo 'Αυτή η μάχη δεν είναι διαθέσιμη αυτή τη στιγμή.'; exit; } else $sql = $db->query(sprintf("SELECT * FROM `battle_ladders` WHERE `ladderId` = '%u'", abs((int) $_GET['id']))); $r = $db->fetch_row($sql); { echo ' <div class="generalinfo_txt"> <div><img src="images/info_left.jpg" alt="" /></div> <div class="info_mid"><h2 style="padding-top:10px;"> '.stripslashes($r['ladderName']).'</h2></div> <div><img src="images/info_right.jpg" alt="" /></div> </div> <div class="generalinfo_simple"><br> <br><br> <table width="600" class="table"> <tr> <th width="10%">Βαθμός</th> <th width="40%">Μαφιόζος</th> <th width="20%">Σκορ</th> <th width="15%">Νίκες</th> <th width="15%">Ήττες</th> </tr>'; while($r = $db->fetch_row($fetch)) { $count ++; echo '<tr> <td align="center">'.$count.'</td> <td><a href="viewuser.php?u='.$r['userid'].'">'.$r['username'].'</a></td> <td>'.number_format($r['bmemberScore']).'</td> <td>'.$r['bmemberWins'].'</td> <td>'.$r['bmemberLosses'].'</td> </tr>'; } } } } print "</table> "; $h->endpage(); exit; function ladder_signup() { global $ir, $db; if(!isset($_GET['id'])) { echo ' <div class="generalinfo_txt"> <div><img src="images/info_left.jpg" alt="" /></div> <div class="info_mid"><h2 style="padding-top:10px;"> Λάβε μέρος σε μάχη</h2></div> <div><img src="images/info_right.jpg" alt="" /></div> </div> <div class="generalinfo_simple"><br> <br><br> Μπορείς να συμμετάσχεις στις παρακάτω μάχες.<br /><br /> <table width="300" class="table"> <tr> <td>'; $fetch = $db->query(sprintf("SELECT * FROM `battle_ladders` WHERE `ladderLevel` <= '%d' ORDER BY `ladderLevel` ASC", $ir['level'])); while ($r = $db->fetch_row($fetch)) { echo '<a href="battle_ladder.php?page=signup&id='.$r['ladderId'].'">'.stripslashes($r['ladderName']).'</a><br />'; } echo '</td> </tr> </table> </div><div><img src="images/generalinfo_btm.jpg" alt="" /></div><br></div></div></div></div></div>'; } else { $check = $db->query(sprintf("SELECT * FROM `battle_members` WHERE `bmemberUser` = '%u'", $ir['userid'])); if($db->num_rows($check)) { echo 'Αυτή τη στιγμή έχεις λάβει μέρος σε άλλη μάχη.'; } else { $sql = $db->query(sprintf("SELECT * FROM `battle_ladders` WHERE `ladderId` = '%u'", abs((int) $_GET['id']))); $r = $db->fetch_row($sql); if($r['ladderLevel'] > $ir['level']) { echo 'Δεν έχεις την απαιτούμενη εμπειρία για να συμμετάσχεις σε αυτή τη μάχη.'; } else { $db->query(sprintf("INSERT INTO `battle_members` (`bmemberId`, `bmemberUser`, `bmemberLadder`, `bmemberScore`) VALUES ('NULL','%u', '%d', '%d')", $ir['userid'], $r['ladderId'], 100)); echo 'Έλαβες μέρος στην μάχη '.stripslashes($r['ladderName']).', κάνε επιθέσεις σε άλλους μαφιόζους για να αυξήσεις το σκόρ σου.'; } } } } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.