MDC System Problem
#10

Quote:
Originally Posted by Macronix
Посмотреть сообщение
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;
}
When I use that code, using /mdc does nothing, I don't even get the "No records found" error
Reply


Messages In This Thread
Number of arguments does not match definition - by Luke_James - 25.07.2015, 14:43
AW: MDC System Problem - by Macronix - 25.07.2015, 16:44
Re: MDC System Problem - by Luke_James - 25.07.2015, 17:04
AW: MDC System Problem - by Macronix - 25.07.2015, 17:24
Re: MDC System Problem - by Luke_James - 25.07.2015, 17:49
AW: MDC System Problem - by Macronix - 25.07.2015, 17:59
Re: MDC System Problem - by Luke_James - 25.07.2015, 18:01
AW: MDC System Problem - by Macronix - 25.07.2015, 18:06
Re: AW: MDC System Problem - by Luke_James - 25.07.2015, 18:19
Re: AW: MDC System Problem - by Luke_James - 25.07.2015, 18:24

Forum Jump:


Users browsing this thread: 1 Guest(s)