Thread: Random Breeding
View Single Post
  #2  
Old 09-18-2011, 07:34 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 393,734
Hall of Famer is on a distinguished road
Default

So you want breeding to have 50% chance of success and 50% chance of failure? You may want to use the mt_rand() function to generate random number at equal chance, a typical way of doing this is:

PHP Code:
$rand mt_rand(0,1); //Generate a random number between 0 and 1
if($rand == 0){
  
// codes to execute for successful breeding.
}
else{
  
// shows an error message saying breeding has failed.

Hopefully this is the correct interpretation of your request.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote