Odd bug with y_ini?
#1

Hey guys, I just encountered a real big error, I don't know if it's my coding or y_ini, but there is a something going on..

I registered with a new account. My stats are set to 0.

pawn Код:
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                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");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"VIP",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"XP",0);
                INI_WriteInt(File,"Cookies",0);
                INI_WriteInt(File,"Seconds",0);
                INI_WriteInt(File,"Minutes",0);
                INI_WriteInt(File,"Hours",0);
                INI_Close(File);
   ...
I disconnect, and wait.
People come, they register and after a while, disconnect.
I check the "Users" folder, and I find something odd.

As I mentioned with the code above, when you register for the first time, it should have your stats set to zero.

However look at this..

This is me:

Код:
[data]
Password = N/A
Cash = 2826
Admin = 6
VIP = 3
Kills = 0
Deaths = 0
Score = 0
Banned = false
Jailed = false
Muted = false
Caged = 0
CageTime = 0
XP = 24
Cookies = 29
Seconds = 28
Minutes = 6
Hours = 0
Here is the next user registered...
Код:
[data]
Password = 307823447
Cash = 0
Admin = 0
VIP = 0
Kills = 0
Deaths = 0
Score = 0
Banned = false
Jailed = false
Muted = false
Caged = 0
CageTime = 0
All fine and dandy..then all of the sudden..

Код:
[data]
Password = 348062537
Cash = 0
Admin = 6
VIP = 3
Kills = 0
Deaths = 0
Score = 0
XP = 24
Cookies = 29
Seconds = 11
Minutes = 21
Hours = 12
Banned = false
Jailed = false
Muted = false
Caged = 0
CageTime = 0
This player just registered and got this!

Something wrong?
Reply
#2

Reset your variables under OnPlayerConnect.

For example:

Код:
public OnPlayerConnect(playerid)
{
PlayerData[playerid][Cookies] = 0;
}
This must be done to all your player assigned variables, or the server might bug and give players messed up information.
Reply
#3

Great, however, should I place it on the below all the information..? or on top, because I have if's with variables like if he is muted and leaves and comes back, he still is muted. Wouldn't setting it to zero mean that he is no longer muted once he connects?
Reply
#4

Once he connets, set his stats to 0.
Once he loggs in, load all his stats.

It will all save, you just need to set all his stats to 0 BEFORE he loggs in.
Reply
#5

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)