25.07.2015, 18:24
Quote:
Do you have a "name" variable in your table "characters"? Then you could try something like that:
Код:
MDCLookup(playerid, name[]) { new msg[256]; format(msg, sizeof(msg), "SELECT `c1`.`character`,`c1`.`phone`,`c1`.`id` FROM `characters` AS `c1` WHERE `c1`.`name` = %s", name); //try to search a record by "name" and not "id" mysql_function_query(g_iHandle, msg, true, "OnMDCRetrieve", "d", playerid); } forward OnMDCRetrieve(playerid); public OnMDCRetrieve(playerid) { new string[128], id_string[128]; new rows, fields; cache_get_data(rows, fields); if(rows < 1) { SendClientMessage(playerid, COLOR_GREY, "No records found."); return 1; } SendClientMessage(playerid, COLOR_GREY,"|__________LSPD Mobile Data Computer__________|"); cache_get_row(0, 0, id_string); format(string, sizeof(string), "NAME: %s", id_string); SendClientMessage(playerid, COLOR_WHITE, string); cache_get_row(0, 1, id_string); format(string, sizeof(string), "CONTACT NUMBER: %s", id_string); SendClientMessage(playerid, COLOR_WHITE, string); cache_get_row(0, 2, id_string); return 1; } CMD:mdc(playerid, params[]) { if (GetFactionType(playerid) != FACTION_POLICE) return SendErrorMessage(playerid, "You must be a police officer."); if (!IsACruiser(GetPlayerVehicleID(playerid))) return SendErrorMessage(playerid, "You must be inside a police cruiser."); new name[MAX_PLAYER_NAME]; if(!sscanf(params, "s[" #MAX_PLAYER_NAME "]", name)) { if(IsValidPlayerName(name)) { MDCLookup(playerid, name); } } else { return SendSyntaxMessage(playerid, "/mdc [player name]"); } return 1; } |