-
Posts
2,142 -
Joined
-
Last visited
-
Days Won
148
Content Type
Profiles
Forums
Events
Everything posted by Magictallguy
-
I've got one, runs perfectly fine and keep my 1.5TB HDD fairly clean - I keep my film collection on the NAS, and my games on my PC. 3 drives, about 2TB+ of space on my PC 1 NAS, 2 drives, about 5TB of space - no complaints here ^.^
-
Thanks for the fixes, I've been way too busy with the family
-
Replace with: printf("<td><a href='yourgang.php?action=staff&act2=decidehousereq&ID=%u&dir=accept' style='color:#79A888;'>Accept</a> · <a href='yourgang.php?action=staff&act2=decidehousereq&ID=%u&dir=decline' style='color:#AF4035;'>Decline</a></td>", $row['grrID'], $row['grrID']); Original code updated
-
How to find Sponsors and/or Developers for an idea
Magictallguy replied to Pavlos1316's topic in General
I'd be interested in working with Dave again, give me a shout :P -
As a professional musician, I can't help but listen (and sing to) music, no matter what I'm doing! DJK will probably remember that I wouldn't shut up when I want to visit him a couple of years ago xD
-
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(); ?>
-
May write that up, sounds like something I'd use
-
I know, but I was basically stating, in so many words, that you can have the entire auto credit shiz with the standard MC Craps
-
Getting back to the Donator with IPN request... You do realise, right, that "IPN" stands for "Instant Payment Notification" - that part is enabled on your PayPal itself. You can set up your system to automatically credit the donator pack/will potions using an IPN, but the IPN itself is *not* the auto-credit.. Screenshots on how to set up IPN http://screencast.com/t/ki1OQNPeP8I http://screencast.com/t/8p2fIggjOI http://screencast.com/t/ugF0Jf9jVP http://screencast.com/t/bKV6arHtRsTr - change to your own site
-
Fixed, I'll read the message now :P
-
I have details to around 15 sites.. Which one was yours? :P Edit: Nevermind, just noticed the file path
-
Tested for parse errors only Provided there are no more errors. This code has been completely fixed, and a little security has been put in place, alongside preventing E_WARNING | E_NOTICE errors ^.^ <?php include "globals.php"; ?><center><font size='4' face='Arial, Helvetica, sans-serif'>User images</font> <hr width='90%'><?php $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch($_GET['action']) { case 'view': view_image(); break; default: user_images(); break; } function user_images() { global $db, $ir, $h; $_GET['delete'] = isset($_GET['delete']) && ctype_digit($_GET['delete']) ? abs(@intval($_GET['delete'])) : null; if(!empty($_GET['delete'])) { $select = $db->query(sprintf("SELECT `imgID` FROM `userimages` WHERE ((`imgUSER` = %u) AND (`imgID` = %u))", $ir['userid'], $_GET['delete'])); if(!$db->num_rows($select)) { echo "Either that image doesn't exist, or it's not yours"; $h->endpage(); exit; } $db->query(sprintf("DELETE FROM `userimages` WHERE (`imgID` = %u)", $_GET['delete'])); echo "Image deleted from gallery.<hr width='90%'>"; } $_GET['set'] = isset($_GET['set']) && ctype_digit($_GET['set']) ? abs(@intval($_GET['set'])) : null; if(!empty($_GET['set'])) { $image = $db->query(sprintf("SELECT `imgURL` FROM `userimages` WHERE ((`imgID` = %u) AND (`imgUSER` = %u))", $ir['userid'], $_GET['set'])); if(!$db->num_rows($image)) { echo "Either that image doesn't exist, or it's not yours"; $h->endpage(); exit; } $db->query(sprintf("UPDATE `users` SET `display_pic` = '%s' WHERE (`userid` = %u)", $db->fetch_single($image), $ir['userid'])); echo "New display image set.<hr width='90%'>"; } $_GET['XID'] = isset($_GET['XID']) && ctype_digit($_GET['XID']) ? abs(@intval($_GET['XID'])) : null; if(empty($_GET['XID'])) { echo "No user submitted<hr width='90%'>> <a href='explore.php'>Back to city</a><hr width='90%'>"; $h->endpage(); exit; } $select = $db->query(sprintf("SELECT `ui`.`imgUSER`, `u`.`username` " . "FROM `userimages` AS `ui` " . "LEFT JOIN `users` AS `u` ON (`ui`.`imgUSER` = `u`.`userid`) " . "WHERE (`ui`.`imgUSER` = %u) ", $_GET['XID'])); if(!$db->num_rows($select)) { echo "Either that player doesn't exist, or they haven't uploaded any images"; $h->endpage(); exit; } $player = $db->fetch_row($select); echo "<strong>",stripslashes(htmlspecialchars($player['username'])),"'s uploaded images</strong>"; if(!$db->num_rows($q)) { ?><table width='90%' bgcolor=#DFDFDF><tr><td><center>This user has no uploaded images</center></td></tr></table><hr width='90%'>> <a href='viewuser.php?u=<?php echo $y['userid']; ?>'>Back to profile</a><hr width='90%'><?php $h->endpage(); exit; } echo "<table width='90%' bgcolor=#DFDFDF cellpadding='3'><tr>"; $br = 0; $cn = 0; $div = ''; while($row = $db->fetch_row($select)) { if($br == 3) { $div = "</tr><tr>"; $br* = 0; } echo "<td align='center'><strong>#$cn Profile image</strong><a href='userimages.php?action=view&ID=",$row['imgUSER'],"'>View</a>"; if($_GET['XID'] == $ir['userid']) { echo "[<a href='userimages.php?XID=",$row['imgUSER'],"'>Delete</a>] [<a href='userimages.php?XID=",$row['imgUSER'],"'>Set Image</a>]"; } echo "</td>",$div; ++$br; ++$cn; } echo "</tr></table><hr width='90%'>> <a href='viewuser.php?u=",$player['imgUSER'],"'>Back to profile</a><hr width='90%'>"; } function view_image() { global $db, $ir, $h; $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; $e = $db->query(sprintf("SELECT `imgURL` FROM `userimages` WHERE (`imgID` = %u)", $_GET['ID'])); if(!$db->num_rows($e)) { echo "Either that player doesn't exist, or they have no images"; $h->endpage(); exit; } echo "<img src=",stripslashes($db->fetch_single($e))," /><hr width='90%'>> <a href='userimages.php?XID=",$_GET['ID'],">Back to images</a><hr width='90%'>"; } $h->endpage(); ?>
-
Working on it now.. Just really struggling with a 5 month old boy who's just found his voice -.-
-
Untested Replace the gang_kidnap() function in yourgang.php with this: function cleanKill($msg = 'Something happened..') { global $h; ?><div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><?php echo $msg; $h->endpage(); exit; } function gang_event_add($gangID, $event) { global $db; $db->query(sprintf("INSERT INTO `gangevents` VALUES ('', %u, %s, '%s')", $gangID, time(), $db->escape($event))); } function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } function player($id, $escape = 0) { global $db; $selectPlayer = $db->query(sprintf("SELECT `username` FROM `users` WHERE (`userid` = %u)", $id)); return sprintf("<a href='viewuser.php?u=%u'>%s</a> [%s]", $id, format($db->fetch_single($selectPlayer)), format($id)); } function gang_kidnap() { global $db, $ir, $h, $gangdata; $_GET['u'] = isset($_GET['u']) && ctype_digit($_GET['u']) ? abs(@intval($_GET['u'])) : null; if(empty($_GET['u'])) cleanKill("You didn't select a valid gang member"); if(!$ir['gang']) cleanKill("You're not in a gang, you can't do this"); if($ir['gang'] == $gangdata['gangID']) cleanKill("You can't kidnap your own members..."); $select = $db->query(sprintf("SELECT `gangID` FROM `gangs` WHERE ((`gangPRESIDENT` = %1\$u) OR (`gangVICEPRES` = %1\$u))", $ir['userid'])); if(!$db->num_rows($select)) cleanKill("You're not the President or Vice President of your gang. You can't do that"); if(in_array($_GET['u'], array($gangdata['gangPRESIDENT'], $gangdata['gangVICEPRES']))) cleanKill("You can't kidnap the President or Vice President"); $select = $db->query(sprintf("SELECT `gang` FROM `users` WHERE (`userid` = %u)", $_GET['u'])); if(!$db->num_rows($select)) cleanKill("That player doesn't exist"); if($db->fetch_single($select) != $gangdata['gangID']) cleanKill(player($_GET['u'])." isn't in that gang"); $selectRansoms = $db->query(sprintf("SELECT `gkID` FROM `gangKidnaps` WHERE (`gkUser` = %u)", $_GET['u'])); if($db->num_rows($selectRansom)) cleanKill(player($_GET['u'])." is already being held ransom"); if(!isset($_POST['submit'])) { echo "<h3>Kidnapping ",player($_GET['u'])," from ",format($gangdata['gangNAME']),"</h3>"; ?><form action='gangs.php?action=view&ID=<? echo $gangdata['gangID']; ?>&u=<? echo $_GET['u']; ?>' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Ransom</th> <td width='55%'>$<input type='number' name='ransom' value='2000' /></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='submit' value='Kidnap' /></td> </tr> </table> </form><? } else { $_POST['ransom'] = isset($_POST['ransom']) && ctype_digit($_POST['ransom']) ? abs(@intval($_POST['ransom'])) : null; if(empty($_POST['ransom'])) cleanKill("You didn't enter a valid ransom"); $chance = mt_rand(1, 5); if(in_array($chance, array(1, 3))) { $db->query(sprintf("INSERT INTO `gangKidnaps` VALUES ('', %u, %u, %u, %s, %u)", $ir['gang'], $gangdata['gangID'], $_GET['u'], time(), $_POST['ransom'])); $gEventTheirs = sprintf("%s has kidnapped %s from %s. You have 1 hour to pay the ransom", player($ir['userid']), player($_GET['u']), format($gangdata['gangNAME'])); $gEventMine = sprintf("%s has kidnapped %s from %s. They have 1 hour to pay the ransom", player($ir['userid']), player($_GET['u']), format($gangdata['gangNAME'])); echo "You've kidnapped ",player($_GET['u'])," from ",format($gangdata['gangNAME']); } else if(in_array($chance, array(2, 4))) { $getAnother = $db->query(sprintf("SELECT `userid` FROM `users` WHERE ((`gang` = %u) AND (`userid` != %u)) ORDER BY RAND() LIMIT 1", $gangdata['gangID'], $_GET['u'])); if(!$db->num_rows($getAnother)) echo "You failed to kidnap ",player($_GET['u']); else { $another = $db->fetch_single($getAnother); $db->query(sprintf("INSERT INTO `gangKidnaps` VALUES ('', %u, %u, %u, %s, %u)", $ir['gang'], $ir['gang'], $another, time(), $_POST['ransom'])); $gEventTheirs = sprintf("%s attempted to kidnap %s from %s but failed. Instead, they got %s", player($ir['userid']), player($_GET['u']), player($another)); $gEventMine = sprintf("%s attempted to kidnap %s from %s but failed. Instead, they got %s", player($ir['userid']), player($_GET['u']), player($another)); echo "You failed to kidnap ",player($_GET['u']),", but you managed to get ",player($another)," instead"; } } else { $gEventTheirs = sprintf("%s attempted to kidnap %s from %s, but failed", player($ir['userid']), player($_GET['u']), format($gangdata['gangNAME'])); $gEventMine = sprintf("%s attempted to kidnap %s from %s, but failed", player($ir['userid']), player($_GET['u']), format($gangdata['gangNAME'])); } gang_event_add($gangdata['gangID'], $gEventTheirs); gang_event_add($ir['gang'], $gEventMine); } } Any bugs, post here Thank you :)
-
100% currently, I can easily modify it to have the chance effect if you'd like?
-
Fixed Converted
-
Perhaps he likes the v1 code structure (why, I don't know..), and also likes the features of v2. Those 3 column additions to the users table really isn't that much, and the conversion was simple enough.. There's enough of v2 floating around to grab a copy
-
I offer no guarantee that the code I've posted below will work as expected.. v1 attack from v2, with multiple bug/security/HTML fixes.. <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $is = mysql_query("SELECT `u`.*, `us`.* " . "FROM `users` AS `u` " . "LEFT JOIN `userstats` AS `us` ON (`u`.`userid` = `us`.`userid`) " . "WHERE (`u`.`userid` = " . $userid . ")", $c) or exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); check_level(); $fm = money_formatter($ir['money']); $cm = money_formatter($ir['crystals'], ''); $lv = date('F j, Y, g:i a', $ir['laston']); $h->userdata($ir, $lv, $fm, $cm); function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; if(!$_GET['ID']) { echo "*** you doing, bro?<br /><a href='index.php'>Back</a>"; $h->endpage(); exit; } if($_GET['ID'] == $userid) { echo "Only the crazy attack themselves.<br /><a href='index.php'>Back</a>"; $h->endpage(); exit; } if($ir['hp'] <= 1) { echo "Only the crazy attack when their unconscious.<br /><a href='index.php'>Back</a>"; $h->endpage(); exit; } if(isset($_SESSION['attacklost'])) { echo "Only the losers of all their EXP attack when they've already lost.<br /><a href='index.php'>Back</a>"; $_SESSION['attacklost'] = 0; $h->endpage(); exit; } //get player data $q = mysql_query("SELECT `u`.*, `us`.* " . "FROM `users` AS `u` " . "LEFT JOIN `userstats` AS `us` ON (`u`.`userid` = `us`.`userid`) " . "WHERE (`u`.`userid` = " . $_GET['ID'] . ")", $c) or exit(mysql_error()); if(!mysql_num_rows($q)) { echo "That player doesn't exist"; $h->endpage(); exit; } $them = mysql_fetch_assoc($q); $myabbr = ($ir['gender'] == "Male") ? "his" : "her"; $oabbr = ($ir['gender'] == "Male") ? "his" : "her"; if($ir['attacking'] && $ir['attacking'] != $_GET['ID']) { echo "Bad, bad, bad girl.<br /><a href='index.php'>Back</a>"; $_SESSION['attacklost'] = 0; $h->endpage(); exit; } if($them['hp'] == 1) { echo "This player is unconscious.<br /><a href='index.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($them['hospital']) { echo "This player is in hospital.<br /><a href='index.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($ir['hospital']) { echo "While in hospital you can't attack.<br /><a href='hospital.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($them['jail']) { echo "This player is in jail.<br /><a href='index.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($ir['jail']) { echo "While in jail you can't attack.<br /><a href='jail.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } if($them['travelling']) { echo "That player is travelling.<br /><a href='index.php'>> Back</a>"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } echo "<table width='100%'><tr><td colspan='2' align='center'>"; if(isset($_GET['wepid'])) { if(!isset($_SESSION['attacking']) && $ir['attacking'] == 0) { if($ir['energy'] >= $ir['maxenergy'] / 2) { $ir['energy'] -= floor($ir['maxenergy'] / 2); mysql_query(sprintf("UPDATE `users` SET `energy` = `energy` - %u WHERE (`userid` = %u)", floor($ir['maxenergy'] / 2), $userid), $c) or exit(mysql_error()); $_SESSION['attacklog'] = ""; $_SESSION['attackdmg'] = 0; } else { echo "You can only attack someone when you have 50% energy"; $h->endpage(); exit; } } $_SESSION['attacking'] = 1; $ir['attacking'] = $them['userid']; mysql_query("UPDATE `users` SET `attacking` = " . $ir['attacking'] . " WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); $_GET['wepid'] = isset($_GET['wepid']) && ctype_digit($_GET['wepid']) ? abs(@intval($_GET['wepid'])) : null; $_GET['nextstep'] = isset($_GET['nextstep']) && ctype_digit($_GET['nextstep']) ? abs(@intval($_GET['nextstep'])) : null; //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.<br /><a href='index.php'>> Home</a>"; mysql_query("UPDATE `users` SET `exp` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); $h->endpage(); exit; } $qo = mysql_query("SELECT * FROM `items` WHERE (`itmid` = " . $_GET['wepid'] . ")", $c) or exit(mysql_error()); if(!mysql_num_rows($qo)) { echo "That item doesn't exist"; $h->endpage(); $_SESSION['attacking'] = 0; $ir['attacking'] = 0; mysql_query("UPDATE `users` SET `attacking` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); exit; } $r1 = mysql_fetch_assoc($qo); $mydamage = (int) (($r1['weapon'] * $ir['strength'] / ($them['guard'] / 1.5)) * (mt_rand(8000, 12000) / 10000)); $hitratio = max(10, min(60 * $ir['agility'] / $them['agility'], 95)); if(mt_rand(1, 100) <= $hitratio) { $q3 = mysql_query("SELECT `armor` FROM `items` WHERE (`itmid` = " . $them['equip_armor'] . ") ORDER BY RAND()"); if(mysql_num_rows($q3)) { $mydamage -= mysql_result($q3, 0, 0); } $mydamage = ($mydamage < -100000) ? abs($mydamage) : 1; $crit = mt_rand(1, 40); if($crit == 17) { $mydamage *= rand(20, 40) / 10; } else if($crit == 25 or $crit == 8) { $mydamage /= (mt_rand(20, 40) / 10); } $mydamage = round($mydamage); $them['hp'] -= $mydamage; if($them['hp'] == 1) { $them['hp'] = 0; $mydamage += 1; } mysql_query("UPDATE `users` SET `hp` = `hp` - $mydamage WHERE (`userid` = " . $_GET['ID'] . ")", $c) or exit(mysql_error()); echo "<span style='color:red;'>", $_GET['nextstep'], ". Using your ", format($r1['itmname']), " you hit ", format($them['username']), " doing ", format($mydamage), " damage (", format($them['hp']), ")</span><br />\n"; $_SESSION['attackdmg'] += $mydamage; $_SESSION['attacklog'] .= "<span style='color:red;'>" . $_GET['nextstep'] . ". Using " . $myabbr . " " . format($r1['itmname']) . ". " . format($ir['username']) . " hit " . format($them['username']) . " doing " . format($mydamage) . " damage (" . format($them['hp']) . ")</span><br />\n"; } else { echo "<span style='color:red;'>", $_GET['nextstep'], ". You tried to hit ", format($them['username']), " but missed (", format($them['hp']), ")</span><br />\n"; $_SESSION['attacklog'] .= "<span style='color:red;'>" . $_GET['nextstep'] . ". " . format($ir['username']) . " tried to hit " . format($them['username']) . " but missed (" . format($them['hp']) . ")</span><br />\n"; } if($them['hp'] <= 0) { $them['hp'] = 0; $_SESSION['attackwon'] = $_GET['ID']; mysql_query("UPDATE `users` SET `hp` = 0 WHERE (`userid` = " . $_GET['ID'] . ")", $c) or exit(mysql_error()); echo "<br /><strong>What do you want to do with ", format($them['username']), " now?</strong><br /> <form action='attackwon.php?ID=", $_GET['ID'], "' method='post'><input type='submit' value='Mug Them' /></form> <form action='attackbeat.php?ID=", $_GET['ID'], "' method='post'><input type='submit' value='Hospitalize Them' /></form> <form action='attacktake.php?ID=", $_GET['ID'], "' method='post'><input type='submit' value='Leave Them' /></form>"; } else { //choose opp gun $eq = mysql_query(sprintf("SELECT * FROM `items` WHERE (`itmid` IN(%u, %u))", $them['equip_primary'], $them['equip_secondary']), $c) or exit(mysql_error()); if(!mysql_num_rows($eq)) { $wep = "Fists"; $dam = (int) ((((int) ($them['strength'] / $ir['guard'] / 100)) + 1) * (mt_rand(8000, 12000) / 10000)); } else { $cnt = 0; while($r = mysql_fetch_assoc($eq)) { $enweps[] = $r; $cnt++; } $weptouse = mt_rand(0, $cnt - 1); $wep = $enweps[$weptouse]['itmname']; $dam = (int) (($enweps[$weptouse]['weapon'] * $them['strength'] / ($ir['guard'] / 1.5)) * (mt_rand(8000, 12000) / 10000)); } $hitratio = max(10, min(60 * $them['agility'] / $ir['agility'], 95)); if(mt_rand(1, 100) <= $hitratio) { $q3 = mysql_query("SELECT `armor` FROM `items` WHERE (`itmid` = " . $ir['equip_armor'] . ") ORDER BY RAND()"); if(mysql_num_rows($q3)) { $dam -= mysql_result($q3); } if($dam < -100000) { $dam = abs($dam); } else if($dam < 1) { $dam = 1; } $crit = rand(1, 40); if($crit == 17) { $dam *= rand(20, 40) / 10; } else if($crit == 25 or $crit == 8) { $dam /= (mt_rand(20, 40) / 10); } $dam = round($dam); $ir['hp'] -= $dam; if($ir['hp'] == 1) { $dam += 1; $ir['hp'] = 0; } mysql_query("UPDATE `users` SET `hp` = `hp` - " . $dam . " WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); $ns = $_GET['nextstep'] + 1; echo "<span style='color:blue;'>", $ns, ". Using ", $oabbr, " ", format($wep), " ", format($them['username']), " hit you doing ", format($dam), " damage (", format($ir['hp']), ")</span><br />\n"; $_SESSION['attacklog'] .= "<span style='color:blue;'>" . $ns . ". Using " . $oabbr . " " . format($wep) . " " . format($them['username']) . " hit " . format($ir['username']) . " doing " . format($dam) . " damage (" . format($ir['hp']) . ")</span><br />\n"; } else { $ns = $_GET['nextstep'] + 1; echo "<span style='color:red;'>", $ns, ". ", format($them['username']), " tried to hit you but missed (", format($ir['hp']), ")</span><br />\n"; $_SESSION['attacklog'] .= "<span style='color:blue;'>" . $ns . ". " . format($them['username']) . " tried to hit " . format($ir['username']) . " but missed (" . format($ir['hp']) . ")</span><br />\n"; } if($ir['hp'] <= 0) { $ir['hp'] = 0; $_SESSION['attacklost'] = 1; mysql_query("UPDATE `users` SET `hp` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); echo "<form action='attacklost.php?ID=", $_GET['ID'], "' method='post'><input type='submit' value='Continue' />"; } } } else if($them['hp'] < 5) { echo "You can only attack those who have health"; $h->endpage(); exit; } else if($ir['gang'] == $them['gang'] && $ir['gang'] > 0) { echo "You are in the same gang as ", format($them['username']), "! What are you smoking today dude!"; $h->endpage(); exit; } else if($ir['energy'] < $ir['maxenergy'] / 2) { echo "You can only attack someone when you have 50% energy"; $h->endpage(); exit; } else if($ir['location'] != $them['location']) { echo "You can only attack someone in the same location!"; $h->endpage(); exit; } echo "</td></tr>"; if($ir['hp'] <= 0 || $them['hp'] <= 0) { echo "</table>"; } else { $vars['hpperc'] = round($ir['hp'] / $ir['maxhp'] * 100); $vars['hpopp'] = 100 - $vars['hpperc']; $vars2['hpperc'] = round($them['hp'] / $them['maxhp'] * 100); $vars2['hpopp'] = 100 - $vars2['hpperc']; $mw = mysql_query(sprintf("SELECT * FROM `items` WHERE (`itmid` IN(%u, %u)", $ir['equip_primary'], $ir['equip_secondary']), $c) or exit(mysql_error()); echo "<tr><td colspan='2' align='center'>Attack with:<br />"; if(mysql_num_rows($mw)) { while($r = mysql_fetch_assoc($mw)) { $ns = (!$_GET['nextstep']) ? 1 : $_GET['nextstep'] + 2; if($r['itmid'] == $ir['equip_primary']) { echo "<strong>Primary Weapon:</strong> "; } if($r['itmid'] == $ir['equip_secondary']) { echo "<strong>Secondary Weapon:</strong> "; } echo "<a href='attack.php?nextstep=", $ns, "&ID=", $_GET['ID'], "&wepid=", $r['itmid'], "'>", format($r['itmname']), "</a><br />"; } } else { echo "You have nothing to fight with."; } echo "</table>"; echo "<table width='50%' align='center'> <tr> <td align='right'>Your Health:</td> <td><img src='greenbar.png' width='", $vars['hpperc'], "' height='10' /><img src='redbar.png' width='", $vars['hpopp'], "' height='10' /></td> </tr> <tr> <td align='right'>Opponents Health:</td> <td><img src='greenbar.png' width='", $vars2['hpperc'], " height='10' /><img src='redbar.png' width='", $vars2['hpopp'], "' height='10' /></td> </tr> </table>"; } $h->endpage(); ?> inventory.php <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $is = mysql_query("SELECT `u`.*, `us`.* " . "FROM `users` AS `u` " . "LEFT JOIN `userstats` AS `us` ON (`u`.`userid` = `us`.`userid`) " . "WHERE (`u`.`userid` = " . $userid . ")", $c) or exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); check_level(); $fm = money_formatter($ir['money']); $cm = money_formatter($ir['crystals'], ''); $lv = date('F j, Y, g:i a', $ir['laston']); $h->userdata($ir, $lv, $fm, $cm); $h->menuarea(); function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } $equp = array(); $q = mysql_query(sprintf("SELECT * FROM `items` WHERE (`itmid` IN(%u, %u, %u))", $ir['equip_primary'], $ir['equip_secondary'], $ir['equip_armor']), $c) or exit(mysql_error()); echo "<h3>Equipped Items</h3><hr />"; while($r = mysql_fetch_assoc($q)) { $equip[$r['itmid']] = $r; } echo "<table width='75%' cellspacing='1' class='table'> <tr> <th>Primary Weapon</th> <td>"; if($equip[$ir['equip_primary']]['itmid']) { echo format($equip[$ir['equip_primary']]['itmname']) , "</td><td><a href='unequip.php?type=equip_primary'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } echo "</tr> <tr> <th>Secondary Weapon</th> <td>"; if($equip[$ir['equip_secondary']]['itmid']) { echo format($equip[$ir['equip_secondary']]['itmname']) , "</td><td><a href='unequip.php?type=equip_secondary'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } echo "</tr> <tr> <th>Armor</th> <td>"; if($equip[$ir['equip_armor']]['itmid']) { echo format($equip[$ir['equip_armor']]['itmname']) , "</td><td><a href='unequip.php?type=equip_armor'>Unequip Item</a></td>"; } else { echo "None equipped.</td><td> </td>"; } echo "</tr> </table><hr /> <h3>Inventory</h3><hr />"; $inv = mysql_query("SELECT `iv`.*, `i`.*, `it`.* " . "FROM `inventory` AS `iv` " . "LEFT JOIN `items` AS `i` ON (`iv`.`inv_itemid` = `i`.`itmid`) " . "LEFT JOIN `itemtypes` AS `it` ON (`i`.`itmtype` = `it`.`itmtypeid`) " . "WHERE (`iv`.`inv_userid` = ".$userid.") " . "ORDER BY `i`.`itmtype` ASC, `i`.`itmname` ASC", $c) or exit(mysql_error()); if(!mysql_num_rows($inv)) { echo "<strong>You have no items!</strong>"; $h->endpage(); exit; } echo "<strong>Your items are listed below.</strong><br /> <table width='100%' class='table' border='0' cellspacing='1'> <tr> <td class='h'>Item</td> <td class='h'>Sell Value</td> <td class='h'>Total Sell Value</td> <td class='h'>Links</td> </tr>"; $lt = ""; while($i = mysql_fetch_assoc($inv)) { if($lt != $i['itmtypename']) { $lt = $i['itmtypename']; echo "\n<tr><td colspan=4><strong>",format($lt),"</strong></td></tr>"; } if($i['weapon']) { $i['itmname'] = "<span style='color:red;'>*</span>" . format($i['itmname']); } if($i['armor']) { $i['itmname'] = "<span style='color:green;'>*</span>" . format($i['itmname']); } echo "<tr><td>{$i['itmname']}"; if($i['inv_qty'] > 1) { echo " x",format($i['inv_qty']); } echo "</td><td>\$",format($i['itmsellprice']),"</td><td>"; echo "$" . format($i['itmsellprice'] * $i['inv_qty']); echo "</td><td>[<a href='iteminfo.php?ID=",$i['itmid'],"'>Info</a>] [<a href='itemsend.php?ID=",$i['inv_id'],"'>Send</a>] [<a href='itemsell.php?ID=",$i['inv_id'],"'>Sell</a>] [<a href='imadd.php?ID=",$i['inv_id'],"'>Add To Market</a>]"; if($i['effect1_on'] || $i['effect2_on'] || $i['effect3_on']) { echo " [<a href='itemuse.php?ID=",$i['inv_id'],"'>Use</a>]"; } if($i['weapon']) { echo " [<a href='equip_weapon.php?ID=",$i['inv_id'],"'>Equip as Weapon</a>]"; } if($i['armor']) { echo " [<a href='equip_armor.php?ID=",$i['inv_id'],"'>Equip as Armor</a>]"; } echo "</td></tr>"; } echo "</table><small><strong>NB:</strong> Items with a small red </small><span style='color:red;'>*</span><small> next to their name can be used as weapons in combat.<br />Items with a small green </small><span style='color:green;'>*</span><small> next to their name can be used as armor in combat.</small>"; $h->endpage(); ?> equip_armor.php <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $is = mysql_query("SELECT `u`.*, `us`.* " . "FROM `users` AS `u` " . "LEFT JOIN `userstats` AS `us` ON (`u`.`userid` = `us`.`userid`) " . "WHERE (`u`.`userid` = " . $userid . ")", $c) or exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); check_level(); $fm = money_formatter($ir['money']); $cm = money_formatter($ir['crystals'], ''); $lv = date('F j, Y, g:i a', $ir['laston']); $h->userdata($ir, $lv, $fm, $cm); $h->menuarea(); function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; $id = mysql_query("SELECT `iv`.*, `it`.* " . "FROM `inventory` AS `iv` " . "LEFT JOIN `items` AS `it` ON (`iv`.`inv_itemid` = `it`.`itmid`) " . "WHERE ((`iv`.`inv_id` = ".$_GET['ID'].") AND (`iv`.`inv_userid` = ".$userid.")) LIMIT 1", $c) or exit(mysql_error()); if(!mysql_num_rows($id)) { echo "Invalid item ID"; $h->endpage(); exit; } $r = mysql_fetch_assoc($id); if(!$r['armor']) { echo "This item cannot be equipped to this slot."; $h->endpage(); exit; } if(isset($_GET['type'])) { if($_GET['type'] != 'equip_armor') { echo "This slot ID is not valid."; $h->endpage(); exit; } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); mysql_query("UPDATE `users` SET `".$_GET['type']."` = ".$r['itmid']." WHERE (`userid` = ".$userid.")", $c) or exit(mysql_error()); echo "Your ",format($r['itmname'])," has been equipped successfully."; } else { echo "<h3>Equip Armor</h3><hr /> <form action='equip_armor.php' method='get'> <input type='hidden' name='ID' value='",$_GET['ID'],"' /> Click Equip Armor to equip ",format($r['itmname'])," as your armor, if you currently have any armor equipped it will be removed back to your inventory.<br /> <input type='hidden' name='type' value='equip_armor' /> <input type='submit' value='Equip Armor' /></form>"; } $h->endpage(); ?> equip_weapon.php <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $is = mysql_query("SELECT `u`.*, `us`.* " . "FROM `users` AS `u` " . "LEFT JOIN `userstats` AS `us` ON (`u`.`userid` = `us`.`userid`) " . "WHERE (`u`.`userid` = " . $userid . ")", $c) or exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); check_level(); $fm = money_formatter($ir['money']); $cm = money_formatter($ir['crystals'], ''); $lv = date('F j, Y, g:i a', $ir['laston']); $h->userdata($ir, $lv, $fm, $cm); $h->menuarea(); function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } $_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null; $id = mysql_query("SELECT `iv`.*, `it`.* " . "FROM `inventory` AS `iv` " . "LEFT JOIN `items` AS `it` ON (`iv`.`inv_itemid` = `it`.`itmid`) " . "WHERE ((`iv`.`inv_id` = ".$_GET['ID'].") AND (`iv`.`inv_userid` = ".$userid.")) LIMIT 1", $c) or exit(mysql_error()); if(!mysql_num_rows($id)) { echo "Invalid item ID"; $h->endpage(); exit; } $r = mysql_fetch_assoc($id); if(!$r['weapon']) { echo "This item cannot be equipped to this slot."; $h->endpage(); exit; } if(isset($_GET['type'])) { if(!in_array($_GET['type'], array('equip_primary', 'equip_secondary'))) { echo "This slot ID is not valid."; $h->endpage(); exit; } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); mysql_query("UPDATE `users` SET `".$_GET['type']."` = ".$r['itmid']." WHERE (`userid` = ".$userid.")", $c) or exit(mysql_error()); echo "Your ",format($r['itmname'])," has been equipped successfully."; } else { echo "<h3>Equip Weapon</h3><hr /> <form action='equip_weapon.php' method='get'> <input type='hidden' name='ID' value='",$_GET['ID'],"' /> Please choose the slot to equip ",format($r['itmname'])," to, if there is already a weapon in that slot, it will be removed back to your inventory.<br /> <input type='radio' name='type' value='equip_primary' checked='checked' /> Primary<br /> <input type='radio' name='type' value='equip_secondary' /> Secondary<br /> <input type='submit' value='Equip Weapon' /></form>"; } $h->endpage(); ?> I don't know what v1 SQLs exist.. So I'll stick the SQLs needed here anyway ALTER TABLE `users` ADD ( `equip_primary` INT( 11 ) NOT NULL DEFAULT 0, `equip_secondary` INT( 11 ) NOT NULL DEFAULT 0, `equip_armor` INT( 11 ) NOT NULL DEFAULT 0 );
-
1 plug and play announcements <?php session_start(); require(__DIR__ . '/global_func.php'); if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require(__DIR__ . '/header.php'); $h = new headers; $h->startheaders(); require(__DIR__ . '/mysql.php'); global $c; $is = mysql_query("SELECT `u`.*, `us`.* " . "FROM `users` AS `u` " . "LEFT JOIN `userstats` AS `us` ON (`u`.`userid` = `us`.`userid`) " . "WHERE (`u`.`userid` = " . $userid . ")", $c) or exit(mysql_error()); if(!mysql_num_rows($is)) { echo "There appears to be an issue with your account"; $h->endpage(); exit; } $ir = mysql_fetch_assoc($is); check_level(); $fm = money_formatter($ir['money']); $cm = money_formatter($ir['crystals'], ''); $lv = date('F j, Y, g:i a', $ir['laston']); $h->userdata($ir, $lv, $fm, $cm); $h->menuarea(); $ac = $ir['new_announcements']; $q = mysql_query("SELECT * FROM `announcements` ORDER BY `a_time` DESC", $c) or exit(mysql_error()); ?><table width='80%' cellspacing='1' class='table'> <tr> <th width='30%'>Time</th> <th width='70%'>Announcement</th> </tr><?php if(!mysql_num_rows($q)) { ?><tr><td colspan='2' style='text-align:center;'>There are no announcements</td></tr><?php } else { while($r = mysql_fetch_assoc($q)) { if($ac > 0) { $ac--; $new = '<br /><strong>New!</strong>'; } else { $new = ''; } ?><tr style='vertical-align:top;'> <td><?php echo date('F j Y, g:i:s a', $r['a_time']), $new; ?></td> <td><?php echo nl2br(stripslashes($r['a_text'])); ?></td> </tr><?php } } echo "</table>"; if($ir['new_announcements']) { mysql_query("UPDATE `users` SET `new_announcements` = 0 WHERE (`userid` = " . $userid . ")", $c) or exit(mysql_error()); } $h->endpage(); ?> Staff side (based on the v1 I "grew up" with): Edit admin.php Add function announcements() { global $ir, $c, $h; if($ir['user_level'] != 2) { echo "You don't have access to this"; $h->endpage(); exit; } if(isset($_POST['text']) && !empty($_POST['text'])) { mysql_query(sprintf("INSERT INTO `announcements` VALUES('%s', %s)", mysql_real_escape_string($_POST['text'], $c), time()), $c) or exit(mysql_error()); mysql_query("UPDATE `users` SET `new_announcements` = `new_announcements` + 1", $c) or exit(mysql_error()); echo "Announcement added!<br />> <a href='admin.php'>Back</a>"; } else { ?>Adding an announcement...<br /> Please try to make sure the announcement is concise and covers everything you want it to. <form action='staff.php?action=announce' method='post'> <table class='table' width='75%' cellspacing='1'> <tr> <th width='45%'>Announcement text</th> <td width='55%'><textarea name='text' rows='10' cols='70'></textarea></td> </tr> <tr> <td colspan='2' style='text-align:center;'><input type='submit' value='Add Announcement' /></td> </tr> </table> </form><?php } } SQLs CREATE TABLE IF NOT EXISTS `announcements` ( `a_text` TEXT NOT NULL, `a_time` INT( 11 ) NOT NULL DEFAULT 0 ); ALTER TABLE `users` ADD `new_announcements` INT( 11 ) NOT NULL DEFAULT 0;
-
. Looking around, he
-
With a name of "The Coder", I do believe a simple conversion should be easy for you ;) View this topic for a short How To. Be sure to copy over the SQL structure too ;)
-
garage.php <?php include(__DIR__ . '/globals.php'); echo "<!-- Created by Magictallguy -->"; $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch($_GET['action']) { case 'buy': buyGarage(); break; case 'upgradegarage': upgradeGarage(); break; case 'upgrade': upgradeCar(); break; case 'sell': sellCar(); break; default: carIndex(); break; } function error($msg) { global $h; echo "<div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; $h->endpage(); exit; } function success($msg) { echo "<div style='color: #4F8A10;background-color: #DFF2BF;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>Success!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>"; } function format($str, $dec = 0) { return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str)); } function carIndex() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { header("Location: garage.php?action=buy"); exit; } $garage = $db->fetch_row($selectGarage); $selectCars = $db->query(sprintf("SELECT `pc`.*, `c`.`cName`, `c`.`cDesc` " . "FROM `playerCars` AS `pc` " . "LEFT JOIN `cars` AS `c` ON (`c`.`cID` = `pc`.`pcCarID`) " . "WHERE (`pc`.`pcUser` = %u) " . "ORDER BY `c`.`cName` ASC", $ir['userid'])); ?><h3>Cars: Your <? echo format($garage['gTypeName']); ?></h3> <a href='garage.php?action=upgradegarage'>Upgrade your <? echo format($garage['gTypeName']); ?></a><br /> You have <? echo format($db->num_rows($selectCars)),'/',format($garage['pgCapacity']); ?> cars<br /> <table class='table' width='100%' cellspacing='1'> <tr> <th width='45%'>Car/Description</th> <th width='45%'>Stats</th> <th width='10%'>Links</th> </tr><? if(!$db->num_rows($selectCars)) { echo "<tr><td colspan='3' class='center'>You don't have any cars<br /><a href='cardealer.php'>Go buy one</a></td></tr>"; } else { while($car = $db->fetch_row($selectCars)) { ?><tr> <td><? echo format($car['cName']); ?><br /><br /><? echo nl2br(format($car['cDesc'])); ?></td> <td><table class='table' width='100%' cellspacing='1'> <tr> <th width='20%'>Speed</th> <td width='30%'><? echo format($car['pcSpeed']); ?></td> <th width='20%'>Handling</th> <td width='30%'><? echo format($car['pcHandling']); ?></td> </tr> <tr> <th width='20%'>Acceleration</th> <td width='30%'><? echo format($car['pcAccel']); ?></td> <th width='20%'>Braking</th> <td width='30%'><? echo format($car['pcBrake']); ?></td> </tr> </table></td> <td><a href='garage.php?action=upgrade&ID=<? echo $car['pcID']; ?>'>Upgrade</a> · <a href='garage.php?action=sell&ID=<? echo $car['pcID']; ?>'>Sell</a><br /><a href='carrace.php?ID=<? echo $car['pcID']; ?>'>Race</a></td> </tr><? } } echo "</table>"; } function upgradeCar() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { header("Location: garage.php?action=buy"); exit; } $garage = $db->fetch_row($selectGarage); if(empty($_GET['ID'])) { error("You didn't select a valid car"); } $selectMyCar = $db->query(sprintf("SELECT * FROM `playerCars` WHERE ((`pcID` = %u) AND (`pcUser` = %u))", $_GET['ID'], $ir['userid'])); if(!$db->num_rows($selectMyCar)) { error("You don't own that car"); } $myCar = $db->fetch_row($selectMyCar); $selectStandardCar = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $myCar['pcCarID'])); if(!$db->num_rows($selectStandardCar)) { error("That car doesn't exist - message a staff member to inform them about this"); } $car = $db->fetch_row($selectStandardCar); ?><h3>Cars: Upgrading your <? echo format($car['cName']); ?></h3><? $tuneArray = array('speed', 'handling', 'accel', 'brake'); $_GET['tune'] = isset($_GET['tune']) && ctype_alpha($_GET['tune']) && in_array($_GET['tune'], $tuneArray) ? strtolower(trim($_GET['tune'])) : null; if(empty($_GET['tune'])) { ?><table class='table' width='75%' cellspacing='1'> <tr> <th width='20%'>Stat</th> <th width='60%'>Amount</th> <th width='20%'>Tune</th> </tr> <tr> <th>Speed</th> <td><? echo format($myCar['pcSpeed']); ?></td> <td>Cost: <? echo format($myCar['pcSpeed'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=speed'>Tune</a></td> </tr> <tr> <th>Handling</th> <td><? echo format($myCar['pcHandling']); ?></td> <td>Cost: <? echo format($myCar['pcHandling'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=handling'>Tune</a></td> </tr> <tr> <th>Acceleration</th> <td><? echo format($myCar['pcAccel']); ?></td> <td>Cost: <? echo format($myCar['pcAccel'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=accel'>Tune</a></td> </tr> <tr> <th>Braking</th> <td><? echo format($myCar['pcBrake']); ?></td> <td>Cost: <? echo format($myCar['pcBrake'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=brake'>Tune</a></td> </tr> </table><? } else { $rand = mt_rand(1, 5); $uhOh = ''; switch($_GET['tune']) { case 'speed': if(($myCar['pcSpeed'] * 2) > $ir['money']) { error("You don't have enough to pay for that upgrade"); } if($rand >= 3) { $tuneThis = array('handling', 'accel', 'brake'); shuffle($tuneThis); $randReturn = $tuneThis[0]; $db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID'])); if($randReturn == 'accel') { $randString = 'acceleration'; } else if($randReturn == 'brake') { $randString = 'braking'; } else { $randString = $randReturn; } $uhOh .= ' at the cost of your '.$randString; } $db->query(sprintf("UPDATE `playerCars` SET `pcSpeed` = `pcSpeed` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcSpeed'] * 2), $ir['userid'])); success("You've upgraded your speed".$uhOh); break; case 'handling': if(($myCar['pcHandling'] * 2) > $ir['money']) { error("You don't have enough to pay for that upgrade"); } if($rand >= 3) { $tuneThis = array('speed', 'accel', 'brake'); shuffle($tuneThis); $randReturn = $tuneThis[0]; $db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID'])); if($randReturn == 'accel') { $randString = 'acceleration'; } else if($randReturn == 'brake') { $randString = 'braking'; } else { $randString = $randReturn; } $uhOh .= ' at the cost of your '.$randString; } $db->query(sprintf("UPDATE `playerCars` SET `pcHandling` = `pcHandling` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcHandling'] * 2), $ir['userid'])); success("You've upgraded your handling".$uhOh); break; case 'accel': if(($myCar['pcAccel'] * 2) > $ir['money']) { error("You don't have enough to pay for that upgrade"); } if($rand >= 3) { $tuneThis = array('speed', 'handling', 'brake'); shuffle($tuneThis); $randReturn = $tuneThis[0]; $db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID'])); if($randReturn == 'accel') { $randString = 'acceleration'; } else if($randReturn == 'brake') { $randString = 'braking'; } else { $randString = $randReturn; } $uhOh .= ' at the cost of your '.$randString; } $db->query(sprintf("UPDATE `playerCars` SET `pcAccel` = `pcAccel` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcAccel'] * 2), $ir['userid'])); success("You've upgraded your acceleration".$uhOh); break; case 'brake': if(($myCar['pcBrake'] * 2) > $ir['money']) { error("You don't have enough to pay for that upgrade"); } if($rand >= 3) { $tuneThis = array('speed', 'handling', 'accel'); shuffle($tuneThis); $randReturn = $tuneThis[0]; $db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID'])); if($randReturn == 'accel') { $randString = 'acceleration'; } else if($randReturn == 'brake') { $randString = 'braking'; } else { $randString = $randReturn; } $uhOh .= ' at the cost of your '.$randString; } $db->query(sprintf("UPDATE `playerCars` SET `pcBrake` = `pcBrake` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcBrake'] * 2), $ir['userid'])); success("You've upgraded your braking".$uhOh); break; } } } function upgradeGarage() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { header("Location: garage.php?action=buy"); exit; } $garage = $db->fetch_row($selectGarage); if(!empty($_GET['ID'])) { $select = $db->query(sprintf("SELECT `gTypeName`, `gTypeCost` FROM `garages` WHERE (`gTypeID` = %u)", $_GET['ID'])); if(!$db->num_rows($select)) { error("That upgrade doesn't exist"); } $gar = $db->fetch_row($select); if($gar['gTypeCost'] > $ir['money']) { error("You don't have enough money for that"); } $db->query(sprintf("UPDATE `playerGarages` SET `pgType` = %u WHERE (`pgUser` = %u)", $_GET['ID'], $ir['userid'])); success("You've bought the ".format($gar['gTypeName'])); } $getGarageUpgrades = $db->query(sprintf("SELECT * FROM `garages` WHERE (`gTypeID` > %u)", $garage['gTypeID'])); ?><h3>Cars: Upgrading your <? echo format($garage['gTypeName']); ?></h3> <table class='table' width='75%' cellspacing='1'> <tr> <th width='40%'>Upgrade</th> <th width='40%'>Cost</th> <th width='20%'>Links</th> </tr><? if(!$db->num_rows($getGarageUpgrades)) { echo "<tr><td colspan='3' class='center'>There are no upgrades available</td></tr>"; } else { while($upg = $db->fetch_row($getGarageUpgrades)) { ?><tr> <td><? echo format($upg['gTypeName']); ?></td> <td>$<? echo format($upg['gTypeCost']); ?></td> <td><? echo ($ir['money'] >= $upg['gTypeCost']) ? "<a href='garage.php?action=upgradegarage&ID=".$upg['gTypeID']."'>Buy</a>" : "<span style='color:#444;'>Buy</span>"; ?></td> </tr><? } } echo "</table>"; } function sellCar() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if(!$db->num_rows($selectGarage)) { header("Location: garage.php?action=buy"); exit; } if(empty($_GET['ID'])) { error("You didn't select a valid car"); } $selectMyCar = $db->query(sprintf("SELECT * FROM `playerCars` WHERE ((`pcID = %u) AND (`pcUser` = %u))", $_GET['ID'], $ir['userid'])); if(!$db->num_rows($selectMyCar)) { error("You don't own that car"); } $myCar = $db->fetch_row($selectMyCar); $selectStandardCar = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $myCar['pcCarID'])); if(!$db->num_rows($selectStandardCar)) { error("That car doesn't exist - message a staff member to inform them about this"); } $stdCar = $db->fetch_row($selectStandardCar); $myTotalStats = $myCar['pcSpeed'] + $myCar['pcHandling'] + $myCar['pcAccel'] + $myCar['pcBrake']; $stdTotalStats = $stdCar['cSpeed'] + $stdCar['cHandling'] + $stdCar['cAccel'] + $stdCar['cBrake']; if(($myTotalStats >= $stdTotalStats) && ($myTotalStats <= ($stdTotalStats + 500))) { $cost = $stdCar['cCost'] / 2; } else if(($myTotalStats >= ($stdTotalStats + 501)) && $myTotalStats <= ($stdTotalStats + 1500)) { $cost = $stdCar['cCost']; } else if(($myTotalStats >= ($stdTotalStats + 1501)) && $myTotalStats <= ($stdTotalStats * 2)) { $cost = ($stdCar['cCost'] * 2) - (($stdCar['cCost'] / 100) * 33); } else if(($myTotalStats >= ($stdTotalStats * 2) + 1) && $myTotalStats <= ($stdTotalStats * 5)) { $cost = $stdCar['cCost'] * 3; } else if(($myTotalStats >= ($stdTotalStats * 5) + 1) && $myTotalStats <= ($stdTotalStats * 10)) { $cost = $stdCar['cCost'] * 3; } else if($myTotalStats >= ($stdTotalStats * 10) + 1) { $cost = $stdCar['cCost'] * 5; } ?><h3>Cars: Selling your <? echo format($stdCar['cName']); ?></h3><? if(!isset($_GET['ans'])) { ?>If you sell your car, you will receive $<? echo format($cost); ?><br /> Are you sure you want to do this?<br /> <a href='garage.php?action=sell&ID=<? echo $_GET['ID']; ?>&ans=yes'>Yes</a> · <a href='garage.php'>No</a><? } else { $db->query(sprintf("DELETE FROM `playerCars` WHERE (`pcID` = %u)", $_GET['ID'])); $db->query(sprintf("UPDATE `users` SET `money` = `money` + %u WHERE (`userid` = %u)", $cost, $ir['userid'])); success("You've sold your ".format($stdCar['cName'])." for \$".format($cost)); } } function buyGarage() { global $db, $ir; $selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " . "FROM `playerGarages` AS `pg` " . "LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " . "WHERE (`pg`.`pgUser` = %u)", $ir['userid'])); if($db->num_rows($selectGarage)) { header("Location: garage.php"); exit; } $select = $db->query("SELECT `gTypeName`, `gTypeCost` FROM `garages` WHERE (`gTypeID` = 1)"); $gar = $db->fetch_row($select); ?><h3>Cars: Buying your first <? echo format($gar['gTypeName']); ?></h3><? if($gar['gTypeCost'] > $ir['money']) { error("You don't have enough money to do that. It costs ".format($gar['gTypeCost'])); } $db->query(sprintf("INSERT INTO `playerGarages` VALUES ('', %u, 1, 1)", $ir['userid'])); success("You've bought your ".format($gar['gTypeName'])); } $h->endpage(); ?>
-
Indeed, such is the life of a child! xD
-
5 reps given elsewhere, or receive a rep from the "repped"
-
Indeed, considering the family are now demanding time with me preventing me from doing what I want to .. again xD I'll finish up tomorrow. Coming soon: Garage Types (staff side) Upgrade Garage Upgrade Car Sell Car RacesFun Bet Pinks