<?php
/*
* Created by Eaglesight @ Otland/Otfans
* Don't publish this as your own. (nono)
* Date: 2010-05-10
*
*/
//input the adress to the database (usually localhost)
$dbhost = 'localhost';
//input username to the database (usually root)
$dbuser = 'root';
//input password to the database
$dbpass = 'password';
//what database is the players-table located in?
$dbname = 'whatever';
//connects to the database, do not change
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
//selects the database, do not change
mysql_select_db($dbname);
/////////////////////////////////////////////////////////////////////////////////////
?>
Do you want to correct hp & mana of all players?<br>
<form action="" method="GET">
<input type="hidden" name="start" value="true" />
<input type="submit" value="Yes, go">
</form>
<?php
///////////////////////////////////////////////////////////////////////////////////////
if(isset($_GET['start'])){
//Skapar SQL-frågan
$query = "SELECT * FROM players";
//Exekverar SQL-frågan
$result = mysql_query($query);
echo "<table>";
echo " <tr>";
echo " <th>id</th>";
echo " <th>voc</th>";
echo " <th>level</th>";
echo " <th>health</th>";
echo " <th>mana</th>";
echo " </tr>";
while($row = mysql_fetch_assoc($result) ){
$id = $row['id'];
$voc = $row['vocation'];
$level = $row['level'];
$mana = $row['mana'];
$manamax = $row['manamax'];
$health = $row['health'];
$healthmax = $row['healthmax'];
echo "<tr>";
echo " <td>$id</td>";
echo " <td>$voc</td>";
echo " <td>$level</td>";
echo " <td>$healthmax</td>";
echo " <td>$manamax</td>";
echo "</tr>";
}
echo "</table>";
}
//////////////////////////////////////////////////////////////////////////////////////
echo "<table>";
echo " <tr>";
echo " <th>id</th>";
echo " <th>voc</th>";
echo " <th>level</th>";
echo " <th>mana</th>";
echo " <th>manamax</th>";
echo " <th>health</th>";
echo " <th>healthmax</th>";
echo " </tr>";
if(isset($_GET['start'])){
$result = mysql_query("SELECT * FROM players");
echo "<table>";
echo " <tr>";
echo " <th>id</th>";
echo " <th>voc</th>";
echo " <th>level</th>";
echo " <th>mana</th>";
echo " <th>manamax</th>";
echo " <th>health</th>";
echo " <th>healthmax</th>";
echo " </tr>";
while($row = mysql_fetch_assoc($result) ){
$id = $row['id'];
$vocation = $row['vocation'];
$level = $row['level'];
$mana = $row['mana'];
$manamax = $row['manamax'];
$health = $row['health'];
$healthmax = $row['healthmax'];
//no vocation - incorrect formula
if($vocation == 0){
$gainhpamount = "15";
$gainmanaamount = "5";
$starthp = 150;
$startmp = 0;
}
//sorcerer
else if($vocation == 1 || $vocation == 5){
$gainhpamount = "5";
$gainmanaamount = "30";
$starthp = 185;
$startmp = 210;
}
//druid
else if($vocation == 2 || $vocation == 6){
$gainhpamount = "5";
$gainmanaamount = "30";
$starthp = 185;
$startmp = 210;
}
//paladin
else if($vocation == 3 || $vocation == 7){
$gainhpamount = "10";
$gainmanaamount = "15";
$starthp = 220;
$startmp = 105;
}
//knight
else if($vocation == 4 || $vocation == 8){
$gainhpamount = "15";
$gainmanaamount = "5";
$starthp = 255;
$startmp = 35;
}
$real = $level - 8;
$x = $real * $gainhpamount;
$y = $real * $gainmanaamount;
$x = $x + $starthp;
$y = $y + $startmp;
echo "<h2>New query, here you can see if the hp/mana is like you wanted.</h2>";
echo "<tr>";
echo " <td>$id</td>";
echo " <td>$vocation</td>";
echo " <td>$level</td>";
echo " <td>$realrealhp</td>";
echo " <td>$realrealmp</td>";
echo "</tr>";
mysql_query("UPDATE players SET healthmax=$x WHERE id='$id'");
mysql_query("UPDATE players SET health=$x WHERE id='$id'");
mysql_query("UPDATE players SET manamax=$y WHERE id='$id'");
mysql_query("UPDATE players SET mana=$y WHERE id='$id'");
}
echo "</table>";
}
?>