Anti Caps Lock
#1

Hello, can someone say me how to make an Anti Caps Lock System? Please give me an example then.
Reply
#2

try this

pawn Код:
stock low(s[])
{
    for(new i=0; s[i] != EOS; i++)
        s[i] = ((s[i] > 31) && (s[i] < 59)) ? (s[i]) : (tolower(s[i]));
}
here's an example of using it:

pawn Код:
new mystring[] = "CAPslockKK!!";

printf("before: %s",mystring);
low(mystring);
printf("after: %s",mystring);

stock low(s[])
{
    for(new i=0; s[i] != EOS; i++)
        s[i] = ((s[i] > 31) && (s[i] < 59)) ? (s[i]) : (tolower(s[i]));
}
test it here

it will output

Код:
before: CAPSlockKKK!!
after: capslockkkk!!
like this, all the charsof a string will be turned into lowercase chars, IF they were uppercase chars.
Reply
#3

I think this should work.

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(IsTextCaps(text))
    {
        SendClientMessage(playerid, 0xFF0000FF, "Turn off your caps!");
        return 0; // Will not send the text
    }
    return 1;
}

stock IsTextCaps(text[])
{
    for(new i, j = strlen(text)-1; i < j; i ++)
    {
        if(('A' <= text[i] <= 'Z') && ('A' <= text[i+1] <= 'Z')) // If the letters were in CAPS
        return 1;
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)