[Y_INI] SaveAccounts wont save and [Whirlpool] login accepts everything.
#1

Hello, my SaveAccounts is not saving when it should be, players stats just reset on disconnect when they shouldn't be.

pawn Код:
function SaveAccount(playerid)
{
    if(fexist(Path(playerid)))
    {
        new Float:hp;
        GetPlayerHealth(playerid, hp);
        new INI:file = INI_Open(Path(playerid));
        INI_SetTag(file,"PLAYER_DATA");
        INI_WriteInt(file,"Admin",PlayerInfo[playerid][Admin]);
        INI_WriteInt(file,"Donator",PlayerInfo[playerid][Donator]);
        INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
        INI_WriteInt(file,"Level",GetPlayerScore(playerid));
        INI_WriteInt(file,"Kills",PlayerInfo[playerid][Kills]);
        INI_WriteInt(file,"Deaths",PlayerInfo[playerid][Deaths]);
        INI_WriteInt(file,"Registered",PlayerInfo[playerid][Registered]);
        INI_WriteInt(file,"MaskOwned",PlayerInfo[playerid][MaskOwned]);
        INI_WriteInt(file,"Jailed",PlayerInfo[playerid][Jailed]);
        INI_WriteInt(file,"JailedTime",PlayerInfo[playerid][JailedTime]);
        INI_WriteInt(file,"Faction",PlayerInfo[playerid][Faction]);
        INI_WriteInt(file,"FactionRank",PlayerInfo[playerid][FactionRank]);
        INI_WriteInt(file,"BanAppealMod",PlayerInfo[playerid][BanAppealMod]);
        INI_WriteInt(file,"Faction",PlayerInfo[playerid][Faction]);
        INI_WriteFloat(file,"Health",hp);
        INI_WriteFloat(file,"Armour",PlayerInfo[playerid][Armour]);
        INI_WriteInt(file,"Banned",PlayerInfo[playerid][Banned]);
        INI_WriteInt(file,"Job",PlayerInfo[playerid][Job]);
        INI_WriteInt(file,"JobRank",PlayerInfo[playerid][JobRank]);
        INI_WriteInt(file,"Gun01",PlayerInfo[playerid][pGun01]);
        INI_WriteInt(file,"Gun02",PlayerInfo[playerid][pGun02]);
        INI_WriteInt(file,"Gun03",PlayerInfo[playerid][pGun03]);
        INI_WriteInt(file,"Gun04",PlayerInfo[playerid][pGun04]);
        INI_WriteInt(file,"Gun05",PlayerInfo[playerid][pGun05]);
        INI_WriteInt(file,"Gun06",PlayerInfo[playerid][pGun06]);
        INI_WriteInt(file,"Gun07",PlayerInfo[playerid][pGun07]);
        INI_WriteInt(file,"Gun08",PlayerInfo[playerid][pGun08]);
        INI_WriteInt(file,"Gun09",PlayerInfo[playerid][pGun09]);
        INI_WriteInt(file,"Gun09",PlayerInfo[playerid][pGun10]);
        INI_WriteInt(file,"Gun11",PlayerInfo[playerid][pGun11]);
        INI_WriteInt(file,"Ammo01",PlayerInfo[playerid][pAmmo01]);
        INI_WriteInt(file,"Ammo02",PlayerInfo[playerid][pAmmo02]);
        INI_WriteInt(file,"Ammo03",PlayerInfo[playerid][pAmmo03]);
        INI_WriteInt(file,"Ammo04",PlayerInfo[playerid][pAmmo04]);
        INI_WriteInt(file,"Ammo05",PlayerInfo[playerid][pAmmo05]);
        INI_WriteInt(file,"Ammo06",PlayerInfo[playerid][pAmmo06]);
        INI_WriteInt(file,"Ammo07",PlayerInfo[playerid][pAmmo07]);
        INI_WriteInt(file,"Ammo08",PlayerInfo[playerid][pAmmo08]);
        INI_WriteInt(file,"Ammo09",PlayerInfo[playerid][pAmmo09]);
        INI_WriteInt(file,"Ammo09",PlayerInfo[playerid][pAmmo10]);
        INI_WriteInt(file,"Ammo11",PlayerInfo[playerid][pAmmo11]);
        INI_Close(file);
        return 1;
    }
    return 1;
}
Error 2 [Whirlpool]:

