AKA with MySQL. - 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)
+--- Thread: AKA with MySQL. (
/showthread.php?tid=368721)
AKA with MySQL. -
Edvin - 14.08.2012
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?
Re: AKA with MySQL. -
ryansheilds - 14.08.2012
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.
Re: AKA with MySQL. -
Edvin - 14.08.2012
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"