Php World
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Search the Streets

Go down

Search the Streets Empty Search the Streets

Post  Admin Fri Mar 19, 2010 9:13 pm

This is not made by me but edited by me and i got permission.

Make a file called street.php and add this.


Code:
<?php
    include "globals.php";
    require("sqlpro.php");
    print "<h3>You are currently scavenging the streets</h3>
    <br><br>";
    if ($_GET['action'] != 'scavenge') {
    $turns=$ir['turns'];
    print "Holy smokes! You should scavenge for some serious shit dude. Maybe grab some money off the ground, or get some Experience... maybe even find a special item or two...? Start goin! You have {$turns} turns left for today and will be topped up to 25 at newday.<br>";
    print "<br><br><form method=post action=street.php?action=scavenge><input type=hidden name=action value=scavenge><input type='text' name='steps' value='{$ir['turns']}'><br /><input type=submit value='scavenge'></form>";
    } else {
    $steps=abs((int) $_POST['steps']);
    for($i=0;$i<$steps;$i++)
    {
    if ($ir['turns'] < 1)  {
    print("You do NOT have enough steps to scavenge the streets any more. Come back at newday.<br /><br />");
    }else {
    $chance = rand(1,15);
    $db->query("UPDATE users SET turns=turns-1 where userid=$userid",$c);
    if ($chance == 1)  {
      $amnt=rand(500,2000);
      if($ir['money'] > $amnt)
      {
    print "As you scavenge the streets you see a hobo; he asks you for \$$amnt and you tell him to piss off. Then he proceeds to smack the shit out of you. He takes the  \$$amnt anyway.<br /><br />";
    $db->query("UPDATE users SET money=money- {$amnt } where userid=$userid",$c);
    $ir['money']-=$amnt;
      }
      else
      {
        print "As you walk the streets you see a hobo he asks you for \$1 you tell him to piss off he smacks you over the head and looks in your wallet. Finding it almost empty he just runs off with it.<br /><br />";
        $db->query("UPDATE users SET money=0 where userid=$userid",$c);
        $ir['money']=0;
      }
    }
    if ($chance == 2)  {
    print "Nothing here.<br /><br />";
    }
    if ($chance == 3)  {
    $gained=rand(200,900)*$ir['level'];
    print "You found a bag of cash on the side walk you open it up and find <b> \$$gained</b> was inside.<br /><br />";
    $db->query("UPDATE users SET money=money+$gained where userid=$userid",$c);
    }
    if ($chance == 7)  {
    print "You see a guy getting mugged, but you decide to keep walking. You don't want to be in his shoes anytime soon.<br /><br />";
    }
    if ($chance == 4)  {
    print "While exploring the streets you found some cash, but a hobo came quickly behind you and whacked you over the head. You lurch in suprise and the hobo takes the cash and runs off.";
    }
    if ($chance == 5)  {
    $gain = rand(5,15);
    print "While searching the streets you found <b>$gain</b> crystals.";
    $db->query("UPDATE users SET crystals=crystals+$gain where userid=$userid",$c);
    }
    if ($chance == 6)  {
    $gain = rand(500,1000)*(floor($ir['level']/2)+1);
    print "While searching the streets you found <b> \$$gain</b>.<br /><br />";
    $db->query("update users set money=money+$gain where userid=$userid",$c);
    }
    if ($chance == 8)  {
    print "Nothing here. Just a few drunk bums.<br /><br />";
    }
    if ($chance == 9)  {
    print "You see a small item on the ground, and decide to pick it up... wonder what it is? (Hint, look in your inventory lol)";
    $itemidexplore = 16;
      $db->query("INSERT INTO inventory  VALUES('',$itemidexplore,$userid,1)",$c); print"<br /><br />";
    }
    if ($chance == 10)  {
    print "You see a med-kit on the ground, and decide to pick it up. Looks usefull enough...";
    $itemidexplore = 17;
      $db->query("INSERT INTO inventory  VALUES('',$itemidexplore,$userid,1)",$c);
    print"<br /><br />";
    }
    if ($chance == 11)  {
    print "Nothing here.<br /><br />";
    }
    if ($chance == 12)  {
    print "Nothing here.<br /><br />";
    }
    if ($chance == 13)  {
    $expcur=(($ir['exp']+$ir['exp_needed'])/100);
    $exp=(($expcur)*rand(1,5));
    print "You got in a scuffle with a bum, and WON you gained some EXP!! (Go have a look!)<br /><br />";
    $db->query("UPDATE users SET exp=exp+$exp WHERE userid=$userid",$c);
    }
    if ($chance == 14)  {
    print "Nothing here.<br /><br />";
    }
    if ($chance == 15)  {
    $gained=rand(200,1000)*$ir['level'];
    print "You found a bag of cash on the side walk you open it up and find <b> \$$gained</b> was inside.<br /><br />";
    $db->query("UPDATE users SET money=money+$gained where userid=$userid",$c);
    }
    $ir['turns']--;
    print"you have <b> {$ir['turns'] }</b> steps left<br /><br />";
    }
    }
    if($ir['turns']==0)
    {
      print "Sorry, all turns used!<br /><br />";
    }
    else
    {
      print "<br><br><form method=post action=street.php?action=scavenge><input type=hidden name=action value=scavenge><input type='text' name='steps' value=' {$ir['turns'] }'><br /><input type=submit value='scavenge'></form>";
    }
    }
    $h->endpage;
    ?>
    }



Add SQL



Code:
Code:
 alter table users add turns int(11) not null default 25;



*Change the above default number to something you want it to be, So when users sign up they start with that amount of turns*

Add to day cron



Code:
Code:
$db->query("UPDATE users SET turns=25");



*Yet again, Change the above to your preference*

Then add link in explore and you are done.

Admin
Admin

Posts : 5
Join date : 2010-03-19

https://phpworld.forumotion.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum