Page 1 of 1

help with death penalty

Posted: Thu Jul 08, 2010 7:45 am
by SweetRevenge
Hey guys, so I am making an MMO browser, and I want to make farming not so easy, so I have it set up right now that whenever you die you get a death penalty of 7% exp loss. However, I have decided I want to make them have another penalty.... of let's say a 2:00 minute waiting time.... I am unsure of how i can go about doing that... so if someone could help i would greatly appreciate it. Here is my code for the penalty page.

Code: Select all

<?php
include_once 'connect.php';
  session_start();
  include_once 'logo.php';

?>
 <?php
if (isset($_SESSION['player']))
{
  $player=$_SESSION['player'];
}
else
{
  echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
  exit;
}
?>
</div>
<?php
 $playerinfo="SELECT * from players where name='$player'";
$playerinfo2=mysql_query($playerinfo) or die("could not get player stats!");
$playerinfo3=mysql_fetch_array($playerinfo2);
$pid = $playerinfo3['id'];

 ?>
//////////////////////////Experience Death Penalty////////////////
 <?php

$firstmod = (int)($playerinfo3['exper'] * .07);
          $totalexper =$playerinfo3['exper'] - $firstmod;
          $totalexper = $totalexper;
                     echo "<br><b><big>You died, you lost " . $firstmod . " experience.</b></big><br>";
      $updateplayer="update players set exper='$totalexper' where name = '$player'";
  mysql_query($updateplayer) or die("Could not update player");
  echo "<br><br><a href='index.php'>Go back to town";
  
  $updateplayer="update players set hpoints='1' where name='$player'";
  mysql_query($updateplayer) or die("Could not update player");
  ?>

Re: help with death penalty

Posted: Thu Jul 08, 2010 7:54 am
by Callan S.
You set up a big integer in the player database, size 10, call it timestamp for the demo's purposes

When they 'die' (it's not really dying if your coming back, btw) you save the current time by using 'time()' to get the current time in seconds, then save it to the database as per usual.

Then in all the scripts you don't want them to access, right after loading up the player stats you have something like

Code: Select all

    if (time() < $timestamp+120)
       {
       header("Location: put in here where they go while they wait out 'death'.php");
       exit();
       }