Samurai Legend Posted March 1, 2015 Share Posted March 1, 2015 Code for the attacks - if($r['user_level'] == 0) { $q = $db->query("SELECT `cb_money` FROM `challengebots` WHERE `cb_npcid` = {$r['userid']}"); if($db->num_rows($q) > 0) { $cb = $db->fetch_row($q); $qk = $db->query("SELECT COUNT(`npcid`) FROM `challengesbeaten` WHERE `userid` = $userid AND `npcid` = {$r['userid']}"); if(!$db->num_rows($qk)) { $m = $cb['cb_money']; $db->query("UPDATE `users` SET `money` = `money` + $m WHERE `userid` = $userid"); echo "<br /> You gained " . money_formatter($m) . " for beating the challenge bot {$r['username']}"; $db->query("INSERT INTO `challengesbeaten` VALUES($userid, {$r['userid']}, " . time() . ")"); } $db->free_result($qk); } $db->free_result($q); } For some reason that does not work and it is the default MCCodes? Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted March 1, 2015 Share Posted March 1, 2015 Oh yes, good old McCodes. Lol. I'll take a look. Quote Link to comment Share on other sites More sharing options...
NonStopCoding Posted March 1, 2015 Share Posted March 1, 2015 if($r['user_level'] == 0) { should that not be $ir unless its been changed can you post more code? and what exactly is the issue? Edit: if there is no code which is making it $r then you need to change all $r to $ir as that is the main variable called in mccodes for calling out info from users table and users stats Quote Link to comment Share on other sites More sharing options...
Samurai Legend Posted March 2, 2015 Author Share Posted March 2, 2015 $ir is for the user it self. And $r is the other user I am attacking. It's a bit wierd doens't work and so as the battle ladder add-on <?php $atkpage = 1; require_once('globals.php'); $_GET['ID'] = (isset($_GET['ID']) && is_numeric($_GET['ID'])) ? abs((int) $_GET['ID']) : 0; $_SESSION['attacking'] = 0; $ir['attacking'] = 0; $db->query("UPDATE `users` SET `attacking` = 0 WHERE `userid` = $userid"); $od = $db->query("SELECT * FROM `users` WHERE `userid` = {$_GET['ID']} LIMIT 1"); if(!isset($_SESSION['attackwon']) || $_SESSION['attackwon'] != $_GET['ID']) { error("Cheaters don't get anywhere."); } if($db->num_rows($od) > 0) { $r = $db->fetch_row($od); $db->free_result($od); if($r['hp'] == 1) { error('The user has no health to attack.'); } else { action("You beat {$r['username']}!<br />You beat {$r['username']} severely on the ground. When there is lots of blood showing, you head up to the nearest 10-story building's roof and drop him over the edge. You run home silently and carefully."); $hosptime = rand(50, 150) + floor($ir['level'] / 2); $hospreason = $db->escape("Hospitalized by <a href='viewuser.php?u={$userid}'>{$ir['username']}</a>"); $db->query("UPDATE `users` SET `hp` = 1, `defends_lost` = `defends_lost` + 1, `hospital` = $hosptime, `hospreason` = '{$hospreason}', `hosp_bill` = `hosp_bill` + $hosptime * 10 WHERE `userid` = {$r['userid']}"); $db->query("UPDATE `users` SET `attacks_won` = `attacks_won` + 1 WHERE `userid` = {$ir['userid']}"); event_add($r['userid'], "<a href='viewuser.php?u=$userid'>{$ir['username']}</a> beat you up.", $c); $atklog = $db->escape($_SESSION['attacklog']); $db->query("INSERT INTO `attacklogs` VALUES(NULL, $userid, {$_GET['ID']}, 'won', " . time() . ", -1, '$atklog')"); //Battle Ladder add on $chk_one = $db->query(sprintf("SELECT * FROM `battle_members` WHERE `bmemberUser` = '%u'", $ir['userid'])); $r1=$db->fetch_assoc($chk_one); $chk_two = $db->query(sprintf("SELECT * FROM `battle_members` WHERE `bmemberUser` = '%u' AND `bmemberLadder` = '%u'", $r['userid'], $r1['bmemberLadder'])); if ($db->num_rows($chk_one) AND $db->num_rows($chk_two)) { $score = rand(1, 10); $db->query(sprintf("UPDATE `battle_members` SET `bmemberScore` = `bmemberScore` - '%d', `bmemberLosses` = `bmemberLosses` + '1' WHERE `bmemberUser` = '%u'", $score, $r['userid'])); $db->query(sprintf("UPDATE `battle_members` SET `bmemberScore` = `bmemberScore` + '%d', `bmemberWins` = `bmemberWins` + '1' WHERE `bmemberUser` = '%u'", $score, $ir['userid'])); echo 'You have added '.$score.' points to the score on the battle ladder, well done.<br />'; } //End $_SESSION['attackwon'] = 0; if($ir['clan'] > 0 && $r['clan'] > 0) { $gq = $db->query("SELECT `clanRESPECT`, `clanID` FROM `clans` WHERE `clanID` = {$r['clan']} LIMIT 1"); if($db->num_rows($gq) > 0) { $ga = $db->fetch_row($gq); $warq = $db->query("SELECT COUNT(`warDECLARER`) FROM `clanwars` WHERE (`warDECLARER` = {$ir['clan']} AND `warDECLARED` = {$r['clan']}) OR (`warDECLARED` = {$ir['clan']} AND `warDECLARER` = {$r['clan']})"); if($db->fetch_single($warq) > 0) { $db->query("UPDATE `clans` SET `clanRESPECT` = `clanRESPECT` - 3 WHERE `clanID` = {$r['clan']}"); $ga['clanRESPECT'] -= 3; $db->query("UPDATE `clans` SET `clanRESPECT` = `clanRESPECT` + 3 WHERE `clanID` = {$ir['clan']}"); $db->query( "UPDATE `users` SET `clan_kills` = `clan_kills` + 1 WHERE `userid` = {$ir['userid']}"); echo "<br />You earnt 3 respect for your clan and one clan kill!"; } if($ga['clanRESPECT'] <= 0 && $r['clan']) { $db->query("UPDATE `users` SET `clan` = 0 WHERE `clan` = {$r['clan']}"); $db->query("DELETE FROM `clans` WHERE `clanRESPECT` <= 0"); $db->query("DELETE FROM `clanwars` WHERE `warDECLARER` = {$ga['clanID']} OR `warDECLARED` = {$ga['clanID']}"); } } $db->free_result($gq); } if($r['user_level'] == 0) { $q = $db->query("SELECT `cb_money` FROM `challengebots` WHERE `cb_npcid` = {$r['userid']}"); if($db->num_rows($q) > 0) { $cb = $db->fetch_row($q); $qk = $db->query("SELECT COUNT(`npcid`) FROM `challengesbeaten` WHERE `userid` = $userid AND `npcid` = {$r['userid']}"); if(!$db->num_rows($qk)) { $m = $cb['cb_money']; $db->query("UPDATE `users` SET `money` = `money` + $m WHERE `userid` = $userid"); echo "<br /> You gained " . money_formatter($m) . " for beating the challenge bot {$r['username']}"; $db->query("INSERT INTO `challengesbeaten` VALUES($userid, {$r['userid']}, " . time() . ")"); } $db->free_result($qk); } $db->free_result($q); } } } else { $db->free_result($od); action("You beat Mr. non-exist!"); } 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.