MagicZ94 Posted December 21, 2010 Posted December 21, 2010 The attack, and the Hospital both run perfectly, except it doesn't show the reason for the user to be in the hospital, has anybody ever experianced this before, and could they possibly tell emw hat they did? :) Thanks. Quote
Adrian Posted December 21, 2010 Posted December 21, 2010 Can you post your hospital.php please :) Quote
MagicZ94 Posted December 21, 2010 Author Posted December 21, 2010 Yeah, sure:) <?php include "globals.php"; print "<h3>Hospital</h3> <table width='75%' class=\"table\" border=\"0\" cellspacing=\"1\"><tr bgcolor=gray><th>Name</th> <th>Level</th> <th>Time</th><th>Reason</th></tr>"; $q=$db->query("SELECT u.*,c.* FROM users u LEFT JOIN gangs c ON u.gang=c.gangID WHERE u.hospital > 0 ORDER BY u.hospital DESC",$c); while($r=$db->fetch_row($q)) { print "\n<tr><td>{$r['gangPREFIX']} {$r['username']} [{$r['userid']}]</td><td> {$r['level']}</td><td>{$r['hospital']} minutes</td><td>{$r['hospreason']}</td></tr>"; } print "</table>"; $h->endpage(); ?> Quote
Adrian Posted December 21, 2010 Posted December 21, 2010 Hello, I think it might be you table because the code it self its fine just wait for PRO coder to help you mate. Regards, Adrian Quote
MagicZ94 Posted December 21, 2010 Author Posted December 21, 2010 Alright:) And thanks for trying mate:) I'm not a particularly good coder, and i spent ages tryign tof igure out what was wrong with it, but it all looks normal:P Quote
Curt Posted December 21, 2010 Posted December 21, 2010 hey, check your database and check if hospreason has been changed or if its blank... if its blank you may need to edit the scripts that change that field. Quote
MagicZ94 Posted December 21, 2010 Author Posted December 21, 2010 I feel stupid now, it's not there, i must have deleted it or something. If i create it now, what will i have to do for it to work? Quote
Adrian Posted December 22, 2010 Posted December 22, 2010 I think this is what you need to add :) ALTER TABLE `users` ADD `hospreason` VARCHAR( 255 ) NOT NULL ; Quote
Curt Posted December 22, 2010 Posted December 22, 2010 lol...everyone has there noob moments... create hospreason in your users table and all will be fine. happy holidays, Curt Quote
MagicZ94 Posted December 22, 2010 Author Posted December 22, 2010 I created the table, then attacked someone, it's still doing th same thing HospitalName Level Time Reason Dave [8] 10 10 minutes :/ Quote
Adrian Posted December 22, 2010 Posted December 22, 2010 Are you sure you added the table correctly like i posted it?? Quote
MagicZ94 Posted December 22, 2010 Author Posted December 22, 2010 i added it exactly as you posted it, yeah. Quote
Rasheed saeed Posted December 22, 2010 Posted December 22, 2010 You would have to edit a few files to actually get a reason. Quote
MagicZ94 Posted December 22, 2010 Author Posted December 22, 2010 OH, Alright, which files will it be? hospital.php and attack.php? Quote
Rasheed saeed Posted December 22, 2010 Posted December 22, 2010 Attack - Streets - Other things like that - Robbed office. Quote
MagicZ94 Posted December 22, 2010 Author Posted December 22, 2010 The only thing i have that puts you in hospital at the moment, is attack, will it be an easy simple bit of coding? or will it be something, big? :P Quote
MagicZ94 Posted December 22, 2010 Author Posted December 22, 2010 I just looked in all the attack files, seeing as i only use attack.php and none of the others now, so i thought they might have something in them, and since i changed to this attack that might be why. $db->query("UPDATE users SET hp=1,hospital=$hosptime,hospreason='Hospitalized by <a href=\'viewuser.php?u={$userid}\'>{$ir['username']}</a>' WHERE userid={$r['userid']}"); i found that in attackbeat.php, would this just fit in attack.php somewhere? Quote
MagicZ94 Posted December 22, 2010 Author Posted December 22, 2010 If anyone could add me on msn [email protected] and help me with the adding the bit into attack.php, i'd be really grateful, i don't want you to tell me what to do, just to help me, i need to learn:P Quote
Danny696 Posted December 22, 2010 Posted December 22, 2010 Post up your attack file, your not updating the database... Quote
MagicZ94 Posted December 22, 2010 Author Posted December 22, 2010 <?php $menuhide=1; $atkpage=1; require_once("globals.php"); $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs((int) $_GET['ID']) : false; if(!$_GET['ID']){ echo "You did not select a valid ID"; $h->endpage(); exit; } $energy = $ir['maxenergy']/4; $error = ($ir['hp'] <= 0) ? "You can't attack someone when you have no health!" : $error; $error = ($ir['energy']<$energy) ? "You need to have at least 25% of your energy if you want to attack someone." : $error; $error = ($ir['jail'] > 0) ? "You can't attack someone if you are in jail." : $error; $error = ($ir['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'] == $ir['userid']) ? "You can't attack yourself." : $error; if($ir['equip_armor'] > 0) { $yourarmorstuff = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$ir['equip_armor'].")"); $dat = $db->fetch_row($yourarmorstuff); $defense = $dat['armor']; } else { $defense = 0; } $attacking_person = mysql_query("SELECT `u`.`userid`,`u`.`username`,`u`.`hp`,`u`.`maxhp`,`u`.`level`, " . "`u`.`money`,`u`.`location`,`u`.`hospital`,`u`.`jail`,`u`.`fedjail`,`u`.`gang`,`u`.`user_level`, " . "`u`.`equip_primary`,`u`.`equip_secondary`,`u`.`equip_armor`,`u`.`exp`,`us`.`strength`,`us`.`agility`, " . "`us`.`guard` " . "FROM `users` `u` " . "LEFT JOIN `userstats` `us` " . "ON `u`.`userid`=`us`.`userid` " . "WHERE (`u`.`userid`=".$_GET['ID'].")", $c) OR die(mysql_error()); $attack_person = mysql_fetch_array($attacking_person); $primarydamage = $db->query("SELECT * FROM `items` WHERE `itmid`=".$attack_person['equip_primary'].""); $ouch = $db->fetch_row($primarydamage); $prim = ($attack_person['strength']+$ouch['weapon'])-($ir['guard']+$defense); // PRIMARY "weapon" Damage. $secondarydamage = $db->query("SELECT * FROM `items` WHERE `itmid`=".$attack_person['equip_secondary'].""); $ouchy = $db->fetch_row($secondarydamage); $second = ($attack_person['strength']+$ouchy['weapon'])-($ir['guard']+$defense); // Secondary "weapon" Damage. if($attack_person['equip_primary'] > 0) { $killer = $prim; } elseif($attack_person['equip_primary'] = 0 && $attack_person['equip_secondary'] > 0) { $killer = $second; } else { $killer = $attack_person['strength'] - $ir['guard']; } if($attack_person['equip_armor'] > 0) { $ayourarmorstuff = $db->query("SELECT * FROM `items` WHERE (`itmid`=".$attack_person['equip_armor'].")"); $adat = $db->fetch_row($ayourarmorstuff); $adefense = $dat['armor']; } else { $defense = 0; } $aprimarydamage = $db->query("SELECT * FROM `items` WHERE `itmid`=".$ir['equip_primary'].""); $winn = $db->fetch_row($aprimarydamage); $aprim = ($ir['strength']+$winn['weapon'])-($attack_person['guard']+$defense); // PRIMARY "weapon" Damage. $asecondarydamage = $db->query("SELECT * FROM `items` WHERE `itmid`=".$ir['equip_secondary'].""); $win = $db->fetch_row($asecondary); $secondd = ($ir['strength']+$win['weapon'])-($attack_person['guard']+$defense); // Secondary "weapon" Damage. if($ir['equip_primary'] > 0) { $killers = $aprim; } elseif($ir['equip_primary'] = 0 && $ir['equip_secondary'] > 0) { $killers = $secondd; } else { $killers = $ir['strength'] - $ir['guard']; } if(!mysql_num_rows($attacking_person)) { echo "Invalid User Selected to attack."; $h->endpage(); exit; } $error = ($attack_person['location'] != $ir['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 = ($ir['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; $error = ($ir['gang'] == $attack_person['gang'] AND $ir['gang'] != 0) ? "You cant attack someone in the same clan as yourself!" : $error; $error = ($attack_person['hp'] <= 0) ? "This person has no health at the moment." : $error; $error = ($attack_person['fedjail'] > 1) ? "This person is in fed and cannot be attacked." : $error; $error = ($attack_person['user_level'] == 2) ? "Admins Cannot be attacked." : $error; if (isset($error)){ echo "".htmlentities(stripslashes($error)).""; $h->endpage(); exit; } $yourhp = $ir['hp']; $theirhp = $attack_person['hp']; echo "<center>Fight House</center> <center><font color=white>You are in a fight with ".$attack_person['username'].".</center> "; $wait = ($ir['agility'] > $attack_person['agility']) ? 1 : 0; while($yourhp > 0 && $theirhp > 0) { $damage = $killer; $damage = ($damage < 1) ? 1 : $damage; if($wait == 0) { $yourhp = $yourhp - $damage; echo "<font color=white><center> " . $attack_person['username'] . " hit you for " . $damage . " damage using their Fists. </center>"; // WEAPON STUFF HERE LATER. } else { $wait = 0; } if($yourhp > 0) { $damage = $killers; $damage = ($damage < 1) ? 1 : $damage; $theirhp = $theirhp - $damage; echo "<font color=white><center> You hit " . $attack_person['username'] . " for " . $damage . " damage using your Fists. </center> "; } if($theirhp <= 0){ // ATTACKER WINS AND UPDATES $winner = $ir['userid']; $theirhp = 0; $moneywon = floor($attack_person['money'] /10); $expwon = 150 - (25 * ($ir['level'] - $attack_person['level'])); $expwon = ($expwon < 0) ? 0 : $expwon; $newexp = $expwon + $ir['exp']; $newmoney = $ir['money'] + $moneywon; $result = mysql_query("UPDATE `users` SET `exp` = ".$newexp.", money = ".$newmoney." WHERE (`userid`=".$ir['userid'].")", $c) or die(mysql_error()); $newmoney = $attack_person['money'] - $moneywon; $result = mysql_query("UPDATE `users` SET `money` = ".$newmoney.", `hospital` = 10 WHERE (`userid`=".$attack_person['userid'].")", $c) or die(mysql_error()); event_add($attack_person['userid'], "You were hospitalized by ".$ir['username']." for 10 minutes."); echo "<font color=white><center>You hospitalized " . $attack_person['username'] . ". You gain $expwon exp and stole $".$moneywon." from " . $attack_person['username'] . ".</center>"; } if($yourhp <= 0){ // DEFENDER WINS AND UPDATES $winner = $attack_person['userid']; $yourhp = 0; $moneywon = floor($ir['money'] /10); $expwon = 100 - (25 * ($attack_person['level'] - $ir['level'])); $expwon = ($expwon < 0) ? 0 : $expwon; $newexp = $expwon + $attack_person['exp']; $newmoney = $attack_person['money'] + $moneywon; $result = mysql_query("UPDATE `users` SET `exp` = ".$newexp.", `money` = ".$newmoney." WHERE (`userid`=".$attack_person['userid'].")", $c) or die(mysql_error()); $newmoney = $ir['money'] - $moneywon; $result = mysql_query("UPDATE `users` SET `money` = '".$newmoney."',`hospital` = '20' WHERE (`userid`=".$ir['userid'].")", $c) or die(mysql_error()); event_add($ir['userid'], "You were hospitalized by ".$attack_person['username']." for 20 minutes."); echo "<center><font color=white>".$attack_person['username']." Hospitalized you and stole $".$moneywon." from you.</center>"; } } //UPDATE USERS $newenergy = $ir['energy'] - floor($ir['energy'] * .20); $result = mysql_query("UPDATE `users` SET `hp` = ".$theirhp." WHERE (`userid`=".$attack_person['userid'].")", $c) or die(mysql_error()); $result = mysql_query("UPDATE `users` SET `hp` = ".$yourhp.", `energy` = '".$newenergy."' WHERE (`userid`=".$ir['userid'].")", $c) or die(mysql_error()); echo "</td></tr>"; ?> Quote
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.