lynm77 Posted February 5, 2012 Posted February 5, 2012 Hello Looking for some help if possible please i have attempted to convert the following car mob v1 to v2 But as always just have problems i can't figure out how to resolve. First problem is with tune.php Fatal error: Call to undefined function power() in /home/swisou/public_html/tune.php on line 9 <?php include "globals.php"; print "<h3>Tuning Shop</h3><hr /> > <a href='garage.php'>Back To Garage</a><hr />"; if(!$_GET['id']) { die("Invalid Usage"); } $q=$db->query("SELECT cp.*,ct.* FROM cars_playercars cp LEFT JOIN cars_types ct ON ct.carID=cp.cpcCAR WHERE cp.cpcID={$_GET['id']} AND cp.cpcPLAYER=$userid", $c); if($db->num_rows($q) == 0) { die("Invalid Car"); } $r=$db->fetch_row($q); $cost['acc']=$r['carACC']*power($r['cpcACCLV']+1,4)*($r['cpcACCLV']*$r['carACC']*10); $cost['han']=$r['carHAN']*power($r['cpcHANLV']+1,4)*($r['cpcHANLV']*$r['carHAN']*10); $cost['spd']=$r['carSPD']*power($r['cpcSPDLV']+1,4)*($r['cpcSPDLV']*$r['carSPD']*10); $cost['shd']=$r['carSHD']*power($r['cpcSHDLV']+1,4)*($r['cpcSHDLV']*$r['carSHD']*10); if($_GET['buy']) { if($_GET['buy'] != "acc" && $_GET['buy'] != "han" && $_GET['buy'] != "spd" && $_GET['buy'] != "shd") { die("Abusers suck."); } $upgr_cost=$cost[$_GET['buy']]; if($ir['money'] < $upgr_cost) { die("You don't have enough money to tune this stat."); } $db->query("UPDATE users SET money=money-{$upgr_cost} WHERE userid=$userid", $c); $stat="cpc".strtoupper($_GET['buy'])."LV"; $db->query("UPDATE cars_playercars SET $stat=$stat+1 WHERE cpcID={$_GET['id']}", $c); print "Car tuned!<br /> > <a href='tune.php?id={$_GET['id']}'>Tune some more</a>"; } else { foreach($cost as $k => $v) { $costf[$k]='$'.number_format($v); } $acc=$r['cpcACCLV']*$r['carACC']; $han=$r['cpcHANLV']*$r['carHAN']; $spd=$r['cpcSPDLV']*$r['carSPD']; $shd=$r['cpcSHDLV']*$r['carSHD']; print "Current Stats for your {$r['carNAME']}<br /> <table width='90%'><tr> <th>Stat</th> <th>Amount</th> <th>Cost To Tune</th> <th>Tune</th></tr> <tr> <td>Acceleration</td> <td>Lv{$r['cpcACCLV']} ($acc)</td> <td>{$costf['acc']}</td> <td><a href='tune.php?id={$_GET['id']}&buy=acc'>Tune</a></td></tr> <tr><td>Speed</td> <td>Lv{$r['cpcSPDLV']} ($spd)</td> <td>{$costf['spd']}</td> <td><a href='tune.php?id={$_GET['id']}&buy=spd'>Tune</a></td></tr> <tr> <td>Handling</td> <td>Lv{$r['cpcHANLV']} ($han)</td> <td>{$costf['han']}</td> <td><a href='tune.php?id={$_GET['id']}&buy=han'>Tune</a></td></tr> <tr> <td>Shield</td> <td>Lv{$r['cpcSHDLV']} ($shd)</td> <td>{$costf['shd']}</td> <td><a href='tune.php?id={$_GET['id']}&buy=shd'>Tune</a></td></tr> </table>"; } $h->endpage(); ?> The second problem is with carmarket.php Fatal error: Call to a member function query() on a non-object in /home/swisou/public_html/carmarket.php on line 25 <?php include "globals.php"; print "<h3>Car Market</h3><hr />"; switch($_GET['action']) { case "buy": crystal_buy(); break; case "remove": crystal_remove(); break; default: cmarket_index(); break; } function cmarket_index() { global $ir,$c,$userid,$h; print " Viewing all listings... <table width=100% border=6> <tr style='background:#cc9966'> <th>Seller</th> <th>Car</th> <th>Acceleration Level</th> <th>Handling Level</th> <th>Speed Level</th> <th>Shield Level</th> <th>Price</th> <th>Links</th> </tr>"; $q=$db->query("SELECT cm.*, u.*,ct.* FROM carmarket cm LEFT JOIN users u ON u.userid=cm.cmADDER LEFT JOIN cars_types ct ON ct.carID=cm.cmCAR ORDER BY cmPRICE ASC",$c); while($r=$db->fetch_row($q)) { if($r['cmADDER'] == $userid) { $link = "<a href='carmarket.php?action=remove&ID={$r['cmID']}'>Remove</a>"; } else { $link = "<a href='carmarket.php?action=buy&ID={$r['cmID']}'>Buy</a>"; } print "\n<tr> <td><a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> [{$r['userid']}]</td> <td>{$r['carNAME']}</td> <td>{$r['cmACC']}</td> <td>{$r['cmHAN']}</td> <td>{$r['cmSPD']}</td> <td>{$r['cmSHD']} <td>\$".number_format($r['cmPRICE'])."</td> <td>[$link]</td> </tr>"; } print "</table>"; } function crystal_remove() { global $ir,$c,$userid,$h; $q=$db->query("SELECT cm.*,c.* FROM carmarket cm LEFT JOIN cars_types c ON cm.cmCAR=c.carID WHERE cmID={$_GET['ID']} AND cmADDER=$userid",$c); if(!$db->num_rows($q)) { print "Error, either this car does not exist, or you are not the owner.<br /> <a href='carmarket.php'>> Back</a>"; $h->endpage(); exit; } $r=$db->fetch_row($q); $db->query("INSERT INTO cars_playercars VALUES('', $userid, {$r['cmCAR']}, {$r['cmACC']}, {$r['cmHAN']}, {$r['cmSPD']}, {$r['cmSHD']})", $c); $i=$db->insert_id($c); $db->query("INSERT INTO imremovelogs VALUES ('', {$r['cmCAR']}, {$r['cmADDER']}, $userid, {$r['cmID']}, $i, unix_timestamp(), '{$ir['username']} removed a {$r['carNAME']} from the car market belonging to ID {$r['cmADDER']}.')", $c); $db->query("DELETE FROM carmarket WHERE cmID={$_GET['ID']}",$c); print "Car removed from market!<br /> <a href='carmarket.php'>> Back</a>"; } function crystal_buy() { global $ir,$c,$userid,$h; $q=$db->query("SELECT cm.*,ct.* FROM carmarket cm LEFT JOIN cars_types ct ON ct.carID=cm.cmCAR WHERE cmID={$_GET['ID']}",$c); if(!$db->num_rows($q)) { print "Error, either this car does not exist, or it has already been bought.<br /> <a href='carmarket.php'>> Back</a>"; $h->endpage(); exit; } $r=$db->fetch_row($q); if($r['cmPRICE'] > $ir['money']) { print "Error, you do not have the funds to buy this car.<br /> <a href='carmarket.php'>> Back</a>"; $h->endpage(); exit; } $db->query("INSERT INTO cars_playercars VALUES('', $userid, {$r['cmCAR']}, {$r['cmACC']}, {$r['cmHAN']}, {$r['cmSPD']}, {$r['cmSHD']})", $c); $i=$db->insert_id($c); $db->query("DELETE FROM carmarket WHERE cmID={$_GET['ID']}",$c); $db->query("UPDATE users SET money=money-{$r['cmPRICE']},cars_owned=cars_owned+1 where userid=$userid",$c); $db->query("UPDATE users SET money=money+{$r['cmPRICE']} where userid={$r['cmADDER']}",$c); event_add($r['cmADDER'],"<a href='viewuser.php?u=$userid'>{$ir['username']}</a> bought your {$r['carNAME']} from the market for \$".number_format($r['cmPRICE']).".",$c,'trading'); $db->query("INSERT INTO imbuylogs VALUES ('', {$r['cmCAR']}, {$r['cmADDER']}, $userid, {$r['cmPRICE']}, {$r['cmID']}, $i, unix_timestamp(), '{$ir['username']} bought a {$r['carNAME']} from the car market for \${$r['cmPRICE']} from user ID {$r['cmADDER']}')", $c); print "You bought the {$r['carNAME']} from the market for \$".number_format($r['cmPRICE'])."."; } $h->endpage(); ?> Any help we be great. Thank You Quote
sniko Posted February 5, 2012 Posted February 5, 2012 1. power() is a function, created by the modification creator, maybe they put it in global_func.php file. 2. global $db; Quote
Djkanna Posted February 5, 2012 Posted February 5, 2012 try pow() ? Whilst you're probably right that pow() is what the mod creator intended, damn upgrading is going to get expensive on upgradeTypeLevel+1^4 alone. :| Quote
lynm77 Posted February 5, 2012 Author Posted February 5, 2012 Hello Lads Thanks for your help worked one problem out with your ideas. With the tune.php I added to top function power($num1, $num2) { return pow($num1, $num2); } session_start(); Still trying to solve the carmarket.php Cheers Quote
sniko Posted February 5, 2012 Posted February 5, 2012 function cmarket_index() { global $ir,$c,$userid,$h; print " Viewing all listings... Change the global, so it involves $db. Quote
lynm77 Posted February 5, 2012 Author Posted February 5, 2012 Hello Sniko Yes that has worked. Thank you for your help i changed to function cmarket_index() { global $db,$ir,$c,$userid,$h; print " Viewing all listings... Cheers 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.