Total Registered Players -
Vaishnav - 06.06.2014
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.
Re: Total Registered Players -
Koala818 - 06.06.2014
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.
Re: Total Registered Players -
jessejanssen - 06.06.2014
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.
Re: Total Registered Players -
Vaishnav - 06.06.2014
uhmm bro I tried but I didn't tried `something` btw what is something here ?
Re: Total Registered Players -
jessejanssen - 06.06.2014
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
Re: Total Registered Players -
Vaishnav - 06.06.2014
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
Re: Total Registered Players -
Rittik - 06.06.2014
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
And that's it.
Re: Total Registered Players -
Dangjai - 06.06.2014
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);
?
Re: Total Registered Players -
Vaishnav - 06.06.2014
yes I want something like this
but I am using MySQL ...
Edit: @Rittik, bro I tried It, it got resetted after every server restart :\
Re: Total Registered Players -
Djole1337 - 06.06.2014
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.