Chances with percentage
#1

How can I make two options but one have 10% chance to succes and other one has 90%?
Reply
#2

create a random number between 0 - 9 and check if it is 0 (10%) , if yes , success

if u want for example a 40% chance, you check if it is between 0 and 3.

Might be the sexest soliution, but it would work ^^
Reply
#3

Make random of 10 numbers and in the if statement check only 1 number like this
PHP код:
new rand random(11); //random 11 because it will only have 10 numbers.
if(rand == 1//if the random result is 1 or what ever number you like
{
         
//Do some thing here

We get random of 10 numbers but we check if the random results 1 that means 1 out of 10
EDIT: Marcel was fast || Ok random of 11
Reply
#4

Is dis guud?

Код:
new luck = random(9), panels, doors, lights, tires;
					    
					    if(luck == 0)
					    {
							SendClientMessage(playerid, COLOR_WHITE, "Ai umflat roata prea mult si aceasta a explodat.");
						}
						else if(luck > 0)
						{
						    vehicle = GetPlayerVehicleID(playerid);
						    GetVehicleDamageStatus(vehicle, panels, doors, lights, tires);
						    UpdateVehicleDamageStatus(vehicle, panels, doors, lights, 15);
						}
Reply
#5

yes, but identity is not good.
Reply
#6

Quote:
Originally Posted by coool
Посмотреть сообщение
yes, but identity is not good.
indentation* #GrammarNazi
Reply
#7

Not sure what you mean, the way code is placed? It looks good in gamemode, when I pasted it here it just changed the position.
Reply
#8

I guess you are using spaces and tabs mixed but indentation is annoying, especially when using Pawno, because pawno is shit

Sublime for example can autoindent and convert tabs to spaces and the other way around
Reply
#9

You don't need else if there, just else.
Reply
#10

Quote:
Originally Posted by coool
Посмотреть сообщение
Make random of 10 numbers and in the if statement check only 1 number like this
PHP код:
new rand random(9); //random 9 because it will only have 10 numbers. 
We get random of 10 numbers but we check if the random results 1 that means 1 out of 10
EDIT: Marcel was fast
wrong random(9) will have only 9 numbers (0 - 8 )
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)