18.11.2014, 08:08
My suggestion is make a server-wide account counter. Then just increase it by one every successful registration.
Create the variable
Now load that variable every time you initiate the server. I'm not familiar with yini, but in dini, it went something like this:
Save the variable whenever you feel like it:
Now to increase the counter's variable by one every time a user successfully registers:
It's been awhile since I've touched non-MySQL systems so it might not be the best format. It should work though.
Create the variable
pawn Код:
new
PlayerAccounts;
pawn Код:
stock LoadAccountCounter()
{
#define ACC_CTR_FILE "accounts.cfg"
if(!fexist(ACC_CTR_FILE)) return 1;
new
File: i_FileHandle = fopen("accounts.cfg", io_read), sz_FileStr[16];
fread(i_FileHandle, sz_FileStr);
sscanf(sz_FileStr, "p<,>i", PlayerAccounts); // You can add multiple variables to this, see below
return fclose(i_FileHandle);
}
pawn Код:
stock SaveAccountCounter()
{
new
sz_FileStr[16], File: i_FileHandle = fopen(ACC_CTR_FILE, io_write);
format(sz_FileStr, sizeof(sz_FileStr), "%d", PlayerAccounts); // Add multiple variables separated with a comma
fwrite(i_FileHandle, sz_FileStr);
#undef ACC_CTR_FILE
return fclose(i_FileHandle);
}
pawn Код:
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register","You haven't entered anything. Please enter a password to Proceed.","Register","Quit");
PlayerInfo[playerid][Password] = udb_hash(inputtext);
SavePlayer(playerid);
PlayerAccounts++; // ++ increases the counter
}
}