Jump to content
MakeWebGames

Attack Lost


Scorpio

Recommended Posts

^ This.

Post up the file, and any errors you have or contact mccodes via their website. I would suggest the former.

Due to my current affiliation with McCodes, I'll take this :)

Post the code, plus all relevant details regarding to it not working.

Link to comment
Share on other sites

Error -

 

MCCodes - Critical Error
A critical error has occurred, and this page cannot be displayed. Please try again later.
Query failed

 

attacklost.php -

 

<?php
/**
* MCCodes Version 2.0.5b
* Copyright (C) 2005-2012 Dabomstew
* All rights reserved.
*
* Redistribution of this code in any form is prohibited, except in
* the specific cases set out in the MCCodes Customer License.
*
* This code license may be used to run one (1) game.
* A game is defined as the set of users and other game database data,
* so you are permitted to create alternative clients for your game.
*
* If you did not obtain this code from MCCodes.com, you are in all likelihood
* using it illegally. Please contact MCCodes to discuss licensing options
* in this case.
*
* File: attacklost.php
* Signature: 95b6a74ae7c7a6cf4e9ed998f3b574c8
* Date: Fri, 20 Apr 12 08:50:30 +0000
*/

$atkpage = 1;
require_once('globals.php');

$_GET['ID'] =
       (isset($_GET['ID']) && is_numeric($_GET['ID']))
               ? abs((int) $_GET['ID']) : 0;
$_SESSION['attacking'] = 0;
$_SESSION['attacklost'] = 0;
$od =
       $db->query(
               "SELECT `username`, `level`, `gang` FROM `users` WHERE `userid` = {$_GET['ID']}");
if ($db->num_rows($od) > 0)
{
   $r = $db->fetch_row($od);
   $db->free_result($od);
   echo "You lost to {$r['username']}";
   $expgain = abs(($ir['level'] - $r['level']) ^ 3);
   $expgainp = $expgain / $ir['exp_needed'] * 100;
   echo " and lost $expgainp% EXP!";
   // Figure out their EXP, 0 or decreased?
   $newexp = max($ir['exp'] - $expgain, 0);
   $db->query(
           "UPDATE `users` SET `exp` = {$newexp}, `attacking` = 0 WHERE `userid` = $userid");
   event_add($r['userid'],
           "<a href='viewuser.php?u=$userid'>{$ir['username']}</a> attacked you and lost.",
           $c);
   $atklog = $db->escape($_SESSION['attacklog']);
   $db->query(
           "INSERT INTO `attacklogs` VALUES(NULL, $userid, {$_GET['ID']},
                   'lost', " . time() . ", 0, '$atklog')");
   if ($ir['gang'] > 0 && $r['gang'] > 0)
   {
       $warq =
               $db->query(
                       "SELECT * FROM `gangwars`
                           WHERE (`warDECLARER` = {$ir['gang']} AND `warDECLARED` = {$r['gang']})
                           OR (`warDECLARED` = {$ir['gang']} AND `warDECLARER` = {$r['gang']})");
       if ($db->num_rows($warq) > 0)
       {
           $war = $db->fetch_row($warq);
           $db->query(
                   "UPDATE `gangs` SET `gangRESPECT` = `gangRESPECT` + 1 WHERE `gangID` = {$r['gang']}");
           $db->query(
                   "UPDATE `gangs` SET `gangRESPECT` = `gangRESPECT` - 1 WHERE `gangID` = {$ir['gang']}");
           echo "<br />You lost 1 respect for your gang!";
       }
       $db->free_result($warq);
   }
}
else
{
   $db->free_result($od);
   echo "You lost to Mr. Non-existant! =O";
}
$h->endpage();

 

 

I then Installed it on a Wamp sever. I still get the same error. (I didnt change nothing) And its the latest one from the mccodes place.

Edited by Scorpio
Link to comment
Share on other sites

Try this

<?php
/**
** MCCodes Version 2.0.5b
** Copyright (C) 2005-2012 Dabomstew
** All rights reserved.
**
** Redistribution of this code in any form is prohibited, except in
** the specific cases set out in the MCCodes Customer License.
**
** This code license may be used to run one (1) game.
** A game is defined as the set of users and other game database data,
** so you are permitted to create alternative clients for your game.
**
** If you did not obtain this code from MCCodes.com, you are in all likelihood
** using it illegally. Please contact MCCodes to discuss licensing options
** in this case.
**
** File: attacklost.php
** Signature: 95b6a74ae7c7a6cf4e9ed998f3b574c8
** Date: Fri, 20 Apr 12 08:50:30 +0000
**/

$atkpage = 1;
require_once('globals.php');

$_GET['ID']             = (isset($_GET['ID']) && ctype_digit($_GET['ID'])) ? abs((int) $_GET['ID']) : 0;
$_SESSION['attacking']  = 0;
$_SESSION['attacklost'] = 0;
if(!$_GET['ID']) {
echo "You didn't specify a player to attack";
exit($h->endpage());
}
$od = $db->query("SELECT `username`, `level`, `gang` FROM `users` WHERE `userid` = {$_GET['ID']}");
if(!$db->num_rows($od)) {
echo "You lost to Mr. Non-Existant!";
exit($h->endpage());
}
$r = $db->fetch_row($od);
$db->free_result($od);
echo "You lost to ", stripslashes(htmlspecialchars($r['username']));
$expgain  = abs(($ir['level'] - $r['level']) ^ 3);
$expgainp = $expgain / $ir['exp_needed'] * 100;
echo " and lost ", number_format($expgainp, 2), "% EXP!";
// Figure out their EXP, 0 or decreased?
$newexp = max($ir['exp'] - $expgain, 0);
$db->query("UPDATE `users` SET `exp` = {$newexp}, `attacking` = 0 WHERE `userid` = $userid");
event_add($r['userid'], "<a href='viewuser.php?u=$userid'>{$ir['username']}</a> attacked you and lost.", $c);
$atklog = $db->escape($_SESSION['attacklog']);
$db->query("INSERT INTO `attacklogs` VALUES(NULL, $userid, {$_GET['ID']}, 'lost', " . time() . ", 0, '$atklog')");
if($ir['gang'] > 0 && $r['gang'] > 0) {
$warq = $db->query("SELECT * FROM `gangwars` " . 
					"WHERE (((`warDECLARER` = {$ir['gang']}) AND (`warDECLARED` = {$r['gang']})) " . 
					"OR ((`warDECLARED` = {$ir['gang']}) AND (`warDECLARER` = {$r['gang']})))");
if($db->num_rows($warq) > 0) {
	$war = $db->fetch_row($warq);
	$db->query("UPDATE `gangs` SET `gangRESPECT` = `gangRESPECT` + 1 WHERE `gangID` = {$r['gang']}");
	$db->query("UPDATE `gangs` SET `gangRESPECT` = `gangRESPECT` - 1 WHERE `gangID` = {$ir['gang']}");
	echo "You lost 1 respect for your gang!";
}
$db->free_result($warq);
}
$h->endpage();
?>
Link to comment
Share on other sites

<?php
/**
** MCCodes Version 2.0.5b
** Copyright (C) 2005-2012 Dabomstew
** All rights reserved.
**
** Redistribution of this code in any form is prohibited, except in
** the specific cases set out in the MCCodes Customer License.
**
** This code license may be used to run one (1) game.
** A game is defined as the set of users and other game database data,
** so you are permitted to create alternative clients for your game.
**
** If you did not obtain this code from MCCodes.com, you are in all likelihood
** using it illegally. Please contact MCCodes to discuss licensing options
** in this case.
**
** File: attacklost.php
** Signature: 95b6a74ae7c7a6cf4e9ed998f3b574c8
** Date: Fri, 20 Apr 12 08:50:30 +0000
**/

$atkpage = 1;
require_once('globals.php');

$_GET['ID']             = (isset($_GET['ID']) && ctype_digit($_GET['ID'])) ? abs((int) $_GET['ID']) : 0;
$_SESSION['attacking']  = 0;
$_SESSION['attacklost'] = 0;
if(!$_GET['ID']) {
   echo "You didn't specify a player to attack";
   exit($h->endpage());
}
$od = $db->query("SELECT `username`, `level`, `gang` FROM `users` WHERE `userid` = {$_GET['ID']}");
if(!$db->num_rows($od)) {
   echo "You lost to Mr. Non-Existant!";
   exit($h->endpage());
}
$r = $db->fetch_row($od);
$db->free_result($od);
echo "You lost to ", stripslashes(htmlspecialchars($r['username']));
$expgain  = abs(($ir['level'] - $r['level']) ^ 3);
$expgainp = $expgain / $ir['exp_needed'] * 100;
echo " and lost ", number_format($expgainp, 2), "% EXP!";
// Figure out their EXP, 0 or decreased?
$newexp = max($ir['exp'] - $expgain, 0);
$db->query("UPDATE `users` SET `exp` = {$newexp}, `attacking` = 0 WHERE `userid` = $userid");
event_add($_GET['ID'], "<a href='viewuser.php?u=$userid'>{$ir['username']}</a> attacked you and lost.", $c);
$atklog = $db->escape($_SESSION['attacklog']);
$db->query("INSERT INTO `attacklogs` VALUES(NULL, $userid, {$_GET['ID']}, 'lost', " . time() . ", 0, '$atklog')");
if($ir['gang'] > 0 && $r['gang'] > 0) {
   $warq = $db->query("SELECT * FROM `gangwars` " .
                       "WHERE (((`warDECLARER` = {$ir['gang']}) AND (`warDECLARED` = {$r['gang']})) " .
                       "OR ((`warDECLARED` = {$ir['gang']}) AND (`warDECLARER` = {$r['gang']})))");
   if($db->num_rows($warq) > 0) {
       $war = $db->fetch_row($warq);
       $db->query("UPDATE `gangs` SET `gangRESPECT` = `gangRESPECT` + 1 WHERE `gangID` = {$r['gang']}");
       $db->query("UPDATE `gangs` SET `gangRESPECT` = `gangRESPECT` - 1 WHERE `gangID` = {$ir['gang']}");
       echo "You lost 1 respect for your gang!";
   }
   $db->free_result($warq);
}
$h->endpage();
?>

(event_add() was using $r['userid'], which did not exist. )

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...