Jump to content
MakeWebGames

Race. Help!


Nate

Recommended Posts

Could use all the help i can. laitly ive added a upgrading car parts system. and now im trying to finish this. but its errors after errors. :?

http://www.the-streets.site50.net/game.php?x=carracing

 

<?php
$time=date('U');
     $offtime=$time-180;
$online="update km_users set online='$time', lastseen='Racing(Testing Trial)' where playername='$userstats3[playername]'";
?>
<?php



   $myweapon = mysql_fetch_array(mysql_query("SELECT * FROM equipment WHERE owner='$userstats3[iD]' and type='W' and status='E'"));



$mycar = mysql_fetch_array(mysql_query("SELECT * FROM cars WHERE status='E' and owner=$userstats3[iD]"));

$mycar2 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='P' and owner=$userstats3[iD]"));

$mycar3 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='B' and owner=$userstats3[iD]"));

$mycar4 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='D' and owner=$userstats3[iD]"));

$mycar5 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='N' and owner=$userstats3[iD]"));

$mycar6 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='T' and owner=$userstats3[iD]"));



$expneeded = ($userstats3[level] * 150);



$exppercentage = ($userstats3[exp] / $expneeded);



$pj = number_format($userstats3[pj],1);



$maxpj = number_format($userstats3[maxpj],1);



$half2=$userstats3[def]+$myarm[power];



$half=$userstats3[strength]+$myweapon[power];



$maxhorse=$mycar[horsepower]+$mycar2[power]+$mycar3[power]+$mycar4[power]+$mycar5[power]+$mycar6[power];



$maxbrake=$mycar3[power];



$maxdownforce=$mycar4[power];



$maxnitrous=$mycar5[power];



$maxturbo=$mycar6[power];



?>
<?
include "header.php";
if ($userstats3[gold] <= 5000) { 
							print "You don't have enough gold to battle."; 
							exit;
						}

						if ($userstats3[pj] < 25) { 
							print "You don't have enough pj to Race."; 
							exit;
						}
						$userstats3 = mysql_query("select * from cars where owner=$userstats3[iD] and status='E' and type='D' and type='C'"); 



						if ($mycar[horsepower] < 1) { $encar[horsepower] = 1; } {
							if ($enemy[horsepower] < 1) { $enemy[horsepower] = 1; } {
								print "<ul>"; 
								print "[b][img=$car[image]]</a> Vs. [img=$enemy[image]]</a>
$userstats3[name][/b] vs. [b]$enemy[name][/b]
"; 
								print "
[*][b]The Race:[/b]
"; 

								while ($userstats3[gold] > 0 && $enemy[gold] > 0) { 
									for ($i = 1;$i <= $userstats3[attackstr]; ++$i) { 
										if ($enemy[gold] > 0 && $userstats3[gold] > 0) { 
											$enemy[gold] = ($enemy[gold] - $userstats3[power]); 
											print "You raced [b]$enemy[image][/b] with [b]$userstats3[horsepower][/b] Horse Power!</font>
"; 
										} 
									} 
									for ($i = 1;$i <= $enemy[attackstr]; ++$i) { 
										if ($userstats3[gold] > 0 && $enemy[gold] > 0) { 
											$userstats3[gold] = ($userstats3[gold] - $enemy[damage]); 
											print "[b]$enemy[image][/b] raced you with [b]$enemy[horsepower][/b] Horse Power! ($userstats3[hp] left)
"; 
										} 
									} 
								} 

								if ($userstats3[hp] <= 0) { 
									print "
[*][b]Outcome:[/b] You were defeated by [b]'$enemy[name]'</a>[/b]."; 
									mysql_query("update cars set loses=loses+'1', pj=pj-'.5' where ID=$userstats3[id]"); 
									mysql_query("update cars set lastracedby=$enemy[name], where ID=$userstats3[id]");
								} else { 
									print "
[*][b]Outcome:[/b] You defeated '[b]$enemy[name]'[/b]</a>[/b]."; 
									$expgain = rand($enemy[exp1],$enemy[exp2]); 
									$goldgain = rand($enemy[credits1],$enemy[credits2]); 
									mysql_query("update cars set wins=wins+1 where ID=$userstats3[iD]"); 
									mysql_query("update cars set loses=loses+'1', where ID=$enemy[iD]");
									print "
[*][b]Gains[/b] You Defeated [img=$enemy[image]]</a>, $enemy[name]."; 
									mysql_query("update cars set horsepower=horsepower+'10', where ID=$userstats3[id]"); 

									} 
								} 
								print "[*][b]Options[/b]
"; 
								print "<a href=?x=carracing&battle=$enemy[id]>Race Again</a>
"; 
								print "<a href=?x=Racers>Leave</a>
"; 
							}
				?>

 

