[HELP]Success/Fail?
#1

Hello
I got a small question. I'm trying to make a small command "/rob" but I want to add a success / fail rate like chances of 25% to succeed. Can anyone help me with this? Thank you
Reply
#2

new success = random(4);
if(success != 1)
return SendClientMessage(playerid, -1, "fail);

i'm not sure if the random get the 0 but i gess not... so this way if the random returns 1 he will be able to rob else he will receive the message...
Reply
#3

How can I use the random(4) in my favor? For example random(2) = 50% chance.

And I didn't quite get the "If(success != 1)". Why should it be different from 1?

Please explain, I would appreciate.
Thanks ^^
Reply
#4

The random get a random number between 1 (i'm not sure if is 1 or 0...probably 1) and the number that you put... so when you use random(4) the chances to return 1 is 25% that way you know that he failed if the number is different from 1 (the 1 can be any number between 1 and 4)

idk if you understood...sorry my bad english :/
Reply
#5

Random gets a random value ranging from 0 to the value minus 1.

pawn Код:
random(100)
Would return a random value ranging from 0 to 99.

So, to use percentages:
pawn Код:
if (random(100) < 25) printf("You now have a 25% successrate");
Reply
#6

Thank you for the help Pharrel and PowerPC603
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)