[MySQL] mysql_fetch_row_format function. - 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: [MySQL] mysql_fetch_row_format function. (
/showthread.php?tid=356286)
[MySQL] mysql_fetch_row_format function. -
iansinho - 03.07.2012
So guys...
I want to show a list (dialog) of the characters of an account. I mean, there's a table: accounts. And another one: playeraccounts. At the 'playeraccounts' table there's a 'login' column, just to know the account of that character. So, when the player puts his password and logs in, this list will be shown. The code for this:
Код:
new escapedName[24];
GetPlayerName(extraid, szPlayerName, MAX_PLAYER_NAME);
mysql_real_escape_string(szPlayerName, escapedName);
new query2[300];
format(query2, sizeof(query2), "SELECT * FROM `playeraccounts` WHERE playerLogin = '%s'", escapedName); //
mysql_query(query2, THREAD_CHECK_CHARACTERS, playerid);
At the "OnQueryFinish":
Код:
case THREAD_CHECK_CHARACTERS:
{
mysql_store_result();
mysql_retrieve_row();
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row_format(result, " "))
{
format(szLargeString, sizeof(szLargeString), "%s\n%s", szLargeString, result);
}
ShowPlayerDialog(extraid, DIALOG_CHARACTERS, DIALOG_STYLE_LIST, "Select Character", szLargeString, "Selecionar", "");
mysql_free_result();
return 1;
}
else
{
SendClientMessage(extraid, COLOR_RED, "SERVER: {FFFFFF}You don't have any character. Create at the website.");
Kick(extraid);
}
}
The bug: when I put my password and log in, nothing happens.
Note: the first code its at the "onplayerlogin" function, so doesn't matter...