check value
#1

hi,

if i have smth like this:

pawn Код:
new const NUMBERS[4][1] =
{
    {0},{3},{4},{12}
};
How can i check if a number is included in this function?
E.g. when a player types in a number in a command and then when the typed in number is uncluded in this
collection i posted above it will say: Right number! other wise return wrong.
How can i do this?
I dont want u to script this command for me, just dont know how to check if the entered number is in the number pool.

thanks
Reply
#2

Loop through the array and check if the numbers are equal.
Reply
#3

What SuperViper said above, however you don't need a 2D array for that purpose:

pawn Код:
static const NUMBERS[] =
{
    0,
    3,
    4,
    12
};
And then you can do this:

pawn Код:
IsNumberRight(number)
{
    for (new i = 0; i < sizeof(NUMBERS); i ++)
    {
        if (NUMBERS[i] != number)
            continue;

        return 1;
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)