How do I get this to display ALL results? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How do I get this to display ALL results? (
/showthread.php?tid=322605)
How do I get this to display ALL results? -
Dokins - 03.03.2012
As the title says, I'd like it to display the FULL name as well as the number for all the query's LIKE it.
pawn Код:
CMD:findnumber(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(Phonebook[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You do not have a phonebook, you can buy one from a store.");
new player[24],string[128], query[256], result[24];
if(sscanf(params, "s[24]",player)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /findnumber [player name]");
format(query, sizeof(query), "SELECT `Number` FROM `accounts` WHERE `PlayerName` LIKE '%s%%%'", player);
mysql_query(query); // No query line
mysql_store_result(); // "Error nothing to store"
new rows = mysql_num_rows();
while(mysql_retrieve_row()) //this will be running until all rows are processed
{
mysql_fetch_field(rows, result);
}
new msnum = mysql_fetch_int();
if(rows > 0)
{
format(string, sizeof(string), "%s - %d",result, msnum);
SendClientMessage(playerid, COLOUR_WHITE, string);
}
if(rows == 0)
{
SendClientMessage(playerid, COLOUR_GREY, "There was no numbers found with that name.");
}
mysql_free_result();
return 1;
}
Re: How do I get this to display ALL results? -
Jefff - 03.03.2012
pawn Код:
CMD:findnumber(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(Phonebook[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You do not have a phonebook, you can buy one from a store.");
new player[24],string[128], query[256], result[24];
if(sscanf(params, "s[24]",player)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /findnumber [player name]");
format(query, sizeof(query), "SELECT `Number` FROM `accounts` WHERE `PlayerName` LIKE '%s%%'", player);
mysql_query(query); // No query line
if(mysql_store_result()) // "Error nothing to store"
{
do
{
mysql_get_field("Number",result);
format(string, sizeof(string), "%s - %s", player, result);
SendClientMessage(playerid, COLOUR_WHITE, string);
}
while(mysql_next_row());
}
else
{
SendClientMessage(playerid, COLOUR_GREY, "There was no numbers found with that name.");
}
mysql_free_result();
return 1;
}