jon182 Posted August 7, 2009 Share Posted August 7, 2009 ok the first time people attack it takes away energy but after that they can attack several times andnot lose any energy. i was wondering if anyone knows why off the top of thier head. atatck.php <?php $menuhide = 1; $atkpage = 1; include(DIRNAME(__FILE__) . '/globals.php'); $_GET['ID'] = abs(@intval($_GET['ID'])); if(!$_GET['ID']) { echo "WTF you doing, bro?"; $h->endpage(); exit; } if($_GET['ID'] == $userid) { echo "Only the crazy attack themselves."; $h->endpage(); exit; } if($ir['hp'] <= 1) { echo "Only the crazy attack when their unconscious. [url='index.php']Back[/url]"; $h->endpage(); exit; } if(isset($_SESSION['attacklost'])) { echo "Only the losers of all their EXP attack when they've already lost. [url='index.php']Back[/url]"; unset($_SESSION['attacklost']); $h->endpage(); exit; } //get player data $youdata = $ir; $sql = sprintf( "SELECT u.*, us.* " . "FROM users u " . "LEFT JOIN userstats us ON (u.userid = us.userid) " . "WHERE (u.userid = %u)", $_GET['ID']); $q = $db->query($sql); if(!$db->num_rows($q)) { echo "User does not exist!"; $h->endpage(); exit; } $youdata=$ir; $q=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid={$_GET['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]"; unset($_SESSION['attacklost']); $h->endpage(); exit; } if($odata['hp'] == 1) { echo "This player is unconscious. [url='index.php']> Back[/url]"; $h->endpage(); unset($_SESSION['attacking']); unset($ir['attacking']); $update = sprintf("UPDATE users SET attacking = 0 WHERE (userid = %u)", $userid); $db->query($update); exit; } if($odata['hospital']) { echo "This player is in hospital. [url='index.php']> Back[/url]"; $h->endpage(); unset($_SESSION['attacking']); unset($ir['attacking']); $update = sprintf("UPDATE users SET attacking = 0 WHERE (userid = %u)", $userid); $db->query($update); exit; } else if($ir['hospital']) { echo "While in hospital you can't attack. [url='hospital.php']> Back[/url]"; $h->endpage(); unset($_SESSION['attacking']); unset($ir['attacking']); $update = sprintf("UPDATE users SET attacking = 0 WHERE (userid = %u)", $userid); $db->query($update); exit; } else if($odata['jail']) { echo "This player is in jail. [url='index.php']> Back[/url]"; $h->endpage(); unset($_SESSION['attacking']); unset($ir['attacking']); $update = sprintf("UPDATE users SET attacking = 0 WHERE (userid = %u)", $userid); $db->query($update); exit; } else if($ir['jail']) { echo "While in jail you can't attack. [url='jail.php']> Back[/url]"; $h->endpage(); unset($_SESSION['attacking']); unset($ir['attacking']); $update = sprintf("UPDATE users SET attacking = 0 WHERE (userid = %u)", $userid); $db->query($update); exit; } echo "<table width='100%'>"; echo "<tr>"; echo "<td colspan='2' align='center'>"; if(isset($_GET['wepid'])) { if(!isset($_SESSION['attacking']) && !$ir['attacking']) { if($youdata['energy'] >= $youdata['maxenergy']/4) { $youdata['energy']-= floor($youdata['maxenergy']/4); $me = floor($youdata['maxenergy']/4); $energy = sprintf("UPDATE users SET energy = energy - %u WHERE (userid = %u)", $me, $userid); $db->query($energy); $_SESSION['attacklog'] = false; $_SESSION['attackdmg'] = 0; } else { echo "You can only attack someone when you have 25% energy"; $h->endpage(); exit; } } $_SESSION['attacking'] = 1; $ir['attacking'] = $odata['userid']; $attacking = sprintf("UPDATE users SET attacking = %u WHERE (userid = %u)", $ir['attacking'], $userid); $db->query($attacking); $_GET['wepid'] = abs(@intval($_GET['wepid'])); $_GET['nextstep'] = abs(@intval($_GET['nextstep'])); //damage if($_GET['wepid'] != $ir['equip_primary'] && $_GET['wepid'] != $ir['equip_secondary']) { echo "Stop trying to abuse a game bug. You can lose all your EXP for that. [url='index.php']> Home[/url]"; $noexp = sprintf("UPDATE users SET exp = 0 WHERE (userid = %u)", $userid); $db->query($noexp); $h->endpage(); exit; } $item = sprintf("SELECT * FROM items WHERE (itmid = %u)", $_GET['wepid']); $qo = $db->query($item); $r1 = $db->fetch_row($qo); $hit = mt_rand(70,75); switch ($hit) { case 70: $hitspot = 'Legs'; $img= '/home2/respect/public_html/legs.jpg'; break; case 71: $hitspot = 'Arm'; $img= '/home2/respect/public_html/arms.jpg'; break; case 72: $hitspot = 'Groin'; $img= '/home2/respect/public_html/groin.jpg'; break; case 73: $hitspot = 'Torso'; $img= '/home2/respect/public_html/torso.jpg'; break; case 74: $hitspot = 'Heart'; $img= '/home2/respect/public_html/heart.jpg'; break; case 75: $hitspot = 'Head'; $img= '/home2/respect/public_html/head.jpg'; } $mydamage = (int) (($r1['weapon'] * ($youdata['strength'] / ($odata['guard']) / 1.5)) * (mt_rand(8000,12000) / 10000) * (($hit * .015) * $youdata['will'] / $youdata['maxwill'] * 50 / $odata['will'] * $odata['maxwill'] * 100 / 2.5)/1000); $hitratio = max(10, min(60 * $ir['agility'] / $odata['agility'], 95)); if(mt_rand(1,100) <= $hitratio) { $armour = sprintf("SELECT armor FROM items WHERE (itmid = %u) ORDER BY RAND()", $odata['equip_armor']); $q3 = $db->query($armour); if($db->num_rows($q3)) { $mydamage -= $db->fetch_single($q3); } if($mydamage < -100000) { $mydamage = abs($mydamage); } else if($mydamage < 1) { $mydamage = 1; } $crit = mt_rand(1,40); if($crit == 17) { $mydamage *= mt_rand(20,40) / 10; } else if($crit == 25) { $mydamage /= (mt_rand(20,40) / 10); } $mydamage = round($mydamage); $odata['hp'] -= $mydamage; if($odata['hp'] == 1) { $odata['hp'] = 0; $mydamage += 1; } $updatehp = sprintf("UPDATE users SET hp = hp - %u WHERE (userid = %u)", $mydamage, $_GET['ID']); $db->query($updatehp); echo sprintf("[img=%s]", $img, $set['game_name']); echo sprintf("<span style='color:red;'>%u. Using your %s, you hit %s in the %s doing %s damage (%s)</span> ", $_GET['nextstep'], stripslashes($r1['itmname']), stripslashes($odata['username']), $hitspot, number_format($mydamage), number_format($odata['hp'])); $_SESSION['attackdmg'] += $mydamage; $_SESSION['attacklog'] .= sprintf("<span style='color:red;'>%u. Using %s %s, %s hit %s in the %s doing %s damage (%s)</span> ", $_GET['nextstep'], $myabbr, $r1['itmname'], $ir['username'], $odata['username'], $hitspot, number_format($mydamage), number_format($odata['hp'])); } else { echo sprintf("<span style='color:red;'>%u. You tried to hit %s in the %s, but missed (%s)</span> ", $_GET['nextstep'], stripslashes($odata['username']), $hitspot, number_format($odata['hp'])); $_SESSION['attacklog'] .= sprintf("<span style='color:red;'>%u. %s tried to hit %s in the %s, but missed (%s)</span> ", $_GET['nextstep'], $ir['username'], $odata['username'], $hitspot, number_format($odata['hp'])); } if($odata['hp'] <= 0) { $odata['hp'] = 0; $_SESSION['attackwon'] = $_GET['ID']; $nohp = sprintf("UPDATE users SET hp = 0 WHERE (userid = %u)", $_GET['ID']); $db->query($nohp); echo sprintf(" [b]What do you want to do with %s now?[/b] ", stripslashes($odata['username'])); echo sprintf("<form action='attackwon.php?ID=%u' method='post'><input type='submit' value='Mug Them' align='center' /></form>", $_GET['ID']); echo sprintf("<form action='attackbeat.php?ID=%u' method='post'><input type='submit' value='Hospitalize Them' align='center' /></form>", $_GET['ID']); echo sprintf("<form action='attacktake.php?ID=%u' method='post'><input type='submit' value='Leave Them'align='center' /></form>", $_GET['ID']); } else { //choose opp gun $getweapon = sprintf("SELECT * FROM items WHERE (itmid IN(%u, %u))", $odata['equip_primary'], $odata['equip_secondary']); $eq = $db->query($getweapon); if(!$db->num_rows($eq)) { $wep = "Fists"; $dam = (int)((((($odata['strength'] / $ir['guard']) / 100)) + 1) * (mt_rand(8000,12000) / 10000)* (($hit * .015) * $odata['will'] / $odata['maxwill'] * 50 / $youdata['will'] * $youdata['maxwill'] * 100 / 2.5)); } else { $cnt = 0; while($r = $db->fetch_row($eq)) { $enweps[] = $r; $cnt ++; } $weptouse = mt_rand(0, $cnt-1); $wep = $enweps[$weptouse]['itmname']; $dam = (int) (($enweps[$weptouse]['weapon'] * ($odata['strength'] / ($youdata['guard']) / 1.5)) * (mt_rand(8000,12000) / 10000)* (($hit * .015) * $odata['will'] / $odata['maxwill'] * 50 / $youdata['will'] * $youdata['maxwill'] * 100 / 2.5)/1000); } $hitratio = max(10, min(60 * $odata['agility'] / $ir['agility'], 95)); if(mt_rand(1,100) <= $hitratio) { $getarmour = sprintf("SELECT armor FROM items WHERE (itmid = %u) ORDER BY RAND()", $ir['equip_armor']); $q3 = $db->query($getarmour); if($db->num_rows($q3)) { $dam -= $db->fetch_single($q3); } if($dam < -100000) { $dam = abs($dam); } else if($dam < 1) { $dam = 1; } $crit = mt_rand(1,40); if($crit == 17) { $dam *= mt_rand(20,40) / 10; } else if($crit == 25) { $dam /= (mt_rand(20,40) / 10); } $dam = round($dam); $youdata['hp'] -= $dam; if($youdata['hp'] == 1) { $dam += 1; $youdata['hp'] = 0; } $takehp = sprintf("UPDATE users SET hp = hp - %u WHERE (userid = %u)", $dam, $userid); $db->query($takehp); $ns = $_GET['nextstep'] + 1; global $db,$ir,$c,$h,$hitspot; echo sprintf("<span style='color:blue;'>%u. Using %s %s, %s hit you in the %s doing %s damage (%s)</span> ", $ns, $oabbr, stripslashes($wep), stripslashes($odata['username']), $hitspot, number_format($dam), number_format($youdata['hp'])); $_SESSION['attacklog'] .= sprintf("<span style='color:blue;'>%u. Using %s %s, %s hit %s doing %s damage (%s)</span> ", $ns, $oabbr, $wep, $odata['username'], $ir['username'], number_format($dam), number_format($youdata['hp'])); } else { $ns = $_GET['nextstep'] + 1; echo sprintf("<span style='color:red;'>%s. %s tried to hit you in the %s, but missed (%s)</span> ", $ns, stripslashes($odata['username']), $hitspot, number_format($youdata['hp'])); $_SESSION['attacklog'] .= sprintf("<span style='color:blue;'>%u. %s tried to hit %s, but missed (%s)</span> ", $ns, $odata['username'], $ir['username'], number_format($youdata['hp'])); } if($youdata['hp'] <= 0) { $youdata['hp'] = 0; $_SESSION['attacklost'] = 1; $nohp = sprintf("UPDATE users SET hp = 0 WHERE (userid = %u)", $userid); $db->query($nohp); echo sprintf("<form action='attacklost.php?ID=%u' method='post'><input type='submit' value='Continue' />", $_GET['ID']); } } } else if($odata['hp'] < 5) { echo "You can only attack those who have health"; $h->endpage(); exit; } else if($ir['gang'] == $odata['gang'] && $ir['gang'] > 0) { echo sprintf("You are in the same gang as %s! What are you smoking today dude!", stripslashes($odata['username'])); $h->endpage(); exit; } else if($youdata['energy'] < $youdata['maxenergy']/4) { echo "You can only attack someone when you have 25% energy"; $h->endpage(); exit; } else if($youdata['location'] != $odata['location']) { echo "You can only attack someone in the same location!"; $h->endpage(); exit; } else { } echo "</td></tr>"; if($youdata['hp'] <= 0 || $odata['hp'] <= 0) { echo "</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']; $selectweapons = sprintf("SELECT * FROM items WHERE (itmid IN(%u, %u))", $ir['equip_primary'], $ir['equip_secondary']); $mw = $db->query($selectweapons); echo "<tr><td colspan='2' align='center'>Attack with: "; if($db->num_rows($mw)) { while($r = $db->fetch_row($mw)) { $ns = (!isset($_GET['nextstep'])) ? 1 : $_GET['nextstep'] + 2; if($r['itmid'] == $ir['equip_primary']) { echo "[b]Primary Weapon:[/b] "; } if($r['itmid']==$ir['equip_secondary']) { echo "[b]Secondary Weapon:[/b] "; } echo sprintf("[url='attack.php?nextstep=%u&ID=%u&wepid=%u']%s[/url] ", $ns, $_GET['ID'], $r['itmid'], stripslashes($r['itmname'])); } } else { echo "You have nothing to fight with."; } echo "</table>"; echo "<table width='50%' align='center'>"; echo "<tr>"; echo "<td align='right'>Your Health: </td>"; echo sprintf("<td>[img=greenbar.png][img=redbar.png]</td>", $vars['hpperc'], $vars['hpopp']); echo "</tr>"; echo "<tr>"; echo "<td align='right'>Opponents Health: </td>"; echo sprintf("<td>[img=greenbar.png][img=redbar.png]</td>", $vars2['hpperc'], $vars2['hpopp']); echo "</tr>"; echo "</table>"; } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
danger boy Posted August 7, 2009 Share Posted August 7, 2009 Re: attacking but not losing energy Why's this in the paid mod section? :? Shouldn't it be in the mccodes/dbs codes section? :| Quote Link to comment Share on other sites More sharing options...
Goku Posted August 7, 2009 Share Posted August 7, 2009 Re: attacking but not losing energy Fix Crons. :-D Quote Link to comment Share on other sites More sharing options...
jon182 Posted August 7, 2009 Author Share Posted August 7, 2009 Re: attacking but not losing energy not the crons thier working fine. and ya idk why i put it here i thought i was in the other section. Please move 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.