edit (Templar): I have added the "Code tags" to this post

Link to comment
Share on other sites

Re: Race. Help!

This is what it looks like. i dont really know whats wrong wit it. it was made from scratch. really its just not pulling the names, avvys, cars, ect. from the database. if anyone can help i can send over msn and talk about it.

Also, i have made a test account for you all to log into and check it out.

Username: Test22

Password: 12345678

qnv6fa.png

Link to comment
Share on other sites

Re: Race. Help!

didn't botherd to read the script but do you even connect to your db ?

you know those simple lines with mysql_connect and mysql_select_db

and using 'or die(mysql_error())' at the end of your mysql_query() call will give you way more info on what is going wrong

Link to comment
Share on other sites

Re: Race. Help!

 

didn't botherd to read the script but do you even connect to your db ?

you know those simple lines with mysql_connect and mysql_select_db

and using 'or die(mysql_error())' at the end of your mysql_query() call will give you way more info on what is going wrong

mhmmm it connects thru the Connect.php so i dont have to have it in the scripts....

Update:

So ive added some msql lines and i got the pic of YOUR car to sho up. the opponents car wont sho up. and also it prints a diff name instead of ur opponents name.

 

<?php
$time=date('U');
     $offtime=$time-180;
$online="update km_users set online='$time', lastseen='Racing(Testing Trial)' where playername='$userstats3[playername]'";
?>
<?php

$profilestats="SELECT * FROM km_users WHERE ID='$_GET[battle]'"; 



$profilestats2=mysql_query($profilestats) or die(mysql_error());



$enemyy=mysql_fetch_array($profilestats2);



?>
<?php

$profilestats3 = mysql_fetch_array(mysql_query("SELECT * from km_users"));

   $myweapon = mysql_fetch_array(mysql_query("SELECT * FROM equipment WHERE owner='$userstats3[iD]' and type='W' and status='E'"));

$mycar = mysql_fetch_array(mysql_query("SELECT * FROM cars WHERE status='E' and owner=$userstats3[iD]"));

$equip2 = mysql_fetch_array(mysql_query("select * from cars where status='E' and owner=$profilestats3[iD]"));

$mycar2 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='P' and owner=$userstats3[iD]"));

$mycar3 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='B' and owner=$userstats3[iD]"));

$mycar4 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='D' and owner=$userstats3[iD]"));

$mycar5 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='N' and owner=$userstats3[iD]"));

$mycar6 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='T' and owner=$userstats3[iD]"));



$expneeded = ($userstats3[level] * 150);



$exppercentage = ($userstats3[exp] / $expneeded);



$pj = number_format($userstats3[pj],1);



$maxpj = number_format($userstats3[maxpj],1);



$half2=$userstats3[def]+$myarm[power];



$half=$userstats3[strength]+$myweapon[power];



$maxhorse=$mycar[horsepower]+$mycar2[power]+$mycar3[power]+$mycar4[power]+$mycar5[power]+$mycar6[power];



$maxbrake=$mycar3[power];



$maxdownforce=$mycar4[power];



$maxnitrous=$mycar5[power];



$maxturbo=$mycar6[power];



