Registered Players counter. - 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)
+--- Thread: Registered Players counter. (
/showthread.php?tid=333852)
Registered Players counter. -
nickdodd25 - 13.04.2012
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?
Re: Registered Players counter. -
nickdodd25 - 14.04.2012
Bump. Any suggestions with make it count up?
Re: Registered Players counter. -
AustinJ - 14.04.2012
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.
Re: Registered Players counter. -
nickdodd25 - 14.04.2012
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?
Re: Registered Players counter. -
Jefff - 14.04.2012
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