22.03.2016, 09:20
Seeing you trying to store "Username" into "UserID" just f*cks my mind right up. Change it please.
OT: Why do you need to return it? Just set the variable inside the callback?
OT: Why do you need to return it? Just set the variable inside the callback?
pawn Код:
stock UserFromID(ID)
{
new query[200];
mysql_format(MySQL, query, sizeof(query), "SELECT `Username` FROM `Users` WHERE `ID` = %d LIMIT 0,1", ID);
mysql_tquery(MySQL, query, "OnUserFromIDCheck", "i", ID);
return 1;
}
new UserNAME[MAX_PLAYERS];
forward OnUserFromIDCheck(ID);
public OnUserFromIDCheck(ID)
{
new rows, fields;
cache_get_data(rows, fields, MySQL);
if(rows == 1)
{
cache_get_field_content(0, "Username", UserNAME[ID], MySQL, MAX_PLAYER_NAME);
} else format(UserNAME[ID], MAX_PLAYER_NAME, "");
return 1;
}