SA-MP Forums Archive
Problem with chars. - 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: Problem with chars. (/showthread.php?tid=238253)



Problem with chars. - Tomejus - 11.03.2011

Hello have a little problem with account registration. It is about that if u reg example Your_Nick is everything okey. but if you reg YouR_Nick it creates account, but it bugs with another account in this case Your_Nick how should i protect this ?


Re: Problem with chars. - MadeMan - 11.03.2011

Show your account system script.


Re: Problem with chars. - Tomejus - 11.03.2011

OnPlayerConnect:
Код:
<..>
	new
		query			[ 256 ],
		string			[ 80 ],
		pName			[ MAX_PLAYER_NAME ];
		
	GetPlayerName		( playerid, pName, MAX_PLAYER_NAME );
    
	format( query, 256, "SELECT id FROM `"TABLENAME"` WHERE Vardas = '%s'", pName );
	mysql_query(query);
	mysql_store_result();

    if( mysql_num_rows() == 1 ) pInfo[playerid][pId] = mysql_fetch_int();
    else pInfo[playerid][pId] = 0;
    mysql_free_result();
    
	if( pInfo[playerid][pId] == 0 )
	{
	    format			( string, sizeof( string ), "{FFFFFF}Sveikas, {AFE01B}%s, {FFFFFF}uюsiregistruokite.", pName );
		ShowPlayerDialog( playerid, 6, DIALOG_STYLE_INPUT, string, "{FFFFFF}Бraрykite savo norimа slaptaюodб apaиioje", "Registruotis", "Iрeiti" );
	}
	else
	{
	    format			( string, sizeof( string ), "{FFFFFF}Sveikas, {AFE01B}%s, {FFFFFF}prisijunkite", pName );
        ShowPlayerDialog( playerid, 7, DIALOG_STYLE_INPUT, string, "{FFFFFF}Бraрykite savo slaptaюodб apaиioje", "Prisijungti", "Iрeiti" );
	}
<..>
The dialog:
Код:
	if(dialogid == 6) // REG
    {
    	if(!response)
		{
			SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Jыs pasirinkote iрeiti, todлl buvote iрmestas.");
			Kick(playerid);
			return 1;
		}
		if(response)
        {
		    if(IsPlayerNPC(playerid)) return 1;
			new
				query			[ 256 ],
   				pName			[ MAX_PLAYER_NAME ],
				text 			[ 50 ],
				string 			[ 80 ];
				
			GetPlayerName		( playerid, pName, MAX_PLAYER_NAME );
			strmid				( text, inputtext, 0,64 ); StringToInt( text );
			
			if( !strcmp( text, "0", true ))
			{
	    		format			( string, sizeof( string ), "{FFFFFF}Sveikas, {AFE01B}%s, {FFFFFF}uюsiregistruokite.", pName );
				ShowPlayerDialog( playerid, 6, DIALOG_STYLE_INPUT, string, "{FFFFFF}Бraрykite savo norimа slaptaюodб apaиioje\n\
				{FF0000}Slaptaюodюio laukelis negali bыti tuриias!", "Registruotis", "Iрeiti" );
				return true;
			}
			if( strlen(inputtext) < 8 )
			{
	    		format			( string, sizeof( string ), "{FFFFFF}Sveikas, {AFE01B}%s, {FFFFFF}uюsiregistruokite", pName );
				ShowPlayerDialog( playerid, 6, DIALOG_STYLE_INPUT, string, "{FFFFFF}Бraрykite savo norimа slaptaюodб apaиioje\n\
				{FF0000}Slaptaюodis negali bыti trumpesnis nei 8 simboliai!", "Registruotis", "Iрeiti" );
				return true;
			}
			if( strlen(inputtext) > 50 )
			{
	    		format			( string, sizeof( string ), "{FFFFFF}Sveikas, {AFE01B}%s, {FFFFFF}uюsiregistruokite", pName );
				ShowPlayerDialog( playerid, 6, DIALOG_STYLE_INPUT, string, "{FFFFFF}Бraрykite savo norimа slaptaюodб apaиioje\n\
				{FF0000}Slaptaюodis negali bыti ilgesnis nei 50 simboliai!", "Registruotis", "Iрeiti" );
				return true;
			}
			mysql_real_escape_string( pName, pName );
			mysql_real_escape_string( text, text );
			
			format( query, 256, "INSERT INTO `"TABLENAME"` (Vardas, Slaptazodis, pos_X, pos_Y, pos_Z) VALUES ('%s',('%s'),'-1956.6219', '138.0429', '28.6940')", pName, text );
			mysql_query(query);
			
			pInfo				[ playerid ][ Logged ] = true;
			pInfo				[ playerid ][ PoRegistracijos ] = true;
			GivePlayerMoneyA	( playerid, 2000 );
			
			format( query, 256, "SELECT id FROM `"TABLENAME"` WHERE Vardas = '%s'", pName );
			mysql_query(query);
			mysql_store_result();
			pInfo[playerid][pId] = mysql_fetch_int();
    		mysql_free_result();
        }
        return true;
    }
