help with death penalty

C++, C#, Java, PHP, ect...
Post Reply
SweetRevenge
Posts: 52
Joined: Sun Jul 04, 2010 4:53 am

help with death penalty

Post 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");
  ?>
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: help with death penalty

Post 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();
       }
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Post Reply

Return to “Coding”