SA-MP Forums Archive
Help /changename without symbols - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help /changename without symbols (/showthread.php?tid=182219)



Help /changename without symbols - OrlGiNS - 09.10.2010

Код:
	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


Re: Help /changename without symbols - LarzI - 09.10.2010

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.