<?php
$pullStats = mysql_query('select * from player WHERE id = "'.$userid.'"');
while($row = mysql_fetch_assoc($pullStats)){
$gold = $row['gold'];
$username = $row['username'];
$health = $row['curhealth'];
$mind = $row['mind'];
$body = $row['body'];
$soul = $row['soul'];
$exp = $row['exp'];
$total = ($mind + $body + $soul);
$level = ($total) / 10;
$level = round($level);
$totalHealth = ($body + $soul) * 5;
$defense = ($total)/3 - 2;
$defense = round($defense);
$attack = ($total)/3;
$attack = round($attack);
$agility = ($body + $mind)/2;
$agility = round($agility);
$oldAgility = $row['agility'];
if ($oldAgility != $agility){
$updatePlayer = "UPDATE `shinigami`.`player` SET `agility` = '".$agility."'
WHERE `player`.`id` = '".$userid."' LIMIT 1;";
mysql_query($updatePlayer) or die(mysql_error());
}
$oldAttack = $row['attack'];
if ($oldAttack != $attack){
$updatePlayer = "UPDATE `shinigami`.`player` SET `attack` = '".$attack."'
WHERE `player`.`id` = 1 LIMIT 1;";
mysql_query($updatePlayer) or die(mysql_error());
}
$oldDefense = $row['defense'];
if ($oldDefense != $defense){
$updatePlayer = "UPDATE `shinigami`.`player` SET `defense` = '".$defense."'
WHERE `player`.`id` = 1 LIMIT 1;";
mysql_query($updatePlayer) or die(mysql_error());
}
$oldHealth = $row['health'];
if ($oldHealth != $totalHealth){
$updatePlayer = "UPDATE `shinigami`.`player` SET `health` = '".$totalHealth."'
WHERE `player`.`id` = 1 LIMIT 1;";
mysql_query($updatePlayer) or die(mysql_error());
}
}
?>
Saturday, January 2, 2010
Show and Update Stats
Player stats are now checked and synchronized when they are pulled.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment