parelem Posted February 17, 2008 Posted February 17, 2008 Today a few of my users have told me they are running into a problem attacking. When they attack anyone, and require more than one hit, they lose all of their energy and some experience. They also get "You can only attack someone when you have 50% energy," only a few users are having this problem, while attacking works perfectly fine for everyone else. I should also note, I have no changed anything in my attack system in a few months. Any ideas? Quote
erus Posted February 18, 2008 Posted February 18, 2008 Re: Odd attack problem I also have this problem on mine. but the users start the attack then get the message at the top stating that they have lost ALL thier exp because they ran from the fight also the if they did fight to the end they gained 0 exp Quote
ignite Posted February 22, 2008 Posted February 22, 2008 Re: Odd attack problem Find in header.php if($dosessh && $_SESSION['attacking']) Replace with: if($dosessh && $_SESSION['attacking'] && $ir['attacking']) Quote
parelem Posted February 26, 2008 Author Posted February 26, 2008 Re: Odd attack problem no, that doesn't solve the problem. users are still getting this Quote
Godhand Posted February 26, 2008 Posted February 26, 2008 Re: Odd attack problem I doubt you have a legal version of mccodes. ^_^ Quote
parelem Posted February 26, 2008 Author Posted February 26, 2008 Re: Odd attack problem i don't have a legal version because there is a problem with the codes? that logic is amazing, i guess no one has a legal copy of the codes then. this is a real problem with the codes, I've seen it on other games as well and there's nothing in the code that would indicate WHY it happens so it isn't an easy fix. Quote
Godhand Posted February 26, 2008 Posted February 26, 2008 Re: Odd attack problem That is because it was coded poorly. It does not happen in mine. Quote
erus Posted February 27, 2008 Posted February 27, 2008 Re: Odd attack problem Have i got a legal version hmmmm i think i have as i got it from mccodes.com lol kept the paypal ticket too but still got the error so i just scraped the exp gain formula and made my own lol Quote
Godhand Posted February 27, 2008 Posted February 27, 2008 Re: Odd attack problem Your problem is with you not setting $session to what it is supposed to be after the fight. If you are interested in being a game owner I suggest you learn how to fix it with what I have told you. Also if you have stalemates set you will have to be sure to set it to the right value. Quote
parelem Posted February 27, 2008 Author Posted February 27, 2008 Re: Odd attack problem what's happening is NOT happening AFTER the fight, it is DURING the fight. They never make it to the end, it happens on the second or third hit. i fixed the sessions problems long ago. Quote
Godhand Posted February 27, 2008 Posted February 27, 2008 Re: Odd attack problem You still have it coded wrong.... Make sure you run a test to tell if it is the first step or not. As for why I am saying that that has to be the problem.... It doesn't happen in my game..... Quote
parelem Posted February 27, 2008 Author Posted February 27, 2008 Re: Odd attack problem it wasn't happening to me either until a few day days ago, and it only happens to a few people, during some of their attacks. Quote
Godhand Posted February 27, 2008 Posted February 27, 2008 Re: Odd attack problem let me see your attack.php. I'll look it over. Quote
parelem Posted February 29, 2008 Author Posted February 29, 2008 Re: Odd attack problem here's my attack file, minus my html/css i still can't find what's wrong the sceenshot in the first post is exactly what's happening to users <?php $menuhide=1; $atkpage=1; include "globals.php"; $_GET['ID'] == (int) $_GET['ID']; $id = ($_GET['ID']); if(!$id) { print "WTF you doing, bro?"; $h->endpage(); exit; } else if($id == $userid) { print "Only the crazy attack themselves."; $h->endpage(); exit; } else if ($ir['hp'] <= 1) { print "Only the crazy attack when their unconscious. [url='index.php']Back[/url]"; $h->endpage(); exit; } else if ($_SESSION['attacklost'] == 1) { print "Only the losers of all their EXP attack when they've already lost. [url='index.php']Back[/url]"; $_SESSION['attacklost']=0; $h->endpage(); exit; } //get player data $youdata=$ir; $q=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid={$id}"); $odata=$db->fetch_row($q); $myabbr=($ir['gender']=="Male") ? "his" : "her"; $oabbr=($ir['gender']=="Male") ? "his" : "her"; if($ir['attacking'] && $ir['attacking'] != $_GET['ID']) { print "Bad, bad, bad girl. [url='index.php']Back[/url]"; $_SESSION['attacklost']=0; $h->endpage(); exit; } if($odata['hp'] == 1) { print "This player is unconscious. [url='index.php']> Back[/url]"; $h->endpage(); $_SESSION['attacking']=0; $ir['attacking']=0; $db->query("UPDATE users SET attacking=0 WHERE userid=$userid"); exit; } else if($odata['hospital']) { print "This player is in hospital. [url='index.php']> Back[/url]"; $h->endpage(); $_SESSION['attacking']=0; $ir['attacking']=0; $db->query("UPDATE users SET attacking=0 WHERE userid=$userid"); exit; } else if($ir['hospital']) { print "While in hospital you can't attack. [url='hospital.php']> Back[/url]"; $h->endpage(); $_SESSION['attacking']=0; $ir['attacking']=0; $db->query("UPDATE users SET attacking=0 WHERE userid=$userid"); exit; } else if($odata['jail']) { print "This player is in jail. [url='index.php']> Back[/url]"; $h->endpage(); $_SESSION['attacking']=0; $ir['attacking']=0; $db->query("UPDATE users SET attacking=0 WHERE userid=$userid"); exit; } else if($ir['jail']) { print "While in jail you can't attack. [url='jail.php']> Back[/url]"; $h->endpage(); $_SESSION['attacking']=0; $ir['attacking']=0; $db->query("UPDATE users SET attacking=0 WHERE userid=$userid"); exit; } else if($odata['travelling']) { print "That player is travelling. [url='index.php']> Back[/url]"; $h->endpage(); $_SESSION['attacking']=0; $ir['attacking']=0; $db->query("UPDATE users SET attacking=0 WHERE userid=$userid"); exit; } print "<table width=100%><tr><td colspan=2 align=center>"; if($_GET['wepid']) { if($_SESSION['attacking']==0 && $ir['attacking'] == 0) { if ($youdata['energy'] >= $youdata['maxenergy']/2) { $youdata['energy']-= floor($youdata['maxenergy']/2); $me=floor($youdata['maxenergy']/2); $db->query("UPDATE users SET energy=energy- {$me} WHERE userid=$userid"); $_SESSION['attacklog']=""; $_SESSION['attackdmg']=0; } else { print "You can only attack someone when you have 50% energy"; $h->endpage(); exit; } } $_SESSION['attacking']=1; $ir['attacking']=$odata['userid']; $db->query("UPDATE users SET attacking={$ir['attacking']} WHERE userid=$userid"); $_GET['wepid'] = (int) $_GET['wepid']; $wepid = ($_GET['wepid']); $_GET['nextstep'] = (int) $_GET['nextstep']; $nextstep = ($_GET['nextstep']); //damage $qo=$db->query("SELECT i.* FROM items i WHERE i.itmid={$wepid}"); $r1=$db->fetch_row($qo); $mydamage=(int) (($r1['weapon']*$youdata['strength']/($odata['guard']/1.5))*(rand(8000,12000)/10000)); $hitratio=max(10,min(60*$ir['agility']/$odata['agility'],95)); if(rand(1,100) <= $hitratio ) { $q3=$db->query("SELECT i.armor FROM items i WHERE itmid={$odata['equip_armor']} ORDER BY rand()"); if($db->num_rows($q3)) { $mydamage-=$db->fetch_single($q3); } if($mydamage < -100000) { $mydamage=abs($mydamage); } else if($mydamage < 1) { $mydamage=1; } $crit=rand(1,40); if($crit==17) { $mydamage*=rand(20,40)/10; } else if($crit==25 or $crit == 8) { $mydamage/=(rand(20,40)/10); } $mydamage=round($mydamage); $odata['hp']-=$mydamage; if($odata['hp']==1) { $odata['hp']=0;$mydamage+=1; } $db->query("UPDATE users SET hp=hp-$mydamage WHERE userid={$id}"); print "<font color=red>{$_GET['nextstep']}. Using your {$r1['itmname']} you hit {$odata['username']} doing $mydamage damage ({$odata['hp']})</font> \n"; $_SESSION['attackdmg']+=$mydamage; $_SESSION['attacklog'].="<font color=red>{$_GET['nextstep']}. Using {$myabbr} {$r1['itmname']} {$ir['username']} hit {$odata['username']} doing $mydamage damage ({$odata['hp']})</font> \n"; } else { print "<font color=red>{$nextstep}. You tried to hit {$odata['username']} but missed ({$odata['hp']})</font> \n"; $_SESSION['attacklog'].="<font color=red>{$_GET['nextstep']}. {$ir['username']} tried to hit {$odata['username']} but missed ({$odata['hp']})</font> \n"; } if($odata['hp'] <= 0) { $odata['hp']=0; $_SESSION['attackwon']=$_GET['ID']; $db->query("UPDATE users SET hp=0 WHERE userid={$id}"); print " [b]What do you want to do with {$odata['username']} now?[/b] <form action='attackwon.php?ID={$id}' method='post'><input type='submit' value='Mug Them' /></form> <form action='attackbeat.php?ID={$id}' method='post'><input type='submit' value='Hospitalize Them' /></form> <form action='attacktake.php?ID={$id}' method='post'><input type='submit' value='Leave Them' /></form>"; $dert=mysql_query("SELECT * FROM ladder WHERE ladderID=$userid",$c); $you=mysql_fetch_array($dert); $dert=mysql_query("SELECT * FROM ladder WHERE ladderID={$odata['userid']}",$c); $them=mysql_fetch_array($dert); if($you && $them) { print" <form action='ladderwin.php?ID={$_GET['ID']}' method='post'><input type='submit' value='Ladder Attack Them' /></form>"; } } else { //choose opp gun $eq=$db->query("SELECT i.* FROM items i WHERE i.itmid IN({$odata['equip_primary']}, {$odata['equip_secondary']})"); if(mysql_num_rows($eq) == 0) { $wep="Fists"; $dam=(int)((((int) ($odata['strength']/$ir['guard']/100)) +1)*(rand(8000,12000)/10000)); } else { $cnt=0; while($r=$db->fetch_row($eq)) { $enweps[]=$r; $cnt++; } $weptouse=rand(0,$cnt-1); $wep=$enweps[$weptouse]['itmname']; $dam=(int) (($enweps[$weptouse]['weapon']*$odata['strength']/($youdata['guard']/1.5))*(rand(8000,12000)/10000)); } $hitratio=max(10,min(60*$odata['agility']/$ir['agility'],95)); if(rand(1,100) <= $hitratio) { $q3=$db->query("SELECT i.armor FROM items i WHERE itmid={$ir['equip_armor']} ORDER BY rand()"); if($db->num_rows($q3)) { $dam-=$db->fetch_single($q3); } if($dam < -100000) { $dam=abs($dam); } else if($dam < 1) { $dam=1; } $crit=rand(1,40); if($crit==17) { $dam*=rand(20,40)/10; } else if($crit==25 or $crit == 8) { $dam/=(rand(20,40)/10); } $dam=round($dam); $youdata['hp']-=$dam; if ($youdata['hp']==1) { $dam+=1; $youdata['hp']=0; } $db->query("UPDATE users SET hp=hp-$dam WHERE userid=$userid"); $ns=$nextstep+1; print "<font color=blue>{$ns}. Using $oabbr $wep {$odata['username']} hit you doing $dam damage ({$youdata['hp']})</font> \n"; $_SESSION['attacklog'].="<font color=blue>{$ns}. Using $oabbr $wep {$odata['username']} hit {$ir['username']} doing $dam damage ({$youdata['hp']})</font> \n"; } else { $ns=$nextstep+1; print "<font color=red>{$ns}. {$odata['username']} tried to hit you but missed ({$youdata['hp']})</font> \n"; $_SESSION['attacklog'].="<font color=blue>{$ns}. {$odata['username']} tried to hit {$ir['username']} but missed ({$youdata['hp']})</font> \n"; } if($youdata['hp'] <= 0) { $youdata['hp']=0; $_SESSION['attacklost']=1; $db->query("UPDATE users SET hp=0 WHERE userid=$userid"); print "<form action='attacklost.php?ID={$_GET['ID']}' method='post'><input type='submit' value='Continue' />"; } } } else if ($odata['hp'] < 5) { print "You can only attack those who have health"; $h->endpage(); exit; } else if ($ir['gang'] == $odata['gang'] && $ir['gang'] > 0) { print "You are in the same gang as {$odata['username']}! What are you smoking today dude!"; $h->endpage(); exit; } else if($odata['hospital']) { print "You cannot attack someone that's in the hospital"; } else if ($odata['userid'] == 2 || $odata['userid'] == 1 || $odata['userid'] == 3 || $odata['userid'] == 19) { print "You cannot attack me, I am owner and/or non playing staff!"; $h->endpage(); exit; } else if ($youdata['energy'] < $youdata['maxenergy']/2) { print "You can only attack someone when you have 50% energy"; $h->endpage(); exit; } else if ($youdata['location'] != $odata['location']) { print "You can only attack someone in the same location!"; $h->endpage(); exit; } else { } print "</td></tr>"; if($youdata['hp'] <= 0 || $odata['hp'] <= 0) { print "</table>"; } else { $vars['hpperc']=round($youdata['hp']/$youdata['maxhp']*100); $vars['hpopp']=100-$vars['hpperc']; $vars2['hpperc']=round($odata['hp']/$odata['maxhp']*100); $vars2['hpopp']=100-$vars2['hpperc']; $mw=$db->query("SELECT i.* FROM items i WHERE i.itmid IN({$ir['equip_primary']}, {$ir['equip_secondary']})"); print "<tr><td colspan=2 align='center'>Attack with: "; if($db->num_rows($mw) > 0) { while($r=$db->fetch_row($mw)) { if($odata['hospital'] || $odata['hp'] == 0) { $h->endpage(); print" You cannot attack someone in the hospital or with no health , nice try cheater"; exit; } if(!$nextstep) { $ns=1; } else { $ns=$nextstep+2; } if($r['itmid']==$ir['equip_primary']) { print "[b]Primary Weapon:[/b] "; } if($r['itmid']==$ir['equip_secondary']) { print "[b]Secondary Weapon:[/b] "; } print "[url='attack.php?nextstep=$ns&ID={$id}&wepid={$r[']{$r['itmname']}[/url] "; } } else { print "[url='attack.php?nextstep=$ns&ID={$id}&wepid=1']fists[/url] "; } print "</table>"; print "<table width='50%' align='center'><tr><td align=right>Your Health: </td><td><img src=greenbar.png width={$vars['hpperc']} height=10><img src=redbar.png width={$vars['hpopp']} height=10></td><tr><td align=right>Opponents Health: </td><td><img src=greenbar.png width={$vars2['hpperc']} height=10><img src=redbar.png width={$vars2['hpopp']} height=10></td></tr></table>"; } $h->endpage(); ?> Quote
Blackdogg Posted April 7, 2008 Posted April 7, 2008 Re: Odd attack problem I would be really interested to see if anyone knows how to fix this as I am struggling with this problem as well. Quote
KDawg08 Posted April 20, 2008 Posted April 20, 2008 Re: Odd attack problem One day they will finally smack around the coders and members in here that are always saying stupid shit like... "I DOUBT YOU HAVE A LEGAL VERSION" It's ridiculous to assume shit that you can't prove... Before making those kind of judgments maybe you should grow the hell up and learn to ASK people or FIND PROOF before you trash talk about someones game not being legal. I've had a few of you pull it on me but I have a legal copy and I've proven it to a few people. I still have the receipts from buying it. So don't go judging someones game about legalities until you have the proof to show it's not legal. Quote
Dave Posted June 15, 2008 Posted June 15, 2008 Re: Odd attack problem I think this is the problem of that everytime the user uses there weapon or attack turn it takes 50% energy so after 2 hits your out i remember this happened on my old game. Ill see if i can work out a fix Quote
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.