This error, players can type anything and the server accepts it when it should only be accepting the real password

pawn Код:
if(dialogid == dregister)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
                return 1;
            }
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            new INI:file = INI_Open(Path(playerid));
            INI_SetTag(file,"PLAYER_DATA");
            INI_WriteString(file,"Password",hashpass);
            INI_WriteInt(file,"Admin",PlayerInfo[playerid][Admin] = 0);
            INI_WriteInt(file,"Donator",PlayerInfo[playerid][Donator] = 0);
            INI_WriteInt(file,"Money",PlayerInfo[playerid][Money] = 0);
            INI_WriteInt(file,"Level",PlayerInfo[playerid][Level] = 0);
            INI_WriteInt(file,"Kills",PlayerInfo[playerid][Kills] = 0);
            INI_WriteInt(file,"Deaths",PlayerInfo[playerid][Deaths] = 0);
            INI_WriteInt(file,"Registered",PlayerInfo[playerid][Registered] = 0);//
            INI_WriteInt(file,"MaskOwned",PlayerInfo[playerid][MaskOwned] = 0);
            INI_WriteInt(file,"Jailed",PlayerInfo[playerid][Jailed] = 0);
            INI_WriteInt(file,"JailedTime",PlayerInfo[playerid][JailedTime] = 0);
            INI_WriteInt(file,"Faction",PlayerInfo[playerid][Faction] = 0);
            INI_WriteInt(file,"FactionRank",PlayerInfo[playerid][FactionRank] = 0);
            INI_WriteInt(file,"BanAppealMod",PlayerInfo[playerid][BanAppealMod] = 0);
            INI_WriteInt(file,"Health", 100);
            INI_WriteInt(file,"Banned",PlayerInfo[playerid][Banned] = 0);
            INI_Close(file);
            ServerInfo[TotalRegisteredPlayers]++;
            ShowPlayerDialog(playerid,3,DIALOG_STYLE_MSGBOX,"Register","Thank you for registering at Los Santos Life Roleplay.\nWe hope you enjoy your stay here.\nBefore we commence, you will need to do an RP quiz.","Let's go!","Fuck this shite!");
            return 1;
        }
    }
else if(dialogid == dlogin)
    {
        #if defined DEBUG
        printf("[Debug] PlayerInfo[playerid][Registered] == %d; //dLogin", PlayerInfo[playerid][Registered]);
        #endif
        if(!response) return Kick(playerid);
        if(response)
        {
            #if defined DEBUG
            printf("[Debug] PlayerInfo[playerid][Registered] == %d; //if(response)", PlayerInfo[playerid][Registered]);
            #endif
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(strcmp(hashpass, PlayerInfo[playerid][Password], true) == 0)
            {
                #if defined DEBUG
                printf("[Debug] PlayerInfo[playerid][Registered] == %d;//if(!strcmp(hashpass,PlayerInfo[playerid][Password]))", PlayerInfo[playerid][Registered]);
                #endif
                INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
                #if defined DEBUG
                printf("[Debug] PlayerInfo[playerid][Registered] == %d;//INI_ParseFile", PlayerInfo[playerid][Registered]);
                #endif
                OnPlayerLogin(playerid);
            }
            else
            {
                new diastr[128];
                WrongPassword[playerid] += 1;
                format(diastr, 128, "Wrong Password! (%d/3)\nInsert your password to login to your account.", WrongPassword[playerid]);
                ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login",diastr,"Login","Quit");
                return 1;
            }
        }
    }

