Jump to content
MakeWebGames

Damond

Members
  • Posts

    60
  • Joined

  • Last visited

Everything posted by Damond

  1. Ok so I finally figured this out. It was so simple I really can't believe I didn't see it sooner. I didn't use a session because I truly just can't understand how they work. It was the attack page that really set me in the right direction. First step is to add a row to you user table in the data base. For our needs we are going to call it "streeting" (yeah I know thats not a word, but it work.) Make sure you set the default to 0. Next we need a bit of code in your header.   if ($atkpage == 0 && $ir['streeting']==1){ $db->query("UPDATE users SET attacking=0, streeting=0 WHERE userid=$userid"); }   This is going to make sure that if you are not on the attack page everything is set to zero. Next is my streets page. I added this bit of code in the same block as the code that would send you to fight the NPC. It sets streeting to one.   else if($step['reward_type'] == 'npc'){ $db->query("UPDATE users SET streeting=1 WHERE userid=$userid"); $q=$db->query("SELECT cb.*,u.* FROM challengebots cb LEFT JOIN users u ON cb.cb_npcid=u.userid LEFT JOIN cities cy ON u.location=cy.cityid WHERE u.level <= {$ir['level']} ORDER BY u.level desc LIMIT 1"); $s=$db->fetch_row($q); print"While out walking the streets you run into {$s['username']}, they seem to be looking for a fight.<br /> <a href='attack.php?ID={$s['userid']}'>Fight them?</a><br/>"; }   Just a couple of more bits of code in all the attack results files i.e. 'attackwon, attackloss, attackbeat, attacktake'. This makes sure that streeting is set back to zero after an attack. Its placed just in the top of the file.   $db->query("UPDATE users SET attacking=0, streeting=0 WHERE userid=$userid");   And the final piece of code is in the attack.php itself.   if ($ir['streeting'] == 0 && $r['user_level'] == 0) { die ("Cheaters don't get anywhere."); }   You have to make sure and add the && $r['user_level'] == 0 or else you will not be able to attack any other player at all. That does it. The part in the header makes sure that if you change the URL to another page while in an attack on an NPC that streeting is set back to zero anyways. So there is no back out and trying again. Although that would be pointless in the first place as attacking the NPC is the goal. Still I feel it is better to leave no holes.
  2. See this is why I come here. [MENTION=68711]KyleMassacre[/MENTION] That worked exactly how I wanted it too for location. I don't know why I didn't see that to make the change myself. Thank you. Still need to solved the URL change issue though.
  3. OK so I am going to try and be a little more clear about what I want to happen. I know it can be done because I have see the exact same set up in other games. First we have the battle ground. Here you can challenge any of the bots exactly one time for a cash prize if you beat them. You MUST travel to the city that the bot is in to challenge them. Next is streets. Here we want you to run into the bot closest too but not exceeding your level. This issue was solved in another thread to my great satisfaction. This way users can encounter the bots and use them for leveling experience while doing streets. The only issue that I have with it right now is that you MUST be in the right city to fight the bot of your level during your streets. I have tried to change this by adding a little extra to the location code.   else if ($youdata['location'] != $odata['location'] && $r['user_level'] != 0) { print "<div class='box-style7'> <div class='title12'> <h2>You must be in the same location!</h2> </div> <a href='index.php'><button>Back</button></a> </div>";   The problem here is that by adding the && $r['user_level'] != 0 it is allowing you to attack any user for any city. The main goal of this thread was to make it so that my users CAN hit the bot if they come across it in streets, but CAN NOT alter the URL and attack them any ways. I have tried the code KyleMassacre provided.   if($r["user_level"] == 0) { echo "Put something fancy right here"; $h->endpage(); return; }   But no mater where I place it in the attack page while doing my streets I am prevented from attacking the bots. Granted it does stop the changing of the URL, but again it also stops you from being able to attack them during street encounters. I did find a quick way to solve the attack link on the view user page by adding coding so that it will not print the link if it is an NPC.   if ($r['user_level']==0){ print ""; } else { print " [<a href='attack.php?ID={$r['userid']}'>Attack</a>]<br /><br />"; } print " [<a href='contactlist.php?action=add&ID={$r['userid']}'>Add Contact</a>]"; }
  4. I'm still new to this PHP and SQL thing so I wouldn't even know where to start with that one. Any chance of an example?
  5. [MENTION=69001]Zettieee[/MENTION] How is that different from the code I am already using?
  6. I'm sorry but I don't see how that would help. If I queried the challenges beating table and tell it to die if the user has already beaten that bot would that not stop you from being able to attack the same NPC during streets?
  7. So the idea is to prevent users from being able to hit NPCs unless they are using the battle tent or they come across them in streets. I have already created a second attack.php called npc_attack.php and removed the location restriction so that if you come across an NPC in streets that happens to be in another town you can still attack them. The next step I took was to add a bit of code to attack.php to prevent users from attacking NPCs from the view user page.   else if ($r['user_level']==0) { print "<div class='box-style7'> <div class='title12'> <h2>You can only attack NPCs from the battle grounds.</h2> </div> <a href='index.php'><button>Back</button></a> </div>"; $h->endpage(); exit; }   A draw back to this is that I now had to link my battle tent to the new npc_attack.php which means even at the battle tent you can attack any NPC, that you have not already attacked, from any location. The second part of this problem was pointed out to me by a friend. Set up like this a user need only change the URL to include npc_attack.php?ID=(add NPC ID here) and they can attack an NPC as many times as they like from any location. So does anyone know a way that I could keep users from attacking NPCs from the view user page while making it impossible to change a URL and get hits in anyways and while forcing a user to travel to the right town to use the battle tent? I feel like I am chasing myself in circles here.
  8. That worked perfectly. Thank you so much.
  9. Sorry about the code tags I'm new to a forum like this and trying to pick up on all the rules as quickly as I can. I will do my best to remember the code tags next time. So my user level is level 90. There is a bot at level 75 and then the next is at level 101. I should be calling to the level 75 bot until I reach level 101, but right now it is calling to the lowest level bot, that being the level 1 bot of course.
  10. Hello everyone, So I'm fairly new to the PHP and MySQL scene and I know it is just something simple that I am over looking. I am using a version of streets that allows you to attack the NPCs for experience. We have a rank system and want our players to be able to attack only the NPC of equal rank. Here is my query:   else if($step['reward_type'] == 'npc'){ $q=$db->query("SELECT cb.*,u.* FROM challengebots cb LEFT JOIN users u ON cb.cb_npcid=u.userid LEFT JOIN cities cy ON u.location=cy.cityid WHERE u.level <= {$ir['level']} LIMIT 1"); $s=$db->fetch_row($q); print"While out prowling you run into {$s['username']}, they seem to be looking for a fight.<br /> <a href='npc_attack.php?ID={$s['userid']}'>Fight them?</a><br/>"; } For some reason it is always giving you the lowest level NPC not the one closest to your level without going over your level. I added a second attack page called npc_attack.php so that I could take out the location restriction and you could fight any NPC for any town while in your streets. As I said I know it is something simple that I am just over looking, but again I'm really new to using PHP and MySQL. Thanks for any help.
×
×
  • Create New...