getting total # of acc registered
#1

how can i get the total number of accounts registered i am using y_ini
Reply
#2

pawn Код:
enum ServerData
{
    PlayersRegistered
    //You can add additional stuff here that you might want to save as well
};
new ServerInfo[ServerData];

public OnGameModeInit()
{
    INI_ParseFile("Server.ini", "LoadServInfo_%s", .bExtra = false);
    //Other code...
    return 1;
}

//When a user registers...
ServerInfo[PlayersRegistered]++;
new INI:file = INI_Open("Server.ini");
INI_SetTag(file, "data");
INI_WriteInt(file, "PlayersRegistered", ServerInfo[PlayersRegistered]); //This is just in case the server ever crashes, so we don't use OnGameModeExit
INI_Close(file);
//

forward LoadServInfo_data(name[], value[]);
public LoadServInfo_data(name[], value[])
{
    INI_Int("PlayersRegistered", ServerInfo[PlayersRegistered]);
    //Other server stuff here...
    return 1;
}
Then you could use:
pawn Код:
printf("There are a total of %d players registered.", ServerInfo[PlayersRegistered]);
This is just an example of how to save the amount of players registered.

This uses a 'y_ini' based saving system.
Reply
#3

i have already know this way but how can i get the other # of acc that are registered already
Reply
#4

Well... you could count them manually I guess?
There's no real way to count them as far as I know :l
Reply
#5

If you can find a stock, or a code, that gets the last 3 characters of a string, you could make a loop, that loops through the path which would be wherever your accounts are stored, example "/accounts/" and for each string found that ends with ".ini" you add +1. I'm not sure how you would make the code to check the last 3 characters of a string, but it should be possible.
Reply
#6

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Well... you could count them manually I guess?
There's no real way to count them as far as I know :l
Actually there is. Right click on the Folder > Properties > Contains: x Files.
Reply
#7

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
Actually there is. Right click on the Folder > Properties > Contains: x Files.
I think it's obvious he means scriptwise.

OT:
You could make a seperate .ini file, and every time someone registers it just gets the value from that seperate .ini file, adds 1 and saves.. That's probably the easiest way with an ini based file system.
Reply
#8

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
I think it's obvious he means scriptwise.

OT:
You could make a seperate .ini file, and every time someone registers it just gets the value from that seperate .ini file, adds 1 and saves.. That's probably the easiest way with an ini based file system.
That.
He means to simply create a "Server.ini" file or something. There you can add the number of registrations every time someone registers. You can also store other Server stuff in there. For example, number of bans.
Reply
#9

SO I THINK I NEED TO COUNT THEM manually and add it in the server ini and next each time acc registers it's +1 to each
Reply
#10

Quote:
Originally Posted by NaClchemistryK
Посмотреть сообщение
That.
He means to simply create a "Server.ini" file or something. There you can add the number of registrations every time someone registers. You can also store other Server stuff in there. For example, number of bans.
yea i made something like that to store number of players banned by anticheat
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)