SA-MP Forums Archive
Anti Caps Lock - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Anti Caps Lock (/showthread.php?tid=496476)



Anti Caps Lock - Blackazur - 22.02.2014

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


Re: Anti Caps Lock - CutX - 22.02.2014

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.


Re: Anti Caps Lock - Stinged - 22.02.2014

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;
}