Get special caracteres - 
Ricop522 -  15.03.2011
How i block 
"~, #, @, !, -, _, ♣(etc), $%Ё&"
In this cmd ?
pawn Код:
if(strcmp(cmd, "/bizname", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new bouse = PlayerInfo[playerid][pPbiskey];
            if (bouse == 255)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You don't own a business");
                return 1;
            }
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USE: /bizname [nome]");
            }
            if (bouse >= 100)
            {
                strmid(SBizzInfo[bouse-100][sbMessage], result, 0, 64, 255);
                format(string, sizeof(string), "Business name set to %s",SBizzInfo[bouse-100][sbMessage]);
                OnPropUpdate(3,bouse);
                OnPropTextdrawUpdate(3, bouse);
            }
            else
            {
                strmid(BizzInfo[bouse][bMessage], result, 0, 64, 255);
                format(string, sizeof(string), "Business name set to %s",BizzInfo[bouse][bMessage]);
                OnPropUpdate(2,bouse);
                OnPropTextdrawUpdate(2, bouse);
            }
            SendClientMessage(playerid, COLOR_WHITE, string);
        }
        return 1;
    }
 
thank yo
Re: Get special caracteres - rjjj -  15.03.2011
Hi, Ricop522 
 
So, just make a loop to check if the string has a special character, if it has, you can use return to stop the function 
 
I did it for you with 
switch, look to the code that i put in your command.
Note: You can also check the ASCII characters and use 
< and 
> to make the code smaller 
 
pawn Код:
if(strcmp(cmd, "/bizname", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new bouse = PlayerInfo[playerid][pPbiskey];
            if (bouse == 255)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You don't own a business");
                return 1;
            }
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USE: /bizname [nome]");
            }
            //Look to the code that i made:
            for(new SpecialCaracter = 0; SpecialCaracter <= strlen(result); SpecialCaracter++)
            {
                switch(result[SpecialCaracter])
                {
                    case '~':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case '#':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case '@':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case '!':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case '-':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case '_':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case '?':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case '$':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case '%':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case 'Ё':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                    case '&':
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                        return 1;
                    }
                }
            }
            //The code finishs here
            if (bouse >= 100)
            {
                strmid(SBizzInfo[bouse-100][sbMessage], result, 0, 64, 255);
                format(string, sizeof(string), "Business name set to %s",SBizzInfo[bouse-100][sbMessage]);
                OnPropUpdate(3,bouse);
                OnPropTextdrawUpdate(3, bouse);
            }
            else
            {
                strmid(BizzInfo[bouse][bMessage], result, 0, 64, 255);
                format(string, sizeof(string), "Business name set to %s",BizzInfo[bouse][bMessage]);
                OnPropUpdate(2,bouse);
                OnPropTextdrawUpdate(2, bouse);
            }
            SendClientMessage(playerid, COLOR_WHITE, string);
        }
        return 1;
    }
 
I hope that i have helped 
 
Re: Get special caracteres - 
admantis -  15.03.2011
Shortening's above code
pawn Код:
if(strcmp(cmd, "/bizname", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new bouse = PlayerInfo[playerid][pPbiskey];
            if (bouse == 255)
            {
                SendClientMessage(playerid, COLOR_GRAD2, "   You don't own a business");
                return 1;
            }
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USE: /bizname [nome]");
            }
            //Look to the code that i made:
            for(new SpecialCaracter = 0; SpecialCaracter <= strlen(result); SpecialCaracter++)
            {
                switch(result[SpecialCaracter])
                {
                    case '~', '#', '@', '!', '-', '_', '?', 'ї', '$', '%', '&', '!', 'Ў', '·':
                        return SendClientMessage(playerid, COLOR_WHITE, "The bizname can't have special characters !");
                }
            }
            //The code finishs here
            if (bouse >= 100)
            {
                strmid(SBizzInfo[bouse-100][sbMessage], result, 0, 64, 255);
                format(string, sizeof(string), "Business name set to %s",SBizzInfo[bouse-100][sbMessage]);
                OnPropUpdate(3,bouse);
                OnPropTextdrawUpdate(3, bouse);
            }
            else
            {
                strmid(BizzInfo[bouse][bMessage], result, 0, 64, 255);
                format(string, sizeof(string), "Business name set to %s",BizzInfo[bouse][bMessage]);
                OnPropUpdate(2,bouse);
                OnPropTextdrawUpdate(2, bouse);
            }
            SendClientMessage(playerid, COLOR_WHITE, string);
        }
        return 1;
    }