Php Code: Check Percentage Chance
This script returns a 1 (true) or 0 (false) based on the percent parameter. I use this function in any games I create to determine randomness of specific actions that would require a precise percentage.This function returns a 1 or 0.
1=true
0=false
This function works with any decimal number between 0 - 100. All negatives return 0. All numbers greater than 100 return 1. A common use could be to determine a critical chance. Code is well commented. Copy and paste in an editor and run in a browser to see how it works. Took me a few days to get it running, and I tested the life out of it. Works to the nearest hundred on numbers between 0 and 100. You can tweak it to work the nearest tenth or thousandth if you like. Enjoy!
1=true
0=false
This function works with any decimal number between 0 - 100. All negatives return 0. All numbers greater than 100 return 1. A common use could be to determine a critical chance. Code is well commented. Copy and paste in an editor and run in a browser to see how it works. Took me a few days to get it running, and I tested the life out of it. Works to the nearest hundred on numbers between 0 and 100. You can tweak it to work the nearest tenth or thousandth if you like. Enjoy!
If you don't know how to use this code or need more information Click here!