SA-MP Forums Archive
saving into file... help please. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: saving into file... help please. (/showthread.php?tid=158002)



saving into file... help please. - introzen - 08.07.2010

Hey... I've made this..:

pawn Код:
if(dialogid == BANKCREATE)
    {
        if(response)
        {
            if(!IsNumeric(inputtext[0])) return ShowPlayerDialog(playerid,BANKCREATE+2,DIALOG_STYLE_MSGBOX,"San Fierro Bank System","Invalid Account ID. Please use a 10-digit Account","Back","Cancel");
            new BankID = strval(inputtext[0]);
            new length = strlen(inputtext[0]);
            for(new b=0; b<MAX_BANKS; b++)
            {
                if(BankInfo[b][bBankID] == BankID) return ShowPlayerDialog(playerid,BANKCREATE+1,DIALOG_STYLE_MSGBOX,"San Fierro Bank System","That bank account is already taken","Back","Cancel");
            }
            if(length != 10) return ShowPlayerDialog(playerid,BANKCREATE+2,DIALOG_STYLE_MSGBOX,"San Fierro Bank System","Invalid Account ID. Please use a 10-digit Account","Back","Cancel");
            dini_IntSet(Playerfile(playerid),"BankID",BankID);
            PlayerInfo[playerid][pBankID] = BankID;
            BankInfo[BankID][bBankID] = BankID;
            dini_Create(Bankfile(BankID));
            dini_IntSet(Bankfile(BankID),"BankID",BankID);
            ShowPlayerDialog(playerid,BANKCREATE+3,DIALOG_STYLE_INPUT,"San Fierro Bank System","Type in a 4-digit password for your account:","Select","Cancel");
        }
        return 1;
    }
but for some reason.. it doesn't save the file... help please


Re: saving into file... help please. - CAR - 08.07.2010

Show us the function Bankfile please


Re: saving into file... help please. - introzen - 08.07.2010

pawn Код:
stock Bankfile(bankid)
{
    new file[256];
    format(file,sizeof(file),"CLRP/Banks/%d", bankid);
    return file;
}



Re: saving into file... help please. - introzen - 08.07.2010

bump help please


Re: saving into file... help please. - introzen - 09.07.2010

bump again.......


Re: saving into file... help please. - Hiddos - 09.07.2010

Is the "Banks" directory actually created (The directory: /scriptfiles/CLRP/Banks/)


Re: saving into file... help please. - introzen - 09.07.2010

yes.. I actually managed to save it once but then i changed some in the code...

But as it is now, the code should work. shouldn't it?


Re: saving into file... help please. - introzen - 09.07.2010

I read this on wiki:

"sscanf has inbuilt protection against the long number crash (where very long numbers can crash strval)."

Could it be that my strval can't handle the 10-digit number?


Re: saving into file... help please. - introzen - 09.07.2010

Now I've managed the saving... but it saves as wrong filename...

Example: 9505162470 saves as 915227878


Re: saving into file... help please. - CAR - 09.07.2010

pawn Код:
stock Bankfile(bankid)
{
    new file[256];
    format(file,sizeof(file),"CLRP/Banks/%d.txt", bankid);
    return file;
}
should work... but it must already work