Jump to content
MakeWebGames

Battletent.php help?


ddgamedesign

Recommended Posts

Hey all,

I have a battletent.php that is modified a little, but i'm wanting it to only show NPCs that are in the city you're currently in. Right now, i'm in cityid 2, but its still showing NPC's from city 1 (and of course when you click to attack them, it says you can only attack NPCs in the city you're in). I have NPCs in there that are set in city 2 already, so how do I modify this to get it to only display NPCs that are currently in the city you're in?

Code:

<?php
include "globals.php";
print "<center>[img=cenpark.jpg]</center>

<table width=100% cellspacing=1 class='table'><tr style='background: gray; '><th>Opponent Name</th><th>Level</th><th>Location</th><th>Action</th></tr>";
$q=$db->query("SELECT cb.*,u.*,c.npcid,cy.cityname FROM challengebots cb LEFT JOIN users u ON cb.cb_npcid=u.userid LEFT JOIN challengesbeaten c ON c.npcid=u.userid AND c.userid=$userid LEFT JOIN cities cy ON u.location=cy.cityid ORDER BY RAND() LIMIT 5");
while($r=$db->fetch_row($q))
{
$v=$r['userid'];
$q2=$db->query("SELECT count(*) FROM challengesbeaten WHERE npcid=$userid");
$times=$db->fetch_single($q2);
print "<tr><td><center>{$r['username']}</td><td><center>{$r['level']}";
print "</td><td><center>{$r['cityname']}</td><td>";
if($r['npcid'])
{
print "[i]Already[/i]";
}
else
{
print "[url='npcattack.php?ID={$r[']<font color='red'><center>Attack![/url]</font>";
}
print "</td></tr>";
}
print "</table>";
$h->endpage();
?>
Link to comment
Share on other sites

[mysql]$q=$db->query("SELECT cb.*,u.*,c.npcid,cy.cityname FROM challengebots cb LEFT JOIN users u ON cb.cb_npcid=u.userid AND u.location='.$ir['location'].' LEFT JOIN challengesbeaten c ON c.npcid=u.userid AND c.userid=$userid LEFT JOIN cities cy ON u.location=cy.cityid ORDER BY RAND() LIMIT 5");[/mysql]

May wanna edit out the *'s though...

Link to comment
Share on other sites

Got it (sorta) working. added the { } brackets and now it doesn't crash. The thing is, the NPCs have been set to be at Location 2, and i'm at location 2, and it just displays blank spaces. How do I set it so that only NPCs at Location 2 show up in the 5 choices?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...