Using strfind
#1

I have this define:

pawn Код:
#define     DIALOG_TEXT_REASONS     "Cheaters\nHi\nHl\nHel\nHi"
            /*
                Edit this string with your available reasons to kick a player.
                Put \n between reasons.
                Example: Cheating\nFlaming would display:       Cheating
                                                                Flaming
            */
and I'm trying to count the number of \n's and increase the number of the variable according to it like so:

pawn Код:
new lines = 0;
for( new i; i < 255; i++)
{
    if(strfind(DIALOG_TEXT_REASONS, "\n", true) != -1) { lines++; }
    printf("lines: %d", lines);
}
What am I doing wrong?
Reply
#2

str means string your using a define

find means find which is fine.

Put your define in somthing like this

pawn Код:
format(string, sizeof(string), "text");
Reply
#3

So, something like...

pawn Код:
new lines = 0;
                    for( new i; i < 255; i++)
                    {
                        new Str[128];
                        format(Str, sizeof(Str), DIALOG_TEXT_REASONS);
                        if(strfind(Str, "\n", true) != -1) { lines++; }
                        printf("lines: %d", lines);
                    }
Should work? (Very crude)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)