Jump to content
MakeWebGames

Attacking System


skooda
 Share

Recommended Posts

Hey guys I keep getting this error in my attack I had this ruthless city attack but my users dont like it and its a waste of time so I had this one click attack I had it since my old game and now im trying to put it on my new game and it isnt working.

 

<?php
$menuhide=0;
$atkpage=1;
include "globals.php";

$user_class=$ir;
$q=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid={$_GET['ID']}");
$attack_person=$db->fetch_row($q);
$qo=$db->query("SELECT i.* FROM items i   WHERE i.itmid={$user_class['equip_primary']}");
$user_class1=$db->fetch_row($qo);
$q1=$db->query("SELECT i.* FROM items i   WHERE i.itmid={$user_class['equip_armor']}");
$user_class2=$db->fetch_row($q1);
$weapon= "{$user_class1['itmname']}";
if(mysql_num_rows($qo) == 0) {
               $weapon="Fists";
               } 
$eq=$db->query("SELECT i.* FROM  items i  WHERE i.itmid IN({$attack_person['equip_primary']})");
           if(mysql_num_rows($eq) == 0) {
               $wep="Fists";
               } else {
               $cnt=0;
               while($r=$db->fetch_row($eq)) {
                   $enweps[]=$r;
                   $cnt++;
               }
               $weptouse=rand(0,$cnt-1);
               $wep=$enweps[$weptouse]['itmname'];
               }   
               $enperc=(int) ($ir['energy']/$ir['maxenergy']*100);
               $gq=$db->query("SELECT * FROM gangs WHERE gangID={$attack_person['gang']}");
$ga=$db->fetch_row($gq);
$error = ($enperc < 25) ? "You need to have at least 25% of your energy if you want to attack someone." : $error;
$error = ($user_class['jail'] > 0) ? "You can't attack someone if you are in jail." : $error;
$error = ($user_class['hospital'] > 0) ? "You can't attack someone if you are in the hospital." : $error;
$error = ($_GET['ID'] == "") ? "You didn't choose someone to attack." : $error;
$error = ($_GET['ID'] == $userid) ? "You can't attack yourself." : $error;
$error = ($attack_person['location'] != $user_class['location']) ? "You must be in the same city as the person you are attacking. Duh." : $error;
$error = ($attack_person['username'] == "") ? "That person doesn't exist." : $error;
$error = ($attack_person['hospital'] > 0) ? "You can't attack someone that is in the hospital." : $error;
$error = ($attack_person['jail'] > 0) ? "You can't attack someone that is in jail." : $error;
//$error = ($user_class['level'] > 5 && $attack_person['level'] < 6) ? "You can't attack someone that is level 5 or below because you are higher than level 5." : $error;
////////////// ^^ if you like to have it so noobs stay alive longer

?><div id="main " style="a"><center><?PHP
if (isset($error)){
   echo ($error);

$h->endpage();
           exit;
}
if ($user_class['energy'] >= $user_class['maxenergy']/4) {
           $user_class['energy']-= floor($user_class['maxenergy']/4);
           $me=floor($user_class['maxenergy']/4);
           $db->query("UPDATE users SET energy=energy- {$me} WHERE userid=$userid");
           $_SESSION['attacklog']="";
           $_SESSION['attackdmg']=0;
       } 

$yourhp = $user_class['hp'];
$theirhp = $attack_person['hp'];
$damagestat = number_format($user_class['strength']) ;
$itstat = $user_class1['weapon'];
$damplu = $damagestat * ($itstat*100);
$ratio=($user_class['level']*100)/($attack_person['level']*100);
print "<center>Pirate Battles

   <font color=yellow>The fight Ratio is ".$ratio."%</font>

You are in a Battle with  ".$attack_person['username']." </center>";
echo " You come in with your ".$weapon." With a Strenght of ".$damplu." (+".$itstat."%)
";

