big problems with accounts
#1

Hello, i have a big problems with my registration system.

I have a public COD server with a medium player base and restarting the server for trying to fix this problem is becoming annoying and stressing.

The problem is, sometimes when a player register, the server creates BLANK account file (0 kb without variables inside, like money, pass etc.)

I tried everything, even rescripting the registration system, but nothing.

This is the registration part:

Use file path:

pawn Код:
#define PATH "/Users/%s"
Registration dialog code:

pawn Код:
case DIALOG_REGISTER:
        {
            if(!response)
            {
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","{FF0000}You have entered an invalid password.\n""Type your password below to register a new account.","Register","Quit");
            }
            if(response)
            {
                new Year, Month, Day, Hour, Minute, Second;
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Second);
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                new IP[16];
                GetPlayerIp(playerid,IP,16);
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",1500);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"NoPm",0);
                INI_WriteInt(File,"Mute",0);
                INI_WriteInt(File,"Vip",0);
                INI_WriteInt(File,"C4",0);
                INI_WriteInt(File,"Banned",0);
                INI_WriteInt(File,"Cookies",0);
                INI_WriteInt(File,"Warn",0);
                INI_WriteInt(File, "RegisterDate_day", Day);
                INI_WriteInt(File, "RegisterDate_mon", Month);
                INI_WriteInt(File, "RegisterDate_year",Year);
                INI_WriteInt(File, "RegisterDate_hour",Hour);
                INI_WriteInt(File, "RegisterDate_min", Minute);
                INI_WriteInt(File, "RegisterDate_sec", Second);
                INI_WriteInt(File, "Ip", IP[playerid]);
                INI_WriteInt(File, "Min", 0);
                INI_WriteInt(File, "Hour", 0);
                INI_WriteInt(File, "Sec", 0);
                INI_WriteInt(File, "Jailed", 0);
                INI_WriteInt(File, "Logged", 1);
                INI_WriteInt(File, "AdminActions", 0);
                INI_WriteInt(File, "Rank", 0);
                INI_Close(File);
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
                SetPlayerCash(playerid, PlayerInfo[playerid][pCash]);
                SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pRank]);
                SCM(playerid,-1,"{F70505}Registered and autologged! {FF0000}Now all your data are auto saved.");
                TotalRegister++;
                new msg[250], name[MAX_PLAYER_NAME];
                new msg2[250];
                new plrIP[16];
                GetPlayerIp(playerid, plrIP, sizeof(plrIP));
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Second);
                GetPlayerName(playerid, name, sizeof(name));
                format(msg, sizeof(msg), "4%s (%d) has registered a new account on Cod Samp - Ip: %s - %02d/%02d/%d - %02d:%02d:%02d - Total Accounts: %d", name, playerid,plrIP,Day,Month,Year,Hour,Minute,Second,TotalRegister);
                IRC_GroupSay(gGroupID, IRC_ACHANNEL, msg);
                format(msg2, sizeof(msg2), "%s (%d) has registered a new account on Cod Samp - Ip: %s - %02d/%02d/%d - %02d:%02d:%02d - Total Accounts: %d", name, playerid,plrIP,Day,Month,Year,Hour,Minute,Second,TotalRegister);
                AccountsLog(msg2);
                format(LastAccount,sizeof(LastAccount),"%s (%d) has registered a new account on Cod Samp - Ip: %s - %02d/%02d/%d - %02d:%02d:%02d - Total Accounts: %d",  name, playerid,plrIP,Day,Month,Year,Hour,Minute,Second,TotalRegister);
            }
Sometimes it create the player file and sometimes not.

It's a problem because when the server creates the blank account file, players cant even login!

Please help.

Thanks.
Reply
#2

Do some prints see if all variables are currect to save.
It might be saving "-1","empty" variables which couse it to crash
Reply
#3

#define PATH "/Users/%s.ini" don't know if it will solve your probelm but try it anyway
Reply
#4

Quote:
Originally Posted by thefatshizms
Посмотреть сообщение
#define PATH "/Users/%s.ini" don't know if it will solve your probelm but try it anyway
Nope, doesnt work.
Reply
#5

Here is a critical error !
pawn Код:
new IP[16];
GetPlayerIp(playerid,IP,16);
INI_WriteInt(File, "Ip", IP[playerid]);
Should be IP not IP[playerid] !

