Question
#1

How do you do (with strcmp, preferred) to check if the params is not ANY of these?

pawn Код:
new szAvailableName[9][28];
    szAvailableName[0] = "Meth";
    szAvailableName[1] = "Cocaine";
    szAvailableName[2] = "Heroin";
    szAvailableName[3] = "Speed";
    szAvailableName[4] = "Opium";
    szAvailableName[5] = "Weed";
    szAvailableName[6] = "Extacy";
    szAvailableName[7] = "Crack";
    szAvailableName[8] = "Glue";
If the params are not any of these it will return something.

Thanks.
Reply
#2

pawn Код:
for ( new i, s = sizeof ( szAvailableName ); i < s; ++i ) {
    if ( !strcmp( params, szAvailableName[ i ] ) ) {
        // return so the code does not continue to the no-match-found block
        return 1;
    }
}
// no match found
I also felt I should point out that you spelt 'ecstasy' incorrectly.
Reply
#3

Thank you for the correction and for the grammar correction. I feel satisfied with your help!
Reply
#4

Quote:
Originally Posted by admantis
Посмотреть сообщение
Thank you for the correction and for the grammar correction. I feel satisfied with your help!
I love that translation...
Reply
#5

But that will check if it detects ANY of the names, not one in specific?

@mprofitt: :P
Reply
#6

you should remove the "2" from the length, max length used there should be 8

pawn Код:
if ( !strcmp( params, szAvailableName[ id /*[0-9]?*/] ) )
this is for 1 check only
Reply
#7

Yes, it checks if it matches any of the names. The code under the loop will only execute if no match is found.
Reply
#8

Thanks.. I think I understood it.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)