function loadaccount_user(playerid, name[], value[])
{
    #if defined DEBUG
    printf("[Debug] loadaccount_user(%d,%s,%s);", playerid,name,value);
    #endif
    INI_String("Password", PlayerInfo[playerid][Password],129);
    INI_Int("Admin",PlayerInfo[playerid][Admin]);
    INI_Int("Donator",PlayerInfo[playerid][Donator]);
    INI_Int("Money",PlayerInfo[playerid][Money]);
    INI_Int("Level",PlayerInfo[playerid][Level]);
    INI_Int("Kills",PlayerInfo[playerid][Kills]);
    INI_Int("Deaths",PlayerInfo[playerid][Deaths]);
    INI_Int("Registered",PlayerInfo[playerid][Registered]);
    INI_Int("MaskOwned",PlayerInfo[playerid][MaskOwned]);
    INI_Int("Jailed",PlayerInfo[playerid][Jailed]);
    INI_Int("JailedTime",PlayerInfo[playerid][JailedTime]);
    INI_Int("Faction",PlayerInfo[playerid][Faction]);
    INI_Int("FactionRank",PlayerInfo[playerid][FactionRank]);
    INI_Int("BanAppealMod",PlayerInfo[playerid][BanAppealMod]);
    INI_Int("Faction",PlayerInfo[playerid][Faction]);
    INI_Float("Health",PlayerInfo[playerid][Health]);
    INI_Float("Armour",PlayerInfo[playerid][Armour]);
    INI_Int("Banned",PlayerInfo[playerid][Banned]);
    INI_Int("Job",PlayerInfo[playerid][Job]);
    INI_Int("JobRank",PlayerInfo[playerid][JobRank]);
    INI_Int("Gun01",PlayerInfo[playerid][pGun01]);
    INI_Int("Gun02",PlayerInfo[playerid][pGun02]);
    INI_Int("Gun03",PlayerInfo[playerid][pGun03]);
    INI_Int("Gun04",PlayerInfo[playerid][pGun04]);
    INI_Int("Gun05",PlayerInfo[playerid][pGun05]);
    INI_Int("Gun06",PlayerInfo[playerid][pGun06]);
    INI_Int("Gun07",PlayerInfo[playerid][pGun07]);
    INI_Int("Gun08",PlayerInfo[playerid][pGun08]);
    INI_Int("Gun09",PlayerInfo[playerid][pGun09]);
    INI_Int("Gun10",PlayerInfo[playerid][pGun10]);
    INI_Int("Gun11",PlayerInfo[playerid][pGun11]);
    INI_Int("Ammo01",PlayerInfo[playerid][pAmmo01]);
    INI_Int("Ammo02",PlayerInfo[playerid][pAmmo02]);
    INI_Int("Ammo03",PlayerInfo[playerid][pAmmo03]);
    INI_Int("Ammo04",PlayerInfo[playerid][pAmmo04]);
    INI_Int("Ammo05",PlayerInfo[playerid][pAmmo05]);
    INI_Int("Ammo06",PlayerInfo[playerid][pAmmo06]);
    INI_Int("Ammo07",PlayerInfo[playerid][pAmmo07]);
    INI_Int("Ammo08",PlayerInfo[playerid][pAmmo08]);
    INI_Int("Ammo09",PlayerInfo[playerid][pAmmo09]);
    INI_Int("Ammo10",PlayerInfo[playerid][pAmmo10]);
    INI_Int("Ammo11",PlayerInfo[playerid][pAmmo11]);
    #if defined DEBUG
    printf("[Debug] loadaccount_user(%d,%s,%s); ended", playerid,name,value);
    #endif
    return 1;
}

public OnPlayerConnect(playerid)
{
    //...
    if(fexist(Path(playerid)))
    {
        #if defined DEBUG
        printf("[Debug] PlayerInfo[playerid][Registered] == %d;", PlayerInfo[playerid][Registered]);
        #endif
        INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
        #if defined DEBUG
        printf("[Debug] INI_ParseFile(Path(playerid),\"loadaccount_%s\", .bExtra = true, .extra = playerid);", GetName(playerid));
        printf("[Debug] PlayerInfo[playerid][Registered] == %d;", PlayerInfo[playerid][Registered]);
        #endif
        ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
    }
    else
    {
        ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
        return 1;
    }
    return 1;
}
Reply
#2

Show me how you load your password.
Reply
#3

I sent my whole Registration and Login system. on the first page.
Reply
#4

But it is not completed yet. It should load the data you parse.
Reply
#5

Quote:
Originally Posted by Dwane
Посмотреть сообщение
But it is not completed yet. It should load the data you parse.
Could you by any chance show me where I could improve?
Reply
#6

Learn to debug properly. Printing integers won't help much in this situation. Print the player's password after INI_ParseFile
Reply
#7

Just read the tutorials about how to use y_ini with Whirlpool, it will help you a lot!
Reply
#8

About the 2nd error: id you're testing it on the localhost, it's normally to happen like this. Try it on a hosted server.
Reply
#9

Quote:
Originally Posted by DiGiTaL_AnGeL
Посмотреть сообщение
About the 2nd error: id you're testing it on the localhost, it's normally to happen like this. Try it on a hosted server.
I tried it on my public server, it still allows any password to be entered.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)