Help /changename without symbols
#1

Код:
	if(strcmp(cmd, "/changename", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if (Logged[playerid] != true)
		{
			SendClientMessage(playerid, COLOR1, "Not Logged In");
			return 1;
		}
		new last[256];
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR2, "USE: /changename [name]");
			return 1;
		}
		format(string, sizeof(string), "pplaccount/%s.asd", tmp);
		if(fexist(string))
		{
			SendClientMessage(playerid, COLOR2, "That nickname already exists");
			return 1;
		}
		GetPlayerName(playerid, pname, sizeof(pname));
		format(last, sizeof(last), "accounts/%s.cer", pname);
		fremove(last);
		return 1;
	}
I want to put this command in a way, when it's used only characters from [0-9], [a-z] and _ $ @ = [] () . can be used.
Please help :S
Reply
#2

Can't garantuee that this will work, but try:

pawn Код:
//anywhere
new gAllowedSymbols[ 46 ] =
    "0123456789abcdefghijklmnopqrstuvwxyz_$@=[]().";

pawn Код:
for( new l = 0, c = 0; l < strlen( tmp ) - 1, c = strlen( gAllowedSymbols ) - 1; l++; c++ ) //I don't know if this will work, but if not; make two loops
{
    if( tmp[ i ] != g_AllowedSymbols[ c ] )
        return SendClientMessage( playerid, COLOR2, "Allowed symbols: [0-9] [a-z] _ $ @ [ ] ( ) ." );
}
If this works at all, I'm sure there's a much more efficient way of doing this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)