18.04.2017, 00:22
Hey I think my brain is either dieing or something but I am stumped on something that seems easy I just cant think rn. Anyways
I want to retrieve a players name from a mysql table from ID and return their name to use in a command.
I want to retrieve a players name from a mysql table from ID and return their name to use in a command.
Код:
forward OnLookUpVeh(playerid, plate[]); public OnLookUpVeh(playerid, plate[]) { new rows,fields; cache_get_data(rows,fields); new id_string[128], carname[48],owner, owner2[MAX_PLAYER_NAME], buytime[128], msg[128]; cache_get_row(0, 0, id_string); format(carname, sizeof(carname), "%s", VehiclesName[strval(id_string)-400]); cache_get_row(0,1, id_string); owner = strval(id_string); cache_get_row(0,2, buytime); GetNameFromCharID(owner);//Where I want to retrieve the name from cache_get_row(0,0, owner2); format(owner2, sizeof(owner2), "%s", strval(owner2)); format(msg, sizeof(msg), "Car Name: %s | Owner: %d | Purchased: %s", carname, 0, ReturnDate(buytime)); return 1; }
Код:
stock GetNameFromCharID(charid) { new query[512]; mysql_format(MySQLCon, query, 512, "SELECT `username` FROM `characters` WHERE `ID` = %d LIMIT 1", charid); return mysql_tquery(MySQLCon, query, "EmptyCallback", ""); }