Anti Caps Lock not working
#1

~fixed~
Reply
#2

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
Hello the anti caps lock thing is not working, how to fix it?

Код:
		
                new string[128];
		format(string, sizeof(string),"{FFFF00}Team Chat %s : %s", PlayerName(playerid), text[1]);
		if(IsCaps(string))
                {
                     SendClientMessage(playerid,COLOR_RED" No Caps!");
                    return 0;
                }
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i) && team[i] == team[playerid]) SendClientMessage(i, -1, string);
		}
		return 0;
	}
stock IsCaps:

Код:
stock IsCaps( text[ ] )
{
	for( new i, j = strlen( text )-1; i < j; i ++ )
	{
		if( ( 'A' <= text[ i ] <= 'Z' ) && ( 'A' <= text[ i+1 ] <= 'Z' ) )
			return true;
	}
	return false;
}
I think you just have to replace second and third codes with each other,to be like this:
Код:
		if(IsCaps(string))
                {
                     SendClientMessage(playerid,COLOR_RED" No Caps!");
                    return 0;
                }
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
                new string[128]
                format(string, sizeof(string),"{FFFF00}Team Chat %s : %s", PlayerName(playerid), text[1]);
	        if(IsPlayerConnected(i) && team[i] == team[playerid]) 
                {
                  SendClientMessage(i, -1, string);
		}
		return 0;
}
Means to make the system checks if the chat contains caps first,And it should work now.
+rep me if helped.
Reply
#3

Your loop stops on the first encountered caps character. That isnt correct, as it should loop through all of them.
Код:
stock IsCaps( text[ ] )
{
	for( new i = 0, j = strlen( text ); i < j; i ++ )
	{
		if( ! ( 'A' <= text[ i ] <= 'Z' ))
			return false;
	}
	return true;
}
The function now returns false on the first non-caps character it returns. Also, the last character is no longer skipped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)