Saving problems
#1

Hello everyone. I have some saving problems.
When I register and login for the first time, nothing saves into my userfile.
When I relog and do things it does save.
How to fix it that when you log in for the very first time everything will be saved as well?

pawn Код:
if(dialogid == 1)
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        format(file, sizeof(file), SERVER_USER_FILE, Name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Welcome, your not registered, please fill in a password", "Register", "Leave");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",0);
        dini_IntSet(file, "Money",0);
        dini_IntSet(file, "Score",0);
        dini_IntSet(file, "Gender",0);
        dini_IntSet(file, "Age",0);
        SpawnPlayer(playerid);
        SetCameraBehindPlayer(playerid);
        format(String, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", Name, inputtext);
        SendClientMessage(playerid, COLOR_GREEN, String);
        gPlayerLogged[playerid] = 1;
        ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "_", "Welcome to Infinity Roleplay.\nBefore you can play and have fun with our players,\nwe have to ask you a few questions.", "Continue","");

    }
    if (dialogid == 2)
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        format(file, sizeof(file), SERVER_USER_FILE, Name);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "You're already registered, please login.", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp)
        {
            SendClientMessage(playerid, COLOR_RED, "Wrong password");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "You're already registered, please login.", "Login", "Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][pScore] = dini_Int(file, "Score");
            PlayerInfo[playerid][pCash] = dini_Int(file, "Money");
            PlayerInfo[playerid][pGender] = dini_Int(file, "Gender");
            PlayerInfo[playerid][pAge] = dini_Int(file, "Age");
            Save[playerid] = SetTimerEx("SaveStats",1000,true,"i",playerid);
            SendClientMessage(playerid,COLOR_GREEN, "Successfully logged in!");
            SpawnPlayer(playerid);
            SetCameraBehindPlayer(playerid);
        }

    }
Tell me if you need more.


Thanks in advance.
Reply
#2

Код:
if(dialogid == 1)
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        format(file, sizeof(file), SERVER_USER_FILE, Name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Welcome, your not registered, please fill in a password", "Register", "Leave");
        if(!fexist(file))
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",0);
        dini_IntSet(file, "Money",0);
        dini_IntSet(file, "Score",0);
        dini_IntSet(file, "Gender",0);
        dini_IntSet(file, "Age",0);
        SpawnPlayer(playerid);
        SetCameraBehindPlayer(playerid);
        format(String, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", Name, inputtext);
        SendClientMessage(playerid, COLOR_GREEN, String);
        gPlayerLogged[playerid] = 1;
        ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "_", "Welcome to Infinity Roleplay.\nBefore you can play and have fun with our players,\nwe have to ask you a few questions.", "Continue","");

    }
    if (dialogid == 2)
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        format(file, sizeof(file), SERVER_USER_FILE, Name);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "You're already registered, please login.", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp)
        {
            SendClientMessage(playerid, COLOR_RED, "Wrong password");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "You're already registered, please login.", "Login", "Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][pScore] = dini_Int(file, "Score");
            PlayerInfo[playerid][pCash] = dini_Int(file, "Money");
            PlayerInfo[playerid][pGender] = dini_Int(file, "Gender");
            PlayerInfo[playerid][pAge] = dini_Int(file, "Age");
            Save[playerid] = SetTimerEx("SaveStats",1000,true,"i",playerid);
            SendClientMessage(playerid,COLOR_GREEN, "Successfully logged in!");
            SpawnPlayer(playerid);
            SetCameraBehindPlayer(playerid);
        }

    }
try this I am not testing
Reply
#3

Nope. Didn't work.
The weird thing is that it worked before.
Reply
#4

Код:
if(dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, Name, sizeof(Name));
        format(file, sizeof(file), SERVER_USER_FILE, Name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Welcome, your not registered, please fill in a password", "Register", "Leave");
        if(!fexist(file))
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
        dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 0);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        dini_IntSet(file, "Gender",PlayerInfo[playerid][pGender] = 0);
        dini_IntSet(file, "Age", PlayerInfo[playerid][pAge] = 0);
        SpawnPlayer(playerid);
        SetCameraBehindPlayer(playerid);
        format(String, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", Name, inputtext);
        SendClientMessage(playerid, COLOR_GREEN, String);
        gPlayerLogged[playerid] = 1;
        ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "_", "Welcome to Infinity Roleplay.\nBefore you can play and have fun with our players,\nwe have to ask you a few questions.", "Continue","");

    }
    if (dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, Name, sizeof(Name));
        format(file, sizeof(file), SERVER_USER_FILE, Name);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "You're already registered, please login.", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp)
        {
            SendClientMessage(playerid, COLOR_RED, "Wrong password");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "You're already registered, please login.", "Login", "Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][pScore] = dini_Int(file, "Score");
            PlayerInfo[playerid][pCash] = dini_Int(file, "Money");
            PlayerInfo[playerid][pGender] = dini_Int(file, "Gender");
            PlayerInfo[playerid][pAge] = dini_Int(file, "Age");
            Save[playerid] = SetTimerEx("SaveStats",1000,true,"i",playerid);
            SendClientMessage(playerid,COLOR_GREEN, "Successfully logged in!");
            SpawnPlayer(playerid);
            SetCameraBehindPlayer(playerid);
        }

    }
pawn Код:
#define SERVER_USER_FILE "myserver/%s.ini"
you have #define?
OnPlayerDisconect
Код:
new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(gPlayerLogged[playerid] == 1)
    {
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][pAdminLevel]);
        dini_IntSet(file, "Gender", PlayerInfo[playerid][pGender]);
        dini_IntSet(file, "Age", PlayerInfo[playerid][pAge]);
    }
    gPlayerLogged[playerid] = 0;
I have edited
Reply
#5

Still doesn't work. No stats are setted in my file.
Reply
#6

I don't think it's the script because I redid the register system and it still doesn't set it into the file on the first login.
ANy other ideaS?
Reply
#7

Are you sure you made the folder "myserver" in your scriptfiles?
Reply
#8

Yes. The account is succesfully made. The password does save immediately. But nothing else does.
The rest only saves when I relog and then do things.
Reply
#9

pawn Код:
dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",Playerinfo[playerid][LEVEL]);
        dini_IntSet(file, "Money",GetPlayerMoney(playerid));
        dini_IntSet(file, "Score",GetPlayerScore(playerid));
        dini_IntSet(file, "Gender",Playerinfo[playerid][GENDER]);
        dini_IntSet(file, "Age",Playerinfo[playerid][AGE]);
Try this in the register dialog, and aswell change the "Playerinfo[playerid][something]" to your variables
Reply
#10

http://pastebin.com/v7QWER8T
My whole script. It is in.

It is so weird. I've tried many saving systems. Same problem on all.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)