strfind
#1

Hello guys I'm trying to check if in a string there are only letters. I want to do it myself, so I tried 2 days and it still doesn't work. Can you please tell me what I'm doing wrong, I don't want anybody to give me the code, I just want to describe what piece of my code is wrong and what to change! Here is it:
PHP код:
bool:OnlyLetters(playerid, const text[])
{
    new 
chars = 1;
    for(new 
i = 'a'; i <= 'z'; i++)
    {
        new 
string[256];
        
format(string, sizeof(string), "%c", i);
        for(new 
l = 0; l <= strlen(text); l++)
        {
            if(
strfind(text[l], string, false)) chars++;
        }
        
format(string, sizeof(string), "%d, %d", chars, strlen(text));
        
SendClientMessage(playerid, COLOR_RED, string);
        if(
chars != strlen(text)) return false;
        else return 
true;
    }
    return 
false;
} 
Input: "hello123" and the variable chars shows as 10, it has to be 5 and ignore the other 3 chars("123").
Reply


Messages In This Thread
strfind - by Kraeror - 08.12.2018, 12:26
Re: strfind - by SyS - 08.12.2018, 12:51
Re: strfind - by Kraeror - 08.12.2018, 12:55
Re: strfind - by SyS - 08.12.2018, 13:08
Re: strfind - by Kraeror - 08.12.2018, 15:38
Re: strfind - by SyS - 08.12.2018, 15:46
Re: strfind - by Kraeror - 08.12.2018, 19:10

Forum Jump:


Users browsing this thread: 1 Guest(s)