We've noticed that you've been inactive for over 10 minute(s). We've stopped running the Shoutbox due to your inactivity. If you are back again, please click the I'm Back button below.
Heh =)
It was a long time I made this script
Now I don't reset the HP to 100. Instead, I make it unable to reach under 10, and use healing potions to heal.
And yeh =) I made it basic, because when I was a very newbie, I couldn't find these kind of tutorials. So I had very much trouble to learn these stuff =)
This is an interesting script, however, in my opinion (or game if I'm designing one), I wouldn't reset the HP back to 100.
I think I might use this if I continue on with a game that I hope I'm motivated enough to create, lol.
I am going to share an attack script that i made for some time ago. I made it, as a test for my game.. And ofc, you can use it for your game to. It is still version 1.0. But I want you to learn something from it This is my second tutorial here, and I will try to make it better than my first one
This is very clear, isn't it =? We give $maxHealth a value. We give $healthAward a value (the health the player wins/loses). the mt_rand function will randomize the health the player will get. And we will also give the $winner chance a value.. it is 50% chance that the player wins, and 50% chance that the playe will lose.
if($winner) {
if(($currentHealth + $healthAward) <= $maxHealth) {
$currentHealth += $healthAward;
echo "You won! You've gained {$healthAward} HP. You now have {$currentHealth} HP.";
} else {
echo "You won! Your health is at the maximum, {$maxHealth} HP.";
$currentHealth = $maxHealth;
If the player wins: Check if the player got full hp. If he don't have full hp, give him the healthAward, else, the code will write that he won, but the hp will not change.
} else {
if(($currentHealth - $healthAward) <= 0) {
echo "You died. Your HP is 100 again.";
$currentHealth = 100;
} else {
$currentHealth -= $healthAward;
echo "You lost! You've lost {$healthAward} HP. You now have {$currentHealth} HP.";
}
}
Else if the players hp is less than 0, the code will write that the player died, and reset the hp to 100. if the player lost, but didn't die, the code will remove the hp that the player lost, and write that he lost, and show his remaining hp.
mysql_query ("UPDATE characterss SET health = \"{$currentHealth}\" WHERE id = 2");
}
And ofc, we must update the value in the database.. Else, it won't be fun
echo attack();
mysql_close($db);
?>
Then we echo the function, and close the mysql_connection.
Tell me if you find any errors, or if u want me to change something. And I also want to know if you liked this tutorial
//Feelay
You are not allowed to copy anything from this tutorial, and paste it outside of this topic, without my permission. But you are allowed to copy/paste parts of it, inside this topic.