?>
<?
include "connect.php";
if ($userstats3[gold] <= 5000) { 
							print "You don't have enough gold to battle."; 
							exit;
						}

						if ($userstats3[pj] < 1) { 
							print "You don't have enough pj to Race."; 
							exit;
						}
						$profilestats3 = mysql_fetch_array(mysql_query("SELECT * from km_users where ID='$view' LIMIT 1"));
						$userstats3 = mysql_query("select * from cars where owner=$userstats3[iD] and status='E' and type='D' and type='C'"); 
					    $profilestats3 = mysql_query("select * from cars where owner=$profilestats3[iD] and status='E' and type='D' and type='C'"); 


						if ($mycar[horsepower] < 1) { $encar[horsepower] = 1; } {
							if ($enemy[horsepower] < 1) { $enemy[horsepower] = 1; } {
								print "<ul>"; 
								print "[b]<img src=$mycar[image]></a> Vs. [img=$equip2[image]]</a>
$userstats3[name][/b] vs. [b]$profilestats3[playername][/b]
"; 
								print "
[*][b]The Race:[/b]
"; 

								while ($userstats3[gold] > 0 && $enemy[gold] > 0) { 
									for ($maxhorse = 1;$i <= $userstats3[horsepower]; ++$maxhorse) { 
										if ($enemy[gold] > 0 && $userstats3[gold] > 0) { 
											$enemy[gold] = ($enemy[gold] - $userstats3[horsepower]); 
											print "You raced [b]$enemy[image][/b] with [b]$userstats3[horsepower][/b] Horse Power!</font>
"; 
										} 
									} 
									for ($maxhorse = 1;$maxhorse <= $enemy[horsepower]; ++$maxhorse) { 
										if ($userstats3[gold] > 0 && $enemy[gold] > 0) { 
											$userstats3[gold] = ($userstats3[gold] - $enemy[damage]); 
											print "[b]$enemy[image][/b] raced you with [b]$enemy[horsepower][/b] Horse Power! ($userstats3[hp] left)
"; 
										} 
									} 
								} 

								if ($userstats3[hp] <= 0) { 
									print "
[*][b]Outcome:[/b] You were defeated by [b]'$enemy[name]'</a>[/b]."; 
									mysql_query("update cars set loses=loses+'1', pj=pj-'.5' where ID=$userstats3[id]"); 
									mysql_query("update cars set lastracedby=$enemy[name], where ID=$userstats3[id]");
								} else { 
									print "
[*][b]Outcome:[/b] You defeated '[b]$enemy[name]'[/b]</a>[/b]."; 
									$expgain = rand($enemy[exp1],$enemy[exp2]); 
									$goldgain = rand($enemy[credits1],$enemy[credits2]); 
									mysql_query("update cars set wins=wins+1 where ID=$userstats3[iD]"); 
									mysql_query("update cars set loses=loses+'1', where ID=$enemy[iD]");
									print "
[*][b]Gains[/b] You Defeated [img=$enemy[image]]</a>, $enemy[name]."; 
									mysql_query("update cars set horsepower=horsepower+'10', where ID=$userstats3[id]"); 

									} 
								} 
								print "[*][b]Options[/b]
"; 
								print "<a href=?x=carracing&battle=$enemy[id]>Race Again</a>
"; 
								print "<a href=?x=Racers>Leave</a>
"; 
							}
				?>
Link to comment
Share on other sites

Re: Race. Help!

When you put arrays into strings, they need curly brackets around them.

 

$online="update km_users set online='$time', lastseen='Racing(Testing Trial)' where playername='$userstats3[playername]'";

 

That should be like this:

 

$online="update km_users set online='$time', lastseen='Racing(Testing Trial)' where playername='{$userstats3[playername]}'";

 

Does that help?

Link to comment
Share on other sites

Re: Race. Help!

This should get you pretty close...

 

$myweapon = mysql_fetch_array(mysql_query("SELECT * FROM equipment WHERE owner='$userstats3[iD]' and type='W' and status='E'"));