if playerid > 15 = code crash
Reply
#6

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Here is a critical error !
pawn Код:
new IP[16];
GetPlayerIp(playerid,IP,16);
INI_WriteInt(File, "Ip", IP[playerid]);
Should be IP not IP[playerid] !

if playerid > 15 = code crash
Emh, what?

I dont have anything of it.
Reply
#7

Sorry for bumping but i have to add a thing:

I noticed it stop works when there are more than 10 players online.

MAX_PLAYERS is set to 32 (are the currently server slots).
Reply
#8

pawn Код:
new IP[16];
GetPlayerIp(playerid,IP,16);
INI_WriteInt(File, "Ip", IP[playerid]);
TO
pawn Код:
new IP[MAX_PLAYERS];
GetPlayerIp(playerid,IP,MAX_PLAYERS);
INI_WriteInt(File, "Ip", IP[playerid]);
Reply
#9

Quote:
Originally Posted by maramizo
Посмотреть сообщение
pawn Код:
new IP[16];
GetPlayerIp(playerid,IP,16);
INI_WriteInt(File, "Ip", IP[playerid]);
TO
pawn Код:
new IP[MAX_PLAYERS];
GetPlayerIp(playerid,IP,MAX_PLAYERS);
INI_WriteInt(File, "Ip", IP[playerid]);
There's no reason at all to make IP a player-array.

In the OP, it was just a single line being incorrect, and that was the writing line. He declared IP as a 16-cell array; which is the largest an IP can be, and he set it to 'playerid's IP; which is correct. He was trying to do 'IP[playerid]' when in reality, IP was only a string var. He was also trying to write the string variable 'IP' into the player file as an integer - which also is incorrect.

HOW TO FIX: Change this
pawn Код:
INI_WriteInt(File, "Ip", IP[playerid]);
to this
pawn Код:
INI_WriteString(File, "Ip", IP);
Edit: In the original code, there's a declaration of a variable called plrIP which is used to get the players IP once again. This is highly unnecessary. String variables are declared with a cell-size of 250 which is too damn much.

I suggest trying this code:
pawn Код:
case DIALOG_REGISTER:
        {
            if(!response)
            {
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","{FF0000}You have entered an invalid password.\n""Type your password below to register a new account.","Register","Quit");
            }
            if(response)
            {
                new Year, Month, Day, Hour, Minute, Second;
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Second);
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                new IP[16];
                GetPlayerIp(playerid,IP,16);
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",1500);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"NoPm",0);
                INI_WriteInt(File,"Mute",0);
                INI_WriteInt(File,"Vip",0);
                INI_WriteInt(File,"C4",0);
                INI_WriteInt(File,"Banned",0);
                INI_WriteInt(File,"Cookies",0);
                INI_WriteInt(File,"Warn",0);
                INI_WriteInt(File, "RegisterDate_day", Day);
                INI_WriteInt(File, "RegisterDate_mon", Month);
                INI_WriteInt(File, "RegisterDate_year",Year);
                INI_WriteInt(File, "RegisterDate_hour",Hour);
                INI_WriteInt(File, "RegisterDate_min", Minute);
                INI_WriteInt(File, "RegisterDate_sec", Second);
                INI_WriteInt(File, "Ip", IP[playerid]);
                INI_WriteInt(File, "Min", 0);
                INI_WriteInt(File, "Hour", 0);
                INI_WriteInt(File, "Sec", 0);
                INI_WriteInt(File, "Jailed", 0);
                INI_WriteInt(File, "Logged", 1);
                INI_WriteInt(File, "AdminActions", 0);
                INI_WriteInt(File, "Rank", 0);
                INI_Close(File);
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
                SetPlayerCash(playerid, PlayerInfo[playerid][pCash]);
                SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pRank]);
                SCM(playerid,-1,"{F70505}Registered and autologged! {FF0000}Now all your data are auto saved.");
                TotalRegister++;
                new msg[128], name[MAX_PLAYER_NAME];
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Second);
                GetPlayerName(playerid, name, sizeof(name));
                format(msg, sizeof(msg), "4%s (%d) has registered a new account on Cod Samp - Ip: %s - %02d/%02d/%d - %02d:%02d:%02d - Total Accounts: %d", name, playerid,IP,Day,Month,Year,Hour,Minute,Second,TotalRegister);
                IRC_GroupSay(gGroupID, IRC_ACHANNEL, msg);
                format(msg, sizeof(msg), "%s (%d) has registered a new account on Cod Samp - Ip: %s - %02d/%02d/%d - %02d:%02d:%02d - Total Accounts: %d", name, playerid,IP,Day,Month,Year,Hour,Minute,Second,TotalRegister);
                AccountsLog(msg);
                format(LastAccount,sizeof(LastAccount),"%s (%d) has registered a new account on Cod Samp - Ip: %s - %02d/%02d/%d - %02d:%02d:%02d - Total Accounts: %d",  name, playerid,IP,Day,Month,Year,Hour,Minute,Second,TotalRegister);
            }
