karaeski

Check Percentage Chance

Dec 8th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. Function :
  2. 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.
  3. 1=true
  4. 0=false
  5. 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.
  6. You can tweak it to work the nearest tenth or thousandth if you like. Enjoy!
  7.  
  8. Download from mediafire : http://adf.ly/1gXDds
Add Comment
Please, Sign In to add comment