Jump to content
MakeWebGames

Help with cars mod


Ikz786
 Share

Recommended Posts

Hi, I am having problems with the tune.php page for the cars mod. I saw another thread on this forum and added the function below:

 

function power($num1, $num2)
{
return pow($num1, $num2);
}
session_start();

 

which made a table come up showing all the parts of the car I can tune, but now I can't set the cost of the items that need tuning and I can't change how much I want them to tune.

[ATTACH=CONFIG]808[/ATTACH]

In the screenshot it shows the cost and the amount to tune as '0', I need help changing that.

Can somebody help me please?

Untitled.png.28be6b7ae2ff553f2c24ee5dbfcd4a5f.png

Link to comment
Share on other sites

I dont have session_start() in mine but here is my tune.php that I have

<?php
include_once "globals.php";
function power($num1, $num2)
{
return pow($num1, $num2);
}
print "<h3>Tuning Shop</h3><hr />
> <a href='garage.php'>Back To Garage</a><hr />";
if(!$_GET['id']) { print "Invalid Usage"; $h->endpage(); exit(); }
$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");
if($db->num_rows($q) == 0) { print "Invalid Car"; $h->endpage(); exit(); }
$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") { print "Abusers suck."; $h->endpage(); exit(); }
$upgr_cost=$cost[$_GET['buy']];
if($ir['money'] < $upgr_cost) { print "You don't have enough money to tune this stat."; $h->endpage(); exit(); }
$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']}");
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();
?>
Link to comment
Share on other sites

  • 2 weeks later...

I'm guessing it is somewhere in here:

 

$q=mysql_query("SELECT * FROM cars_tracks ORDER BY rand() LIMIT 1", $c);
$t=mysql_fetch_array($q);
$stats_y=0;
$stats_y+=$m['cpcACCLV']*$m['carACC']*$t['ctrkACC'];
$stats_y+=$m['cpcHANLV']*$m['carHAN']*$t['ctrkHAN'];
$stats_y+=$m['cpcSPDLV']*$m['carSPD']*$t['ctrkSPD'];
$stats_y+=$m['cpcSHDLV']*$m['carSHD']*$t['ctrkSHD'];

$stats_o=0;
$stats_o+=$r['cpcACCLV']*$r['carACC']*$t['ctrkACC'];
$stats_o+=$r['cpcHANLV']*$r['carHAN']*$t['ctrkHAN'];
$stats_o+=$r['cpcSPDLV']*$r['carSPD']*$t['ctrkSPD'];
$stats_o+=$r['cpcSHDLV']*$r['carSHD']*$t['ctrkSHD'];
$stats_y*=rand(800,1200);
$stats_o*=rand(800,1200);
$notes="No-one won anything";
mysql_query("UPDATE users SET cars_challs_accpt=cars_challs_accpt+1 WHERE userid=$userid", $c);
if($stats_y > $stats_o)
{
$winner=$ir['username'];
$winnings=$bet*2;
mysql_query("UPDATE users SET money=money+$winnings, cars_races_income=cars_races_income+$bet,cars_races_won=cars_races_won+1 WHERE userid={$r['chCHD']}", $c);
mysql_query("UPDATE users SET cars_races_income=cars_races_income-$bet,cars_races_lost=cars_races_lost+1 WHERE userid={$r['chCHR']}", $c);
if($bet > 0)
{
$notes="{$r['challenged']} won \$$winnings"; 
}
if($r['chTYPE'] == "High-Stakes")
{
mysql_query("UPDATE cars_playercars SET cpcPLAYER=$userid WHERE cpcID={$r['cpcID']}", $c);
$notes="{$r['challenged']} won {$r['challenger']}\'s {$r['carNAME']}";
mysql_query("UPDATE users SET cars_lost=cars_lost+1 WHERE userid={$r['chCHR']}", $c);
mysql_query("UPDATE users SET cars_won=cars_won+1,cars_owned=cars_owned+1 WHERE userid={$r['chCHD']}", $c);
}
else if($r['chTYPE'] == "Betted")
{
mysql_query("UPDATE users SET cars_races_betted=cars_races_betted+1 WHERE userid IN ({$r['chCHR']}, {$r['chCHD']})", $c);
}
else
{
mysql_query("UPDATE users SET cars_races_friendly=cars_races_friendly+1 WHERE userid IN ({$r['chCHR']}, {$r['chCHD']})", $c);
}
}
else
{
$winner=$r['challenger'];
$winnings=$bet*2;

 

also, after the first $winner=$ir['username'], I changed the $ir['username'] to $r['challenged'] but it didn't make a difference.

Edited by Ikz786
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...