$mycar = mysql_fetch_array(mysql_query("SELECT * FROM cars WHERE status='E' and owner=$userstats3[iD]"));
$mycar2 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='P' and owner=$userstats3[iD]"));
$mycar3 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='B' and owner=$userstats3[iD]"));
$mycar4 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='D' and owner=$userstats3[iD]"));
$mycar5 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='N' and owner=$userstats3[iD]"));
$mycar6 = mysql_fetch_array(mysql_query("SELECT * FROM carparts WHERE status='E' and type='T' and owner=$userstats3[iD]"));

$expneeded = ($userstats3[level] * 150);
$exppercentage = ( $userstats3[exp] == 0 ) ? 0 : ($userstats3[exp] / $expneeded);

$pj = number_format($userstats3[pj],1);
$maxpj = number_format($userstats3[maxpj],1);
$half2=$userstats3[def]+$myarm[power];
$half=$userstats3[strength]+$myweapon[power];

$maxhorse=$mycar[horsepower]+$mycar2[power]+$mycar3[power]+$mycar4[power]+$mycar5[power]+$mycar6[power];
$maxbrake=$mycar3[power];
$maxdownforce=$mycar4[power];
$maxnitrous=$mycar5[power];
$maxturbo=$mycar6[power];

include "header.php";

if ($userstats3[gold] <= 5000) {
print "You don't have enough gold to battle.";
exit;
}
elseif ($userstats3[pj] < 25) {
print "You don't have enough pj to Race.";
exit;
}

$userstats3 = mysql_query("select * from cars where owner=$userstats3[iD] and status='E' and type='D' and type='C'");
if ($mycar[horsepower] < 1) $encar[horsepower] = 1; 
if ($enemy[horsepower] < 1) $enemy[horsepower] = 1; 

print "<ul>";
print "[b][img=".$car[]</a> Vs. [img=".$enemy[]</a>
$userstats3[name][/b] vs. [b]$enemy[name][/b]
";
print "
[*][b]The Race:[/b]
";

while ($userstats3[gold] > 0 && $enemy[gold] > 0) {
for ($i = 1;$i <= $userstats3[attackstr]; ++$i) {
	if ($enemy[gold] > 0 && $userstats3[gold] > 0) {
		$enemy[gold] = ($enemy[gold] - $userstats3[power]);
		print "You raced [b]$enemy[image][/b] with [b]$userstats3[horsepower][/b] Horse Power!</font>
";
	}
}
for ($i = 1;$i <= $enemy[attackstr]; ++$i) {
	if ($userstats3[gold] > 0 && $enemy[gold] > 0) {
		$userstats3[gold] = ($userstats3[gold] - $enemy[damage]);
		print "[b]$enemy[image][/b] raced you with [b]$enemy[horsepower][/b] Horse Power! ($userstats3[hp] left)
";
	}
}
}

if ($userstats3[hp] <= 0) {
print "
[*][b]Outcome:[/b] You were defeated by [b]'$enemy[name]'</a>[/b].";
mysql_query("update cars set loses=loses+'1', pj=pj-'.5' where ID=$userstats3[id]");
mysql_query("update cars set lastracedby=$enemy[name] where ID=$userstats3[id]");
} 
else {
print "
[*][b]Outcome:[/b] You defeated '[b]$enemy[name]'[/b]</a>[/b].";
$expgain = mt_rand($enemy[exp1],$enemy[exp2]);
$goldgain = mt_rand($enemy[credits1],$enemy[credits2]);
mysql_query("update cars set wins=wins+1 where ID=$userstats3[iD]");
mysql_query("update cars set loses=loses+'1' where ID=$enemy[iD]");
print "
[*][b]Gains[/b] You Defeated [img=$enemy[image]]</a>, $enemy[name].";
mysql_query("update cars set horsepower=horsepower+'10' where ID=$userstats3[id]");
}

print "[*][b]Options[/b]
";
print "<a href=?x=carracing&battle=$enemy[id]>Race Again</a>
";
print "<a href=?x=Racers>Leave</a>
";

 

The anchor tags at the bottom are malformed and won't work. Wasn't sure where you were pointing the script to so I left them alone.

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.

×
×
  • Create New...