Total Registered Players
#1

Hi guys,

My problem is that I want to count how many players registered on the server and I am using MySQL R7 I tried every tutorial, threads etc. but nothing worked pls can someone help me out.
Reply
#2

Supposing you have a table like `Players` or `Accounts` you can just simply execute:
pawn Код:
SELECT COUNT(*) FROM `Players`;
either in the console/phpmyadmin/or just do it in a function on server and then retrieve the result whatever you need it for.
Reply
#3

Have you tried mysql_num_rows()?

pawn Код:
mysql_query("SELECT * FROM `table` WHERE `something` != something");
mysql_store_result();
new string[128];
format(string, sizeof(string), ">  You have %d registered players.", mysql_num_rows());
SendClientMessage(playerid, 0xFFFFFFFF, string);
mysql_free_result();
Best regards,
Jesse

EDIT:
Quote:
Originally Posted by Koala818
Посмотреть сообщение
Supposing you have a table like `Players` or `Accounts` you can just simply execute:
pawn Код:
SELECT COUNT(*) FROM `Players`;
either in the console/phpmyadmin/or just do it in a function on server and then retrieve the result whatever you need it for.
Is also a good way to do it.
Reply
#4

uhmm bro I tried but I didn't tried `something` btw what is something here ?
Reply
#5

Quote:
Originally Posted by Vaishnav
Посмотреть сообщение
uhmm bro I tried but I didn't tried `something` btw what is something here ?
The `something` has to be a variable from the SQL table you're selecting and the last something (The one without `) has to be a value they'll never be.

Best regards,
Jesse
Reply
#6

well bro as I said I am using MySQL R7 so mysql_query will won't work :\ pls help

Edit: and it always says -1 accounts :\ pls someone help
Reply
#7

Make a global variable .
Код:
 new totalplayers=0; //At the top of your script
then when player registers, just do a increment there.
Under OnDialogResponse\register section

Код:
totalplayers+=1
And that's it.
Reply
#8

You means
Код:
	format(str, sizeof(str), ""PINK"[NSE] {%06x}%s(%d) {F7B0D0}has registered, making the server have a total {11ED65}%d {F7B0D0}players registered.", random_color >>> 8, GetName(playerid), playerid, gTotalRegisters);
 		 	SetPlayerColor(playerid, random_color);
            SendClientMessageToAll(0x2BD9F8FF, str);
?
Reply
#9

yes I want something like this

but I am using MySQL ...

Edit: @Rittik, bro I tried It, it got resetted after every server restart :\
Reply
#10

Quote:
Originally Posted by Koala818
Посмотреть сообщение
Supposing you have a table like `Players` or `Accounts` you can just simply execute:
pawn Код:
SELECT COUNT(*) FROM `Players`;
either in the console/phpmyadmin/or just do it in a function on server and then retrieve the result whatever you need it for.
SELECT COUNT(`players_id_or_any_unique_key`) FROM `Players`;
would be even faster.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)