Registered Players counter.
#1

Well i seen someone just asked about counting registered players from a file and i decided to work on mine again, i started making one but i couldnt get it figured out. I didnt want to hijack his thread so i made a new one. Heres the register dialog it is in.
pawn Код:
Dialog_Register(playerid, response, inputtext[])
{
    new TotalRegisteredPlayers;
    new file[100], bstr[5], Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(file, sizeof(file), PlayerFile, Name);

    switch (response)
    {
        case 1:
        {

            if(strlen(inputtext)>0)
            {
                TotalRegisteredPlayers++;
                format(APlayerData[playerid][PlayerPassword], 50, "%s", inputtext);
                PlayerFile_Create(playerid);
                PlayerFile_Load(playerid);
                SendClientMessage(playerid, 0xFFFFFFFF, TXT_AccountRegistered);
                APlayerData[playerid][LoggedIn] = true;
                format(bstr, sizeof(bstr), "%d",TotalRegisteredPlayers);
                new File:myfile = fopen("AdminFolder/RegisteredPlayers.txt",io_write);
                fwrite(myfile, bstr);
                fclose(myfile);
            }
            else
            {
                SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
                Kick(playerid);
            }
        }
        case 0:
        {
            SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustRegister);
            Kick(playerid);
        }
    }

    return 1;
}
And well it works but it only stays 1, it dosnt count up. On my test server there is only 10 registerd accounts from my beta testers and other admins and when i put 10 in it resets back to 1 and stays at 1. How would i make it so it gets the current number and adds 1 to it?
Reply
#2

Bump. Any suggestions with make it count up?
Reply
#3

new TotalRegisteredPlayers;

Put that at the top of your script. It needs to be a global variable.

And load the value of it when you start up your server.
Reply
#4

Quote:
Originally Posted by AustinJ
Посмотреть сообщение
new TotalRegisteredPlayers;

Put that at the top of your script. It needs to be a global variable.

And load the value of it when you start up your server.
Well i already had
pawn Код:
new TotalRegisteredPlayers;
In the dialog so moved it to the top of the gamemode. But how do i load the value?
Reply
#5

load
pawn Код:
new registered[15],File:myfile = fopen("AdminFolder/RegisteredPlayers.txt",io_read);
fread(myfile,registered);
fclose(myfile);
TotalRegisteredPlayers = strval(registered);
and new TotalRegisteredPlayers; on the top of GM
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)