Compare Switch(random)) -
kevin1990 - 10.02.2015
Hey everyone,
Is it possible to compare a random number this is drawn with switch. To a number a player types in a params?
For instance
If I had
Код:
CMD:Ticket (playerid, params[]) {
new string[128], number;
if(sscanf(params, "d", number))
And say they said "/ticket 23"
I then want to do a random switch like
Код:
Switch(random(100))
case 1:
{
if ------Checks to make sure the can pay for a ticket
{
If there number matches 1 here
}
else
Tell them what number HERE
}
return 1;
}
Case 2:
and so on......
Is this possible?
Re: Compare Switch(random)) -
CalvinC - 10.02.2015
Yes you can.
Re: Compare Switch(random)) -
kevin1990 - 10.02.2015
Thank you, Now can you tell me
how?
Re: Compare Switch(random)) -
Sime30 - 10.02.2015
pawn Код:
random(100) // Starts from 0 to 99
case 0:
{
}
case 1:
{
}
case 2:
{
}
case 3..60:
{
}
case 61..98: // from 61 to 98
{
}
default: //else
{
}
Re: Compare Switch(random)) -
kevin1990 - 10.02.2015
But How do I make it look to see if it matches the number they typed in after /ticket NUMBER
I know how to make cases.....
Re: Compare Switch(random)) -
CalvinC - 10.02.2015
Pretty much like you did, you just did a few mistakes in using a switch, this is how you should use it:
pawn Код:
switch(random(3))
{
case 0:
case 1:
case 2:
case 3:
}
Re: Compare Switch(random)) -
Sime30 - 10.02.2015
You mean
pawn Код:
switch(params)
{
case 23:
{
}
}
Re: Compare Switch(random)) -
kevin1990 - 10.02.2015
Ok,
Guys, I know how to do a case..
What I am asking is... if the player does /ticket NUMBER
How do I compare the NUMBER they typed.... to a certain case.
so if they picked 23, and the random number 23 came up.. How to tell they were right?
Re: Compare Switch(random)) -
CalvinC - 10.02.2015
You can check with an "if" for that.
pawn Код:
switch(random(100))
{
case 23: if(number == 23) // Code
}
Re: Compare Switch(random)) -
kevin1990 - 10.02.2015
Quote:
Originally Posted by CalvinC
You can check with an "if" for that.
pawn Код:
switch(random(100)) { case 23: if(number == 23) // Code }
|
Ok so,
if(number == 23) // Code
Would the word number be my params for CMD:ticket?
so it checks to see if the params of CMD ticket == the case?