SA-MP Forums Archive
How can I collect? - 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 can I collect? (/showthread.php?tid=541953)



How can I collect? - Ahriman - 15.10.2014

Hello,

I want to collect lines on MySQL so I used "MySQL_Count" fuction but I had a problem with it.

On the pop-up screen, I got "undefined symbol "MySQL_Count" alert.

Does anyone have an idea, how I can fix this problem?


Re: How can I collect? - austin070 - 15.10.2014

You could just use mysql_num_rows() and store it with mysql_store_result().


Re: How can I collect? - Mark_Weston - 16.10.2014

Easy, I assume you want to could all registered players on the server from the database?

This is what I did:

[pwano]
CMD:registeredplayers(playerid, params[]) {
mysql_query("SELECT * FROM `accounts`");
mysql_store_result();
new string[128];
format(string, sizeof(string), "[SERVER]: There are currently %d currently registered players.", mysql_num_rows());
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
mysql_free_result();
return 1;
}
[/pawno]

* means ALL

samething can be done for total houses, total businesses, total tickets, etc.


Re: How can I collect? - KingHual - 16.10.2014

use SELECT COUNT


Re: How can I collect? - Ahriman - 16.10.2014

Quote:
Originally Posted by Mark_Weston
Посмотреть сообщение
Easy, I assume you want to could all registered players on the server from the database?

This is what I did:

[pwano]
CMD:registeredplayers(playerid, params[]) {
mysql_query("SELECT * FROM `accounts`");
mysql_store_result();
new string[128];
format(string, sizeof(string), "[SERVER]: There are currently %d currently registered players.", mysql_num_rows());
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
mysql_free_result();
return 1;
}
[/pawno]

* means ALL

samething can be done for total houses, total businesses, total tickets, etc.
Thank a lot. İt's works!


Re: How can I collect? - Vince - 16.10.2014

Quote:
Originally Posted by KingHual
Посмотреть сообщение
use SELECT COUNT
This. There are usually multiple ways to get to the result, but they are not all equally efficient. Selecting a single number is obviously going to be much faster than loading an entire result into memory.