19.11.2012, 00:22
I'm trying to write a function that grabs a player's username based on their MySQL ID (reference). The issue that I'm having with it is that it appears that the initial function isn't forwarding to the callback and is simply returning on the query.
Here are the functions/callback:
And here's is an example command I made for testing this:
Here's what it's outputting:

That third line is what's outputting from the command, which leads me to believe that, because it's outputting that before the callback output, it's simply not forwarding to the callback so it won't display the correct result. If anyone could provide some assistance on this, that would be greatly appreciated.
Here are the functions/callback:
Код:
stock GetPlayerSQLName(id)
{
new query[128];
format(query, sizeof(query), "SELECT `Username` FROM `accounts` WHERE `id` = %d", id);
mysql_function_query(MainPipeline, query, true, "OnUsernameGet", "i", id);
printf(query);
return 1;
}
forward OnUsernameGet(id);
public OnUsernameGet(id)
{
new rows, fields, name[24];
cache_get_data(rows, fields, MainPipeline);
if(rows)
{
cache_get_field_content(0, "Username", name, MainPipeline);
ReturnName(name);
printf(name);
}
}
stock ReturnName(name[])
{
printf(name);
new string[24];
return string;
}
Код:
CMD:farva(playerid, params[])
{
new string[48];
format(string, sizeof(string), "- %s", GetPlayerSQLName(GetPlayerSQLId(playerid)));
SendClientMessage(playerid, COLOR_GRAD2, string);
printf(string);
return 1;
}
That third line is what's outputting from the command, which leads me to believe that, because it's outputting that before the callback output, it's simply not forwarding to the callback so it won't display the correct result. If anyone could provide some assistance on this, that would be greatly appreciated.