Reply
#10

Sigh; it is 5:30 in the morning, I can't believe I actually told someone to store IP in a MAX_PLAYERS array.
Also, LarzI, you didn't update the wrong code, here it is:
pawn Код:
case DIALOG_REGISTER:
        {
            if(!response)
            {
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","{FF0000}You have entered an invalid password.\n""Type your password below to register a new account.","Register","Quit");
            }
            if(response)
            {
                new Year, Month, Day, Hour, Minute, Second;
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Second);
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                new IP[16];
                GetPlayerIp(playerid,IP,16);
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",1500);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"NoPm",0);
                INI_WriteInt(File,"Mute",0);
                INI_WriteInt(File,"Vip",0);
                INI_WriteInt(File,"C4",0);
                INI_WriteInt(File,"Banned",0);
                INI_WriteInt(File,"Cookies",0);
                INI_WriteInt(File,"Warn",0);
                INI_WriteInt(File, "RegisterDate_day", Day);
                INI_WriteInt(File, "RegisterDate_mon", Month);
                INI_WriteInt(File, "RegisterDate_year",Year);
                INI_WriteInt(File, "RegisterDate_hour",Hour);
                INI_WriteInt(File, "RegisterDate_min", Minute);
                INI_WriteInt(File, "RegisterDate_sec", Second);
                INI_WriteString(File, "Ip", IP);
                INI_WriteInt(File, "Min", 0);
                INI_WriteInt(File, "Hour", 0);
                INI_WriteInt(File, "Sec", 0);
                INI_WriteInt(File, "Jailed", 0);
                INI_WriteInt(File, "Logged", 1);
                INI_WriteInt(File, "AdminActions", 0);
                INI_WriteInt(File, "Rank", 0);
                INI_Close(File);
                INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
                SetPlayerCash(playerid, PlayerInfo[playerid][pCash]);
                SetPlayerWantedLevel(playerid, PlayerInfo[playerid][pRank]);
                SCM(playerid,-1,"{F70505}Registered and autologged! {FF0000}Now all your data are auto saved.");
                TotalRegister++;
                new msg[128], name[MAX_PLAYER_NAME];
                getdate(Year, Month, Day);
                gettime(Hour, Minute, Second);
                GetPlayerName(playerid, name, sizeof(name));
                format(msg, sizeof(msg), "4%s (%d) has registered a new account on Cod Samp - Ip: %s - %02d/%02d/%d - %02d:%02d:%02d - Total Accounts: %d", name, playerid,IP,Day,Month,Year,Hour,Minute,Second,TotalRegister);
                IRC_GroupSay(gGroupID, IRC_ACHANNEL, msg);
                format(msg, sizeof(msg), "%s (%d) has registered a new account on Cod Samp - Ip: %s - %02d/%02d/%d - %02d:%02d:%02d - Total Accounts: %d", name, playerid,IP,Day,Month,Year,Hour,Minute,Second,TotalRegister);
                AccountsLog(msg);
                format(LastAccount,sizeof(LastAccount),"%s (%d) has registered a new account on Cod Samp - Ip: %s - %02d/%02d/%d - %02d:%02d:%02d - Total Accounts: %d",  name, playerid,IP,Day,Month,Year,Hour,Minute,Second,TotalRegister);
            }
edit:
Also @ OP, make sure you edit the loading callback to load a STRING named IP, not an integer, or it will load as xxx instead of xxx.xxx.xxx.xxx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)