-1
Hello, I am creating a system of items on my website. Each item has a certain chance to win.
For example, 0.01%
I would like to know how to make PHP every time the user plays, try to win some item with this percentage.
Kind of:
if(drop_item(0.01) == true) {
echo "Você ganhou uma poção!";
} else {
echo "Você não ganhou nada!";
}
If you know how to do this with multiple items, with each item with a chance to win, I would be very happy :)
Thank you for your attention.
I understood, but how can I make this percentage conversion to number (which in this case was 10000)?
– Dante
In case you need to pass a number in % and return the maximum value?
– Costamilam
I think so, yeah. I am storing the items in an array, and in this array I would like to put the chance value of winning in % for a better visualization, in case I need to change something later.
– Dante
I edited the answer, I believe it’s more or less what you need
– Costamilam
You missed 0, and I also missed that it’s division and not multiplication
– Costamilam
Now just returning that person won XD
– Dante
Let’s go continue this discussion in chat.
– Dante