ddgamedesign Posted April 23, 2010 Share Posted April 23, 2010 Hey all, This is the MySQL query to load users eligible for attack on my 'attacklist' screen: $users = $db->query ( "SELECT u.`userid`, u.`username`, u.`level`, u.`hp`, u.`gang`, u.`location`, g.`gangname`, g.`gangPREF`, c.`cityname` FROM `users` u LEFT JOIN `gangs` g ON `gangID` = u.`gang` LEFT JOIN `cities` c ON c.`cityID` = u.`location` WHERE ( c.`cityID` = ".$ir['location']." ) "); How do I adjust it to NOT show NPC's on this screen? I only want them to show up on my Battle Tent area. Quote Link to comment Share on other sites More sharing options...
furn355 Posted April 23, 2010 Share Posted April 23, 2010 Skip that. Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted April 23, 2010 Author Share Posted April 23, 2010 furn355: meaning? Can anyone actually help with this? I'm sure its something simple. Quote Link to comment Share on other sites More sharing options...
furn355 Posted April 23, 2010 Share Posted April 23, 2010 I wrote it out again demonstrating how to search for NPC's. Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted April 23, 2010 Author Share Posted April 23, 2010 Could you let me know, using that code there, how to skip loading NPC's into the display list for attack? Or is that the right approach? Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted April 23, 2010 Share Posted April 23, 2010 $users = $db->query ( "SELECT u.`userid`, u.`username`, u.`level`, u.`hp`, u.`gang`, u.`location`, g.`gangname`, g.`gangPREF`, c.`cityname` FROM `users` u LEFT JOIN `gangs` g ON `gangID` = u.`gang` LEFT JOIN `cities` c ON c.`cityID` = u.`location` WHERE c.`cityID` = ".$ir['location']." AND `u.user_level` != 0 "); Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted April 23, 2010 Author Share Posted April 23, 2010 AlabamaHit: Thanks, but replacing my line with yours gives MySQL Query errors. Here's the whole file, for info purposes (it was a free mod, so no sweat there): <?php /* * Made By: Djkanna. */ require_once (dirname (__file__) .'/globals.php'); $users = $db->query ( "SELECT u.`userid`, u.`username`, u.`level`, u.`hp`, u.`gang`, u.`location`, g.`gangname`, g.`gangPREF`, c.`cityname` FROM `users` u LEFT JOIN `gangs` g ON `gangID` = u.`gang` LEFT JOIN `cities` c ON c.`cityID` = u.`location` WHERE ( c.`cityID` = ".$ir['location']." ) "); echo' '; ?> <table width="100%" class="table"> <tr> <th>Player</th><th>Status</th><th>Level</th><th>Posse</th><th>Options</th> </tr> <?php while ($u = $db->fetch_row ($users) ) : ?> <tr> <td><?php echo $u['gang'] != 0 ? "[".$u['gangPREF']."]".stripslashes(htmlentities($u['username'], ENT_QUOTES)) : "".stripslashes(htmlentities($u['username'], ENT_QUOTES)); ?></td> <td><?php echo $u['hp'] <= 1 ? "<span style='font-color: red;'>Unconscious</span>" : "<span style='font-color: green;'>Alive</span>"; ?></td> <td><?php echo number_format($u['level']); ?></td> <td><?php echo $u['gang'] != 0 ? "".stripslashes(htmlentities($u['gangname'], ENT_QUOTES))."" : "<span>No Posse</span>"; ?></td> <td><?php echo $u['hp'] <= 1 ? "<span style='font-color: #999; text-decoration: line-through;'>Attack</span>" : "<span style='font-color: red;'>Attack!</span>"; ?></td> </tr> <?php endwhile; ?> </table> <?php $h->endpage (); ?> Quote Link to comment Share on other sites More sharing options...
AlabamaHit Posted April 23, 2010 Share Posted April 23, 2010 Probary a typo, i do that all the time. Try this $users = $db->query ( "SELECT u.`userid`, u.`username`, u.`level`, u.`hp`, u.`gang`, u.`location`, g.`gangname`, g.`gangPREF`, c.`cityname` FROM `users` u LEFT JOIN `gangs` g ON `gangID` = u.`gang` LEFT JOIN `cities` c ON c.`cityID` = u.`location` WHERE c.`cityID` = ".$ir['location']." AND u.`user_level` != 0 "); Quote Link to comment Share on other sites More sharing options...
Djkanna Posted April 23, 2010 Share Posted April 23, 2010 Edit: Sorry didn't see AlabamaHits post ^^ <?php /* * Made By: Djkanna. */ require_once (dirname (__file__) .'/globals.php'); $users = $db->query ( "SELECT u.`userid`, u.`username`, u.`level`, u.`hp`, u.`gang`, u.`location`, g.`gangname`, g.`gangPREF`, c.`cityname` FROM `users` u LEFT JOIN `gangs` g ON `gangID` = u.`gang` LEFT JOIN `cities` c ON c.`cityID` = u.`location` WHERE ( c.`cityID` = ".$ir['location']." && u.`user_level` != 0 ) "); echo'[img=/pickafight.jpg] '; ?> <table width="100%" class="table"> <tr> <th>Player</th><th>Status</th><th>Level</th><th>Posse</th><th>Options</th> </tr> <?php while ($u = $db->fetch_row ($users) ) : ?> <tr> <td><?php echo $u['gang'] != 0 ? "[".$u['gangPREF']."]".stripslashes(htmlentities($u['username'], ENT_QUOTES)) : "".stripslashes(htmlentities($u['username'], ENT_QUOTES)); ?></td> <td><?php echo $u['hp'] <= 1 ? "<span style='font-color: red;'>Unconscious</span>" : "<span style='font-color: green;'>Alive</span>"; ?></td> <td><?php echo number_format($u['level']); ?></td> <td><?php echo $u['gang'] != 0 ? "[url='gangs.php?action=view&ID=".$u[']".stripslashes(htmlentities($u['gangname'], ENT_QUOTES))."[/url]" : "<span>No Posse</span>"; ?></td> <td><?php echo $u['hp'] <= 1 ? "<span style='font-color: #999; text-decoration: line-through;'>Attack</span>" : "[url='attack.php?ID=".$u[']<span style='font-color: red;'>Attack!</span>[/url]"; ?></td> </tr> <?php endwhile; ?> </table> <?php $h->endpage (); ?> Try that. Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted April 23, 2010 Author Share Posted April 23, 2010 Works perfectly, both of you. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted April 23, 2010 Author Share Posted April 23, 2010 Actually related to the NPC thing: I'm using the default Battle Tent, McCodes V2. How do I randomly load 5 NPC's to fight everytime the battletent.php is loaded? Is there a fairly simple way to do this? Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted April 23, 2010 Author Share Posted April 23, 2010 Never mind, got this figured out. 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.