BluroSoft Posted January 26, 2013 Share Posted January 26, 2013 Okay basically some of my top players have their stats over 19486372424599998562304+ when they attack a player their max damage is around 1-2 even low level players can beat them up. One player reported with a crap item he can hit quite good but with top items he can not if someone can help me identify and resolve this error it will be great. $_SESSION['attacking'] = 1; $ir['attacking'] = $odata['userid']; $db->query("UPDATE users SET attacking={$ir['attacking']} WHERE userid=$userid"); $_GET['wepid'] = (int)$_GET['wepid']; $_GET['nextstep'] = (int)$_GET['nextstep']; //damage if ($youdata['location'] != $odata['location']) { print "You can only attack someone in the same location! <br /><a data-role='button' data-rel='back' href='index.php'>Back</a>"; $db->query("UPDATE users SET attacking=0 WHERE userid=$userid"); $h->endpage(); exit; } if ($_GET['wepid'] != $ir['equip_primary'] && $_GET['wepid'] != $ir['equip_secondary']) { print "Stop trying to abuse a game bug. You can lose all your EXP for that.<br /> <a href='index.php'>> Home</a>"; $db->query("UPDATE users SET exp=0 where userid=$userid", $c); die(""); } $qo = $db->query("SELECT i.* FROM items i WHERE i.itmid={$_GET['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); } elseif ($mydamage < 1) { $mydamage = 1; } $crit = rand(1, 40); if ($crit == 17) { $mydamage *= rand(20, 40) / 10; } elseif ($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={$_GET['ID']}"); print "<font color=red>{$_GET['nextstep']}. Using your {$r1['itmname']} you hit {$odata['username']} doing $mydamage damage ({$odata['hp']})</font><br />\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><br />\n"; } else { print "<font color=red>{$_GET['nextstep']}. You tried to hit {$odata['username']} but missed ({$odata['hp']})</font><br />\n"; $_SESSION['attacklog'] .= "<font color=red>{$_GET['nextstep']}. {$ir['username']} tried to hit {$odata['username']} but missed ({$odata['hp']})</font><br />\n"; } if ($odata['hp'] <= 0) { $odata['hp'] = 0; $_SESSION['attackwon'] = $_GET['ID']; $db->query("UPDATE users SET hp=0 WHERE userid={$_GET['ID']}"); print "<br /> <b>What do you want to do with {$odata['username']} now?</b><br /> <form action='attackwon.php?ID={$_GET['ID']}' method='post'><input type='submit' value='Steal Money' /></form> <form action='attackcry.php?ID={$_GET['ID']}' method='post'><input type='submit' value='Steal Crystals' /></form> <form action='attackbeat.php?ID={$_GET['ID']}' method='post'><input type='submit' value='Leave at Hospital' /></form> <form action='attacktake.php?ID={$_GET['ID']}' method='post'><input type='submit' value='Leave For Exp' /></form>"; /*<form action='attackbomb.php?ID={$_GET['ID']}' method='post'><input type='submit' value='Leave Them & Bomb (cost $20,000)' /></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); } elseif ($dam < 1) { $dam = 1; } $crit = rand(1, 40); if ($crit == 17) { $dam *= rand(20, 40) / 10; } elseif ($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 = $_GET['nextstep'] + 1; print "<font color=blue>{$ns}. Using $oabbr $wep {$odata['username']} hit you doing $dam damage ({$youdata['hp']})</font><br />\n"; $_SESSION['attacklog'] .= "<font color=blue>{$ns}. Using $oabbr $wep {$odata['username']} hit {$ir['username']} doing $dam damage ({$youdata['hp']}hp left)</font><br />\n"; } else { $ns = $_GET['nextstep'] + 1; print "<font color=red>{$ns}. {$odata['username']} tried to hit you but missed ({$youdata['hp']}hp left)</font><br />\n"; $_SESSION['attacklog'] .= "<font color=blue>{$ns}. {$odata['username']} tried to hit {$ir['username']} but missed ({$youdata['hp']})</font><br />\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' />"; } } } elseif ($odata['hp'] < 5) { print "You can only attack those who have health<a data-role='button' data-rel='back' href='index.php'>Back</a>"; $h->endpage(); exit; } elseif ($ir['gang'] == $odata['gang'] && $ir['gang'] > 0) { print "You are in the same gang as {$odata['username']}! What are you smoking today dude!<a data-role='button' data-rel='back' href='index.php'>Back</a>"; $h->endpage(); exit; } elseif ($youdata['energy'] < $youdata['maxenergy'] / 2) { print "You can only attack someone when you have 50% energy<a data-role='button' data-rel='back' href='index.php'>Back</a>"; $h->endpage(); exit; } elseif ($youdata['location'] != $odata['location']) { print "You can only attack someone in the same location!<a data-role='button' data-rel='back' href='index.php'>Back</a>"; $h->endpage(); exit; } else { } print "</td></tr></table>"; if ($youdata['hp'] <= 0 || $odata['hp'] <= 0) { print ""; } 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 "<div class='attackbox'>Attack with:<br /><br />"; if ($db->num_rows($mw) > 0) { while ($r = $db->fetch_row($mw)) { if (!$_GET['nextstep']) { $ns = 1; } else { $ns = $_GET['nextstep'] + 2; } Quote Link to comment Share on other sites More sharing options...
Someone Posted January 26, 2013 Share Posted January 26, 2013 Seems like you are running into the max int size in PHP. See http://stackoverflow.com/questions/670662/whats-the-maximum-size-for-an-int-in-php The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, and maximum value using the constant PHP_INT_MAX since PHP 4.4.0 and PHP 5.0.5. Quote Link to comment Share on other sites More sharing options...
Razor42 Posted January 26, 2013 Share Posted January 26, 2013 Why are there stats so large anyway? Quote Link to comment Share on other sites More sharing options...
Someone Posted January 26, 2013 Share Posted January 26, 2013 (edited) Yes thats a valid question as well. Unless it has been running for a very long time and/or they get a lot of stats every time they train, I suspect some exploiting going on. Also, is the database column stat field an unsigned number, will not help here, but it should be unsigned (the number will never be less than 0, allows storing bigger number in the database). Something to experiment with for a work around. If the problem is only when doing math with the big numbers. Divide the stats by 1000 (or something) before using them. Something like // do for each stat $ir['agility'] = ($ir['agility'] / 1000); if($ir['agility'] < 1){ //In case the player has a stat less than 1000 $ir['agility'] = 1; } Edited January 26, 2013 by Someone wrong in code sample Quote Link to comment Share on other sites More sharing options...
Razor42 Posted January 26, 2013 Share Posted January 26, 2013 Iv played games that have been open for 4 years and still no where near stats at that level 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.