The problem is if in DB are account example: John_Jocubs and if u come with JohN_Jocubs the system reques you to register and when both accounts buggy... :/ The best solution i think is if someone came up with JohN example he or she gets kick.. I have one stock wich helps me, but in this case not...
the stock:
Код:
stock InvalidNickKick(playerid)
{
	if(IsPlayerNPC(playerid))return 1;
    new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    new where = strfind(name,"_",true);
    new lenght = strlen(name)-1;
    new invalid = strfind(name,"[",true);
    if(invalid == -1) invalid = strfind(name,"]",true);

	if(name[0] < 65 || name[0] > 90)
    {
	    SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Jыsш slapyvardis neteisingas, vardas raрomas didюiajа raide.");
		SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Teisinga slapyvardюio forma bыtш:");
		SendClientMessage(playerid,LIGHTGREEN,"[ > ]{FF7E7E} Vardas_Pavarde");
	    Kick(playerid);
	    return 1;
	 }

	if(name[where+1] < 65 || name[where+1] > 90)
    {
	    SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Jыsш slapyvardis neteisingas, pavardл raрosi didюiajа raide.");
		SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Teisinga slapyvardюio forma bыtш:");
		SendClientMessage(playerid,LIGHTGREEN,"[ > ]{FF7E7E} Vardas_Pavarde");
	    Kick(playerid);
	    return 1;
	}

	for(new i = 1; i < where-1; i++)
	{
		if(name[i] < 97 || name[i] > 122)
		{
			SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Jыsш slapyvardis netinkamas, didюiosios raidлs negali bыti viduryje.");
			SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Teisinga slapyvardюio forma bыtш:");
			SendClientMessage(playerid,LIGHTGREEN,"[ > ]{FF7E7E} Vardas_Pavarde");
			Kick(playerid);
			return 1;
		}
	}

    if(where == 0 || where == lenght || where==-1)
	{
	    SendClientMessage(playerid, WHITE,"[ > ]{FF7E7E} Jыsш slapyvardis netinkamas.");
		SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Teisinga slapyvardюio forma bыtш:");
		SendClientMessage(playerid, WHITE,"[ > ]{FF7E7E} Vardas_Pavarde");
	    Kick(playerid);
	    return 1;
	}

	if(strlen(name[where])<4)
	{
		SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Jыsш slapyvardis per trumpas.");
		SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Teisinga slapyvardюio forma bыtш:");
		SendClientMessage(playerid, WHITE,"[ > ]{FF7E7E} Vardas_Pavarde");
	    Kick(playerid);
	    return 1;
	}

	if(where<3)
	{
		SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Jыsш slapyvardis per trumpas.");
		SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Teisinga slapyvardюio forma bыtш:");
		SendClientMessage(playerid, WHITE,"[ > ]{FF7E7E} Vardas_Pavarde");
	    Kick(playerid);
	    return 1;
	}


	if(invalid != -1)
	{
		SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Jыsш slapyvarde rasta netinkamш simboliш.");
		SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Teisinga slapyvardюio forma bыtш:");
		SendClientMessage(playerid, WHITE,"[ > ]{FF7E7E} Vardas_Pavarde");
	    Kick(playerid);
	    return 1;
	}

	for(new i = where+2; i < MAX_PLAYER_NAME; i++)
	{
		if(name[i] < 97 || name[i] > 122)
		{
			if(name[i] == 0){i = MAX_PLAYER_NAME; return 0;}
			SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Jыsш slapyvardis netinkamas dлl: Didюiosios raidлs, skaiиiai viduryje юodюio");
		    SendClientMessage(playerid, WHITE, "[ > ]{FF7E7E} Teisinga slapyvardюio forma bыtш:");
		    SendClientMessage(playerid, WHITE,"[ > ]{FF7E7E} Vardas_Pavarde");
		    Kick(playerid);
		    return 1;
		}
	}
	return 0;
}
Using this OnPlayerConnect. Thank you!