$wait = ($user_class['agility'] > $attack_person['agility']) ? 1 : 0;
$hospital = 600;
$qo=$db->query("SELECT i.* FROM  items i  WHERE i.itmid IN({$attack_person['equip_primary']})");
$r1=$db->fetch_row($qo);
$qo=$db->query("SELECT i.* FROM  items i  WHERE i.itmid IN({$attack_person['equip_primary']})");
$r2=$db->fetch_row($qo);
$damage = (int) (($user_class1['weapon']*$user_class['strength']/($attack_person['guard']/1.5)));
$theirdamage = (int) (($r1['weapon']*$attack_person['strength']/($user_class['guard']/1.5)));
while($yourhp > 0 && $theirhp > 0){
   $damage = ($damage < 1) ? 1 : $damage;
   $theirdamage = ($theirdamage < 1) ? 1 : $theirdamage;
   if($wait == 0){
       $yourhp = $yourhp - $theirdamage;
       echo "<font color=red>".$attack_person['usename']."Takes their turn to swing at you!</font>
";
       echo $attack_person['username'].  " hit you for "  .number_format($theirdamage).  " damage using their ".$wep.". 
";
   } else {
       $wait = 0;
   }

   if($yourhp > 0) {
$damage = (int) (($user_class1['weapon']*$user_class['strength']/($attack_person['guard']/1.5)));
       $damage = ($damage < 1) ? 1 : $damage;
       $theirhp = $theirhp - $damage;
       echo "<font color=green>You swing at them!</font>
";
       echo "You hit " .$attack_person['username'].  " for " . number_format($damage) . " damage using your ".$weapon.". 
";
   }

   if($theirhp <= 0){ // attacker won
        $winner = $user_class['ID'];
        $theirhp = 0;
        $moneywon = floor($attack_person['money'] /10);
        $expwon = 150 - (25 * ($user_class['level'] - $attack_person['level']));
        $expwon = ($expwon < 0) ? 0 : $expwon;
        $hosptime=20;

        $hospreason = "Attacked by ".$user_class['username']."" ;
        $newexp = $expwon + $user_class['exp'];
        $newmoney = $user_class['money'] + $moneywon;
        $result = $db->query("UPDATE `users` SET `exp` = '".$newexp."', money = '".$newmoney."' WHERE `userid`='".$user_class['userid']."'");   
        $newmoney = $attack_person['money'] - $moneywon;
        $result = $db->query("UPDATE `users` SET `hp`= 1,`hospital` ='".$hosptime."', `money` = '".$newmoney."', `hospreason` = '".$hospreason."' WHERE `userid`='".$attack_person['userid']."'");
        $atklog=mysql_escape_string($_SESSION['attacklog']);
$db->query("INSERT INTO attacklogs VALUES('',".$user_class['userid'].",".$attack_person['userid'].",'won',unix_timestamp(),".$moneywon.",'$atklog')  ;");
        event_add($attack_person['userid'], "You were hospitalized by ".$user_class['username']." for 20 minutes.");
        $final ="<center>You hospitalized "  .$attack_person['username'].  ".
You gain $expwon exp and stole $".$moneywon." from "  .$attack_person['username'].  ".
</center>";
       $pwnd ="";
$warq=$db->query("SELECT * FROM gangwars WHERE (warDECLARER={$user_class['gang']} AND warDECLARED={$attack_person['gang']}) OR (warDECLARED={$user_class['gang']} AND warDECLARER={$attack_person['gang']})");
if ($db->num_rows($warq) > 0)
{
$war=$db->fetch_row($warq);
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT-2 WHERE gangID={$attack_person['gang']}");
$ga['gangRESPECT']-=2;
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+2 WHERE gangID={$user_class['gang']}");
$pwnd  ="
You earnt 2 respect for your gang!";
       }
       if ($ga['gangRESPECT']<=0 && $attack_person['gang'])
{
$db->query("UPDATE users SET gang=0 WHERE gang={$attack_person['gang']}");

$db->query("DELETE FROM gangs WHERE gangRESPECT<='0'");
$db->query("DELETE FROM gangwars WHERE warDECLARER={$ga['gangID']} or warDECLARED={$ga['gangID']}");
}
$bots=array(96,94,5,97,98,99,142,138,138,140,141,1  46,143,144,145);//Your Battle Tent Bots
$moneys=array(96 =>5000,94 =>5000,5 => 500,97 => 5000, 98 => 500, 99 => 10000, 142 => 1500,138 =>10000,140 =>10000,141 =>10000,146 =>20000,143 =>15000,144 =>15000,145 =>15000);
if(in_array($attack_person['userid'],$bots))
{
$gain=$moneys[$attack_person['userid']];
$db->query("UPDATE users SET money=money+$gain WHERE userid=$userid",$c);
$finalbot ="";
$finalbot ="

Congrats, for beating the Challenge Bot {$attack_person['username']}, you have earnt \$$gain!";

}
}

   if($yourhp <= 0){ // defender won
        $winner = $attack_person['ID'];
        $yourhp = 0;
        $moneywon = floor($user_class['money'] /10);
        $expwon = 100 - (25 * ($attack_person['level'] - $user_class['level']));
        $expwon = ($expwon < 0) ? 0 : $expwon;
        $hosplost = "Lost to ".$attack_person['username']."" ;
        $hosptime=20;
        $newexp = $expwon + $attack_person['exp'];
        $newmoney = $attack_person['money'] + $moneywon;
        $result = $db->query("UPDATE `users` SET `exp` = '".$newexp."', money = '".$newmoney."' WHERE `userid`='".$attack_person['userid']."'");
        $newmoney = $user_class['money'] - $moneywon;
        $result = $db->query("UPDATE `users` SET `hp`= 1,`hospital` ='".$hosptime."' ,`money` = '".$newmoney."', `hospreason` = '".$hosplost."' WHERE `userid`='".$user_class['userid']."'");
         $atklog=mysql_escape_string($_SESSION['attacklog']);
$db->query("INSERT INTO attacklogs VALUES('',".$attack_person['userid'].",".$user_class['userid'].",'won',unix_timestamp(),".$moneywon.",'$atklog')  ;");
        $final = $attack_person2 . " beat you and stole $".$moneywon." from you.";
$pwnd ="";
$warq=$db->query("SELECT * FROM gangwars WHERE (warDECLARER={$user_class['gang']} AND warDECLARED={$attack_person['gang']}) OR (warDECLARED={$user_class['gang']} AND warDECLARER={$attack_person['gang']})");
if ($db->num_rows($warq) > 0)
{
$war=$db->fetch_row($warq);
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+1 WHERE gangID={$attack_person['gang']}");
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT-1 WHERE gangID={$user_class['gang']}");
$pwnd ="
You lost 1 respect for your gang!";
}
}
}
echo "$final";
echo "$pwnd ";
echo "$finalbot";
$h->endpage();
?></div></center>

 

 

