Jump to content
MakeWebGames

Recommended Posts

Posted

ok i got a streets mod but everytime i press search i get this

You found a total of 0 Crystals. You found a total of $0. You found a total of 0 Items.

here is my file

 

<?php
include "globals.php";
?>

<style type="text/css">

p.together {
line-height: .5em;
text-align: left;


}

</style>


<?php
$pointsf=0;
$moneyf=0;
$itemsf=0;
$ritemf=0;
$sritemf=0;
print "<h3>Scavenge</h3> <hr>


";
$_GET['action'] = mysql_real_escape_string($_GET['action']);
$search=$ir['turns'];
if($_POST['turns']>$search)
{
 print("You do not have that many turns left.


 <a href='streets.php'><i>Continue ...</i></a>

");
 return;
}
if ($_GET['action'] != 'search') {
$search=$ir['turns'];
print "You can search the streets 25 times a day. 
You have {$search} turns left for today.
You can find Crystals, Money, Items or even Gain EXP.

";
print "

<form method=post action=streets.php?action=search><input type=hidden name=action value=search><input type='text' name='search' value='{$ir['turns']}'>
<input type=submit value='Search'></form>
";
}
else {
$search=abs((int) $_POST['turns']);
for($i=0;$i<$search;$i++)

if ($ir['turns'] < 1)  {
print("You have searched all you can for today. Come back at newday.


<a href='explore.php'><i>back to city</i></a>

");
return;
}
else {
$g=$i+1;

$chance = rand(1,10);    ## $chance = random numbr between 1 and 15 -- diferrent posiblities for search
$chancepoints= rand (1,25);   ## Chance to find points : tweak this to change the rate that you find points
$chancemoney = rand (1,10);
$chanceitem = rand (1,35);
$chanceritem = rand (1,70);
$chancesritem = rand (1,100);

$query1=sprintf("UPDATE users SET turns=turns-1 where userid=$userid");
$db->query($query1);
              print"<p class='together'><b> $g : </b>";
              if ($chance == 1)  {
              print "Nothing here.";
              }
## CHANCE FOR POINTS
              if ($chance == 2)
              {
                    if ($chancepoints < 23) {
                    print "Nothing here.";
                    }
                    if ($chancepoints == 23) {
                    $gain = rand(1,15);
                    print "You found <b>$gain</b> Crystals.";
                    $query2=sprintf("UPDATE users SET crystals=crystals+$gain where userid=$userid");
                    $db->query($query2);
                    $pointsf=$pointsf+$gain;
                    }
                    if ($chancepoints == 24) {
                    $gain = rand(1,10);
                    print "You found <b>$gain</b> Crystals.";
                    $query3=sprintf("UPDATE users SET crystals=crystals+$gain where userid=$userid");
                    $db->query($query3);
                    $pointsf=$pointsf+$gain;
                    }
                    if ($chancepoints == 25) {
                    $gain = rand(1,5);
                    print "You found <b>$gain</b> Crystals.";
                    $query4=sprintf("UPDATE users SET crystals=crystals+$gain where userid=$userid");
                    $db->query($query4);
                    $pointsf=$pointsf+$gain;
                    }

              }
## CHANCE FOR MONEY
              if ($chance == 3)
              {
                    if ($chancemoney < 7)  {
                    print "Nothing here.";
                    }
                    if ($chancemoney == 7)  {
                    $gain = rand(50,100)*(floor($ir['level']/2)+1);
                    print "You found <b> \$$gain</b>.";
                    $query5=sprintf("update users set money=money+$gain where userid=$userid");
                    $db->query($query5);
                    $moneyf=$moneyf+$gain;
                    }
                    if ($chancemoney == 8)  {
                    $gain = rand(75,150)*(floor($ir['level']/2)+1);
                    print "You found <b> \$$gain</b>.";
                    $query6=sprintf("update users set money=money+$gain where userid=$userid");
                    $db->query($query6);
                    $moneyf=$moneyf+$gain;
                    }
                    if ($chancemoney == 9)  {
                    $gain = rand(50,100)*(floor($ir['level']*2));
                    print "You found <b> \$$gain</b>.";
                    $query7=sprintf("update users set money=money+$gain where userid=$userid");
                    $db->query($query7);
                    $moneyf=$moneyf+$gain;
                    }
                    if ($chancemoney == 10)  {
                    $gain = rand(150,300)*(floor($ir['level']/2)+1);
                    print "You found <b> \$$gain</b>.";
                    $query8=sprintf("update users set money=money+$gain where userid=$userid");
                    $db->query($query8);
                    $moneyf=$moneyf+$gain;
                    }
              }
              if ($chance == 4)  {
              print "Nothing here.
";
              }

###########################
## CHANCE FOR COMMON ITEM #
###########################

              if ($chance == 5)  {

              if ($chanceitem == 22) { ## RANDOM NUMBER FOR COMMON ITEM

              srand ((double) microtime() * 10000000);
              // $ri = array("9","52","53","54","8","30");**EXAMPLE**
              $ci = array("9","15","16");   ## Add You common Items ID to this array
              $cia = array_rand($ci,1);

              $common = $db->query("SELECT * FROM `items` WHERE `itmid`='".$ci[$cia]."' LIMIT 1");
      $comi = mysql_fetch_array($common);
              $query9=sprintf("INSERT INTO inventory   VALUES('',$ci[$cia],$userid,1)",$c);
              $db->query($query9);
              $itemsf = $itemsf +1;

              print " You found a/an {$comi['itmname']} !";

              }
              else
              {
              echo "Nothing here.";
              }
              }

              if ($chance == 6)  {
              print "Nothing here.
";
              }

              if ($chance == 7)  {
                          $gain = rand(50,100)*(floor($ir['level']*2));
                          print "You found <b> \$$gain</b>.";
                          $query10=sprintf("update users set money=money+$gain where userid=$userid");
                          $db->query($query10);
                          $moneyf=$moneyf+$gain;
              }

              if ($chance == 8)  {
                           $gain = rand(50,100)*(floor($ir['level']/2)+1);
                           print "You found <b> \$$gain</b>.";
                           $query11=sprintf("update users set money=money+$gain where userid=$userid");
                           $db->query($query11);
                           $moneyf=$moneyf+$gain;
              }

##########################
## CHANCE FOR RARE ITEM ##
##########################

              if ($chance == 9)  {


              if ($chanceritem == 25) { ## RANDOM NUMBER FOR RARE ITEM

              srand ((double) microtime() * 10000000);
              $ri = array("17","34","66");   ## Add Your Rare Items ID to this array
              $ria = array_rand($ri,1);

              $common = $db->query("SELECT * FROM `items` WHERE `itmid`='".$ri[$ria]."' LIMIT 1");
              $ri = mysql_fetch_array($common);
              $query12=sprintf("INSERT INTO inventory   VALUES('',$ri[$ria],$userid,1)",$c);
              $db->query($query12);
              $ritemf = $ritemf + 1;

              print " You found a/an {$ri['itmname']} !";

              }
              else
              {
              echo "Nothing here.";
              }
              }

################################
## CHANCE FOR SUPER RARE ITEM ##
################################

              if ($chance == 10)  {

              if ($chancesritem == 25) { ## RANDOM NUMBER FOR SUPER RARE ITEM

              srand ((double) microtime() * 10000000);
              $ri = array("73","70","75");   ##  Replace numbers with your Super Rare Items ID to this array
              $ria = array_rand($ri,1);

              $common = $db->query("SELECT * FROM `items` WHERE `itmid`='".$ri[$ria]."' LIMIT 1");
          $ri = mysql_fetch_array($common);
              $query13=sprintf("INSERT INTO inventory   VALUES('',$ri[$ria],$userid,1)",$c);
              $db->query($query13);
              $sritemf = $sritemf + 1;

              print " You found a/an {$ri['itmname']} !";

              }
              else
              {
              echo "Nothing here.";
              }
              }


}
$moneyf=number_format($moneyf);

              print "
<hr></p> You found a total of <b> $pointsf </b>Crystals.

                      You found a total of <b>  \$$moneyf. </b>

                      You found a total of <b> $itemsf </b> Items.
";
                      if ($ritemf > 0){
              print "<b> You found a total of<i> $ritemf </i>Rare Items.</b>
";
                       }
                       if ($sritemf > 0){
              print "<b> You found a total of<i> $sritemf </i> Super Rare Items.</b>
";
                       }
              print "<hr>";
if($ir['turns']==0)
{
 print("You have searched all you can for today. Come back at newday.


 <a href='explore.php'><i>back to city</i></a>

");
 return;
}
else
{
 print "

<form method=post action=streets.php?action=search><input type=hidden name=action value=search><input type='text' name='search' value=' {$ir['turns'] }'>
<input type=submit value='Search'></form>";
}
}
$h->endpage();
?>
Posted

I have been learning php for about 4 months, I made something like this 2 months ago for a friend on a game and it took me 5 mins, btw you don't need tables you can just use variables:

$money_g=$money_g+$gain Then at the bottom something like print "You gained $money_g Pounds";

If the Owner would be kind enough to give me the file i will give it to you, if not ill make it for you. :)

Posted
ooo sorry for bad code :(

That mod was literally the first mod i coded from scratch i believe....lol

You could always be nice, and fix it for him ;)

if it was your first ever mod... i have seen a lot worse.

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...