08.12.2018, 12:26
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:
Input: "hello123" and the variable chars shows as 10, it has to be 5 and ignore the other 3 chars("123").
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;
}