Y_Ini problem:
#1

pawn Code:
CMD:register(playerid, params[])
{
    new file[256],n[MAX_PLAYER_NAME];
    GetPlayerName(playerid,n,MAX_PLAYER_NAME);
    format(file,sizeof(file),"mAdmin/Users/%s.txt",n);
    if(fexist(file))
        return SendClientMessage(playerid,YELLOW,"You are already registered!");
    if(PInfo[playerid][Regged] == 1)
        return SendClientMessage(playerid,LIGHTBLUE,"You are already registered!");
    if(PInfo[playerid][Logged] == 1)
        return SendClientMessage(playerid,ORANGE,"You are already registered, and logged in!");
    new INI:PlayerAcc = INI_Open(file);
    if(!isnull(params))
    {
        if(!fexist(file))
        {
            INI_WriteString(PlayerAcc,"Password",params);
            INI_WriteInt(PlayerAcc,"Regged",1);
            INI_WriteInt(PlayerAcc,"Logged",0);
            INI_WriteInt(PlayerAcc,"Level",0);
            INI_WriteInt(PlayerAcc,"Score",GetPlayerScore(playerid));
            INI_WriteInt(PlayerAcc,"Cash",GetPlayerMoney(playerid));
            INI_WriteInt(PlayerAcc,"Deaths",0);
            INI_WriteInt(PlayerAcc,"Kills",0);
            SendClientMessage(playerid,ORANGE,"You have just registered, Please use /login [password] to login!");
            PInfo[playerid][Regged] = 1;
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
        return 1;
    }
    return 1;
}
The problem is that, it doesn't create a file. No file gets created in my mAdmin/Users.
Reply
#2

File must be .ini not .txt

So this
pawn Code:
format(file,sizeof(file),"mAdmin/Users/%s.txt",n);
becomes
pawn Code:
format(file,sizeof(file),"mAdmin/Users/%s.ini",n);
Reply
#3

No, still the same
Reply
#4

Ah yeah, you need to close the file.

So
pawn Code:
//[...]
            INI_WriteInt(PlayerAcc,"Deaths",0);
            INI_WriteInt(PlayerAcc,"Kills",0);
            INI_Close( PlayerAcc ); //<-- this.
            SendClientMessage(playerid,ORANGE,"You have just registered, Please use /login [password] to login!");
            PInfo[playerid][Regged] = 1;
Reply
#5

Oh lol, forgot that. Okay testing.
EDIT: It works, thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)