AKA with MySQL.
#1

Hi all

I try to make an AKA system using MySQL. I have a problem on showing the names of IP what joined the player.

I make the query:
Код:
SELECT * FROM `Accounts` WHERE `IP` LIKE '127.0.0.1'
and now, how can i show all players what joined with that IP?
Reply
#2

Not good with MySQL but I think this will work...

pawn Код:
new string[128];
    new plrIP[16];
    GetPlayerIp(playerid, plrIP, sizeof(plrIP));
    format(string, sizeof(string), "SELECT * FROM `Accounts` WHERE `IP` = '%s'", plrIP);
    mysql_function_query(rename, string, true, "OnIPCheck", "i", playerid);
Then
pawn Код:
forward OnIPCheck(index);
public OnIPCheck(index)
{
    mysql_store_result(rename);
    if(mysql_num_rows(rename) > 0) // Change to how many rows and what you want to do..
    {
    }
}
Should work I think, also depends on which MySQL plugin you're using but you should get the point.

Also change rename to your connection settings.
Reply
#3

I using MySQL plugin R6

Yes, I know that ... I don't know how to load the names, what have the IP, for exemple: "127.0.0.1"

---------
I make this:
Код:
CMD:aka( playerid, params[ ] )
{
	VACheck( playerid, 3, 2 );
    
        new
		Player
	;
        if ( sscanf( params, "u", Player ) )
		return SendClientMessage( playerid, COLOR_ULTRARED, "USAGE: {33CCFF}/aka [PlayerID]" );

	if ( !IsPlayerConnected( Player ) )
		return SendError( playerid, "Player is not connected!" );

	if ( PlayerInfo[ Player ][ Level ] > PlayerInfo[ playerid ][ Level ] )
		return SendError( playerid, "You cannot use this command on this admin" );

	new
	    sz_Query[ 128 ]
	;
	format( sz_Query, sizeof sz_Query, "SELECT `Name` FROM `Accounts` WHERE `IP` LIKE '%s'", GetPlayerIPEx( Player ) );
	mysql_query( sz_Query, THREAD_LOAD_AKA, playerid );
	return 1;
}
In OnQueryFinish callback, I put these codes:
Код:
...
case THREAD_LOAD_AKA:
		{
		    mysql_store_result( );
		    
			if ( !IsPlayerConnected( extraid ) )
			    return mysql_free_result( );

			new
			    pAKA[ 256 ],
			    p_Aka_Names[ 25 ]
			;
			while( mysql_fetch_row_format( pAKA ) )
			{
			    sscanf( pAKA, "p<|>s[25]", p_Aka_Names );
			    printf( "%s", p_Aka_Names );
			}
			FormatMSG( extraid, COLOR_ABLUE, "Aka: %s,", p_Aka_Names );
		}
...
But it don't load just the last account what have IP "127.0.0.1"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)