Record of max players online - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Record of max players online (
/showthread.php?tid=259751)
Record of max players online -
Face9000 - 05.06.2011
Hi guys,is possibile to save in a file a record of max players online and reading it in the server with a command?How?
Re: Record of max players online -
Mauzen - 05.06.2011
pawn Код:
stock GetPlayerRecord()
{
new File:file = fopen("playerrecord.txt"); // Open a file
new string[8];
fread(file, string); // Read the content of the file
fclose(file); // Dont forget to close the file
return strval(string); // convert it to an integer and return the value
}
stock GetOnlinePlayers()
{
new count;
// Count all connected players
for (new i = 0; i < MAX_PLAYERS; i ++) count += IsPlayerConnected(i);
return count;
}
stock UpdatePlayerRecord()
{
// Check if there is a new player record
new onlines = GetOnlinePlayers();
if (onlines <= GetPlayerRecord()) return;
new File:file = fopen("playerrecord.txt");
new string[8];
format(string, 8, "%d", onlines); // convert the playercount to a string
fwrite(file, string); // And put it in the file
fclose(file);
}
// In OnPlayerConnect:
// Checks for a new player record every time a player joins
UpdatePlayerRecord();
Untested, but should work except for typos

The code should be quite self-explaining, but feel free to ask if you got a question.
Re: Record of max players online -
Face9000 - 05.06.2011
You rock! Thanks very much.