03.11.2016, 03:52
Automatically assuming that carOwner is a foreign key of some kind of player/account table in your database. Upon spawning the vehicle you also load the owner information.
Creating the function:
Add carOwnerName as a string into your CarData enum (carOwnerName[MAX_PLAYER_NAME]). Note, this is only a template of an example and not the actual answer, you cannot just copy-paste this expecting it will work.
Код:
format(query, sizeof(query), "SELECT PlayerName FROM playerTable WHERE ID=%i", CarData[id][carOwner]); mysql_tquery(connection, query, "OnPlayerLoadForVehicles", "i", CarData[id][carOwner]);
Код:
forward OnPlayerLoadForVehicles(vID); public OnPlayerLoadForVehicles(vID) { new rows = cache_get_row_count(connection); if (rows == 1) { cache_get_field_content(0, "PlayerName", CarData[vID][carOwnerName]); //select first row (0) and take out whatever is stated in it and place it into the enum } return 1; }