Needing some help with Dini
#1

I was trying to convert the login/register system to Dini, but im getting a few errors.

OnPlayerLogin:
pawn Код:
public OnPlayerLogin(playerid, password[])
{
    new tmp2[64];
    new string2[256];
    new playername2[MAX_PLAYER_NAME];
    new playernamesplit[3][MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername2, sizeof(playername2));
    split(playername2, playernamesplit, '_');

    format(string2, sizeof(string2), "users/%s.ini", playername2);
    if(dini_Exists(string2))
    {
        [ ... ]
        PlayerInfo[playerid][pMarried] = dini_Int(string2, "Married");
        PlayerInfo[playerid][pMarriedTo] = dini_Get(string2, "MarriedTo");
        PlayerInfo[playerid][pNote1] = dini_Get(string2, "Note1");
        PlayerInfo[playerid][pNote1s] = dini_Int(string2, "Note1s");
        PlayerInfo[playerid][pNote2] = dini_Get(string2, "Note2");
        PlayerInfo[playerid][pNote2s] = dini_Int(string2, "Note2s");
        PlayerInfo[playerid][pNote3] = dini_Get(string2, "Note3");
        PlayerInfo[playerid][pNote3s] = dini_Int(string2, "Note3s");
        PlayerInfo[playerid][pNote4] = dini_Get(string2, "Note4");
        PlayerInfo[playerid][pNote4s] = dini_Int(string2, "Note4s");
        PlayerInfo[playerid][pNote5] = dini_Get(string2, "Note5");
        PlayerInfo[playerid][pNote5s] = dini_Int(string2, "Note5s");
        [ ... ]
    }
    [ ... ]
Enum:
pawn Код:
enum pInfo
{
    [ ... ]
    pMarried,
    pMarriedTo[128],
    pNote1[128],
    pNote1s,
    pNote2[128],
    pNote2s,
    pNote3[128],
    pNote3s,
    pNote4[128],
    pNote4s,
    pNote5[128],
    pNote5s,
    [ ... ]
};
Errors:
Код:
C:\Documents and Settings\Administrator\Desktop\ \gamemodes\BBC1.pwn(10766) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\Administrator\Desktop\ \gamemodes\BBC1.pwn(10767) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\Administrator\Desktop\ \gamemodes\BBC1.pwn(10769) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\Administrator\Desktop\ \gamemodes\BBC1.pwn(10771) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\Administrator\Desktop\ \gamemodes\BBC1.pwn(10773) : error 047: array sizes do not match, or destination array is too small
C:\Documents and Settings\Administrator\Desktop\ \gamemodes\BBC1.pwn(10775) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#2

Whats this? [ ... ]
Reply
#3

Quote:
Originally Posted by Chuck_Taylor
Whats this? [ ... ]
The rest of the code which isn't needed for me to show it to you
Reply
#4

anyone?
Reply
#5

Telling us the line numbers could help us to identify where the problem is
Reply
#6

Looks to me like you have too many characters in one string variable. Try making more?
Reply
#7

Quote:
Originally Posted by WrathOfGenesis
Telling us the line numbers could help us to identify where the problem is
Well the error lines are under OnPlayerLogin:
pawn Код:
PlayerInfo[playerid][pMarriedTo] = dini_Get(string2, "MarriedTo"); //error line
        PlayerInfo[playerid][pNote1] = dini_Get(string2, "Note1"); //error line
        PlayerInfo[playerid][pNote1s] = dini_Int(string2, "Note1s");
        PlayerInfo[playerid][pNote2] = dini_Get(string2, "Note2"); //error line
        PlayerInfo[playerid][pNote2s] = dini_Int(string2, "Note2s");
        PlayerInfo[playerid][pNote3] = dini_Get(string2, "Note3"); //error line
        PlayerInfo[playerid][pNote3s] = dini_Int(string2, "Note3s");
        PlayerInfo[playerid][pNote4] = dini_Get(string2, "Note4"); //error line
        PlayerInfo[playerid][pNote4s] = dini_Int(string2, "Note4s");
        PlayerInfo[playerid][pNote5] = dini_Get(string2, "Note5"); //error line
        PlayerInfo[playerid][pNote5s] = dini_Int(string2, "Note5s");
Quote:
Originally Posted by Seif_
Use strmid when using dini_Get with the string variables.
I dont quite get it Seif, I looked the code for dini_Get and there is strmid function already,
bother to explain further more, Im new to Dini, but still understand it allitle.
pawn Код:
stock dini_Get(filename[],key[]) {
    new tmpres[DINI_MAX_STRING];
   
    new key_length = strlen(key);
    if (key_length==0 || key_length+2>DINI_MAX_STRING) return tmpres;
   
    new File:fohnd;
    fohnd=fopen(filename,io_read);
    if (!fohnd) return tmpres;
   
    while (fread(fohnd,tmpres)) {
        if (
            tmpres[key_length]=='='
            && !strcmp(tmpres, key, true, key_length)  
        ) {
            /* We've got what we need */
            DINI_StripNewLine(tmpres);
            strmid(tmpres, tmpres, key_length + 1, strlen(tmpres), DINI_MAX_STRING); // STRMID FUNC
Reply
#8

I think i know the problem, when you use dini_Get the variable to store it in should always have a size of 256
Reply
#9

Ah, i have decided not to use Dini anymore, because it reads like one line, and closes the file
And like that for every variable stored in userfile, so that's not good, so I've decided not to use it.
Moderators can delete/close this thread.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)