SA-MP Forums Archive
Disabling Cap Keys - 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: Disabling Cap Keys (/showthread.php?tid=302098)



Disabling Cap Keys - xMichaelx - 07.12.2011

Hey,

I was on SACNR the other day and someone had there cap lock keys disabled by an admin how would i do this? And what method would this use?

Thanks.


Re: Disabling Cap Keys - Rob_Maate - 07.12.2011

Well... You could write a long-ass code:

pawn Код:
new string = //your input
new output
for(new i=0; i<sizeof(string); i++)
{
  if(strcmp(i, "A", true) || strcmp(i, "a", true))
  {
    i = "a"
    new currentoutput = output;
    format(output, sizeof(output) + 1, "%s%s", i, currentoutput);
  }
  if(strcmp(i, "B", true) || strcmp(i, "b", true))
  {
    i = "b"
    new currentoutput = output;
    format(output, sizeof(output) + 1, "%s%s", i, currentoutput);
  }
//etc.
}
string = output;



Re: Disabling Cap Keys - Sascha - 07.12.2011

maybe something like that..
pawn Код:
new CapsL[26][] =
{
    "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
    "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
};
new NCaps[26][] =
{
    "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
    "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
};

stock DisableCaps(text[])
{
    for(new n=0; n<strlen(text); n++)
    {
        for(new nx=0; nx<sizeof(CapsL); nx++)
        {
            if(text[n] == CapsL[nx])
            {
                text[n] = NCaps[nx];
            }
        }
    }
    return text;
}

public OnPlayerText(playerid, text[])
{
    if(playercapsdisbale[playerid])
    {
        new ntext[256];
        format(ntext, sizeof(ntext), "%s", DisableCaps(text));
        SendClientMessageToAll(GetPlayerColor(playerid), ntext);
        return 0;
    }
    return 1;
}
I did not test that, but just wrote it up.. if it doesn't work, it should at least give you a slight idea of how you could do it


Re: Disabling Cap Keys - JamesC - 07.12.2011

Or, you could do the same using decimals. The Ascii Table is your friend

pawn Код:
#define toLower(%0) for(new i;%0[i];i++) %0[i]+=(65<=%0[i]<=90)?32:0



Re: Disabling Cap Keys - cessil - 07.12.2011

tolower is a native, never used it until 5 seconds ago.

pawn Код:
new string[128] = "LOL CAPS LOCK";
    for(new i=0;i<strlen(string);i++)
    {
        string[i] = tolower(string[i]);
    }
    printf("nocaps = %s",string);



Re: Disabling Cap Keys - xMichaelx - 07.12.2011

Thanks all.