Parse error: syntax error, unexpected T_LNUMBER, expecting ')' in /home/fefegx10/public_html/attack.php on line 142

<<<<<<<<This is the error that keep pulling up also i dint make this attack it was just in my old files and I decided to you is it.

Link to comment
Share on other sites

ok now I get this when I do a attack

 

Pirate Battles The fight Ratio is 0.117647058824% You are in a Battle with ForkingPawn

You come in with your Fists With a Strenght of 0 (+%) Takes their turn to swing at you! ForkingPawn hit you for 8,698 damage using their ArmaLite M-15A4 Rifle . QUERY ERROR: Column count doesn't match value count at row 1

Query was INSERT INTO attacklogs VALUES('',19,1,'won',unix_timestamp(),214747368,' g') ;

Link to comment
Share on other sites

heres my attack log

 

<?PHP

require "globals.php";

$id = abs((int)$_GET['id']);

if(!$id){

echo "Not in the attack logs.";

$h->endpage();

die();

}

$s = $db->fetch_row($db->query("SELECT * FROM `attacklogs` where log_id=$id"));

if(!$s){

echo "Not in the attack logs.";

$h->endpage();

die();

}

if($s['annon'] == 1){

$nm = $db->fetch_row($db->query("select username from users where userid=$s[attacked]"));

echo "<h2>Someone VS $nm[username]</h2>";

}else{

$nm = $db->fetch_row($db->query("select username from users where userid=$s[attacker]"));

$nm1 = $db->fetch_row($db->query("select username from users where userid=$s[attacked]"));

echo "<h2>$nm[username] VS $nm1[username]</h2>";

}

echo "<br>$s[attacklog]<br><br>$s[outcome]<br><hr><a href=events.php>> Back</a><hr>";

 

$h->endpage();

?>

Link to comment
Share on other sites

-- phpMyAdmin SQL Dump
-- version 3.4.9
-- [url]http://www.phpmyadmin.net[/url]
--
-- Host: localhost
-- Generation Time: Feb 17, 2012 at 02:07 PM
-- Server version: 5.0.92
-- PHP Version: 5.2.9

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `wisecrim_torn`
--

-- --------------------------------------------------------

--
-- Table structure for table `attacklogs`
--

CREATE TABLE IF NOT EXISTS `attacklogs` (
 `log_id` int(11) NOT NULL auto_increment,
 `attacker` int(11) NOT NULL default '0',
 `attacked` int(11) NOT NULL default '0',
 `result` enum('won','lost') NOT NULL default 'won',
 `time` int(11) NOT NULL default '0',
 `stole` int(11) NOT NULL default '0',
 `attacklog` longtext NOT NULL,
 `annon` smallint(1) NOT NULL default '0',
 `outcome` text NOT NULL,
 PRIMARY KEY  (`log_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=54 ;

--
-- Dumping data for table `attacklogs`
--
Edited by Nickson
code tags
Link to comment
Share on other sites

Okay, so you have the following columns in your table

log_id

attacker

attacked

result

time

stole

attacklog

annon

outcome

-----------

Total: 9

And this is your query

INSERT INTO attacklogs VALUES('',19,1,'won',unix_timestamp(),214747368,' g') ;

-----------

Total: 7

If you're wanting to insert data into specific columns, use this syntax

INSERT INTO <table> (<columns*>) VALUES (<data*>)

* Separate with a comma

...So, match what you're wanting to insert with the table columns.

I hope you understand.

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.

 Share

×
×
  • Create New...