SA-MP Forums Archive
Problem with loading dialog list items from file - 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: Problem with loading dialog list items from file (/showthread.php?tid=259850)



Problem with loading dialog list items from file - woaha - 06.06.2011

I am working for while this function, wich loads dialog list contents from file, however I didin't never find a way to do so, so I tryed DLDiag from https://sampforum.blast.hk/showthread.php?tid=190068. But now I can't even see dialog!

First, I loaded contents of file with this:
pawn Code:
#define FILESTRING_SIZE 276 // Filestring size
#define MAX_QUESTIONS 11 // Max Questions

//----------------------------------------------------------
// Question enum
//----------------------------------------------------------
enum questione
{
    qid,
    question[255],
    answer[255]
};

new questions[MAX_QUESTIONS][questione];

stock LoadCarSchoolQuestions()
{
    new filestring[FILESTRING_SIZE];
    format(pfile, sizeof(pfile), "%s/%s/%s%s", CORE_FOLDER, QUESTION_FOLDER, SUB_FILE_questions, CORE_FOLDERS_FILESYSTEM);
    new SplitDiv[2][MAX_QUESTIONS];
    new File: file = fopen(pfile, io_read);
        for(new qide = 0; qide < MAX_QUESTIONS; qide++)
        {
            fread(file, filestring);
            split(filestring, SplitDiv, ',');
            questions[qide][qid] = strval(SplitDiv[0]);
            strmid(questions[qide][question], SplitDiv[1], 0, strlen(SplitDiv[1]), 255);
        }
        fclose(file);
    return 1;
}
Yeah they loaded fine, tested it.

Now I am creating dialog with that DLDiag.

pawn Code:
stock CreateCarSchoolDialog(playerid)
{
        new str[255];
        for(new qide = 0; qide < MAX_QUESTIONS; qide++)
        {
            format(str, sizeof(str), "%i. %s", questions[qide][question], questions[qide][qid]);
            AddDListItem(playerid, str, questions[qide][qid]);
        }
        ShowPlayerDList(playerid, 9053+1742,  "Car school Questions", "Choose", "Exit");
    return 1;
}
(format should be look like this ID. QUESTION)

And now I am callin' this CreateCarSchoolDialog(playerid) from:
pawn Code:
// Lisence driving...
    if(dialogid == 1555+1122)
    {
        if(response)
        {
            if(listitem == 0)
            {
            if (ppInfo[playerid][driving] == 1)
            {
            ....
            }
            if (ppInfo[playerid][driving] == 0)
            {
            ...
            CreateCarSchoolDialog(playerid); // THIS WONT SHOW DIALOG????
            }
            }
            if(listitem == 1)
            {
            if (ppInfo[playerid][driving] == 0)
            {
            ...
            }
            if (ppInfo[playerid][driving] == 1)
            {
            ...
            }
            }
        }
        return 1;
    }
Others listitems works fine. But this "CreateCarSchoolDialog(playerid);" one just doesn't.
So what can be problem? Or is there simpler way to load dialog list items from file?

----
Yeah and question file should look like this:
1,What is general speed limit?
2,What is....

ID,QUESTION

BTW I am 100% sure that if (ppInfo[playerid][driving] == 0) works, so that is not the problem! (Tested it)


Re: Problem with loading dialog list items from file - woaha - 07.06.2011

bump


Re: Problem with loading dialog list items from file - woaha - 08.06.2011

bump


Re: Problem with loading dialog list items from file - woaha - 09.06.2011

bump


Re: Problem with loading dialog list items from file - woaha - 10.06.2011

bump


Re: Problem with loading dialog list items from file - PGTips - 10.06.2011

Do you get and warning / errors?


Re: Problem with loading dialog list items from file - woaha - 10.06.2011

Nope.


Re: Problem with loading dialog list items from file - roschti - 10.06.2011

Bump ... eh...

pawn Code:
format(str, sizeof(str), "%i. %s", questions[qide][question], questions[qide][qid]);
You have to switch the last 2 parameters.


Re: Problem with loading dialog list items from file - woaha - 11.06.2011

Yeah, now my code looks like this:
pawn Code:
stock CreateCarSchoolDialog(playerid)
{
        new str[255];
        ShowPlayerDList(playerid, -1,  "Car school Questions", "Choose", "Exit");
        for(new qide = 0; qide < MAX_QUESTIONS; qide++)
        {
            format(str, sizeof(str), "%i. %s", questions[qide][qid], questions[qide][question]);
            AddDListItem(playerid, str, questions[qide][qid]);
        }
        ShowPlayerDList(playerid, 9053+1742,  "Car school Questions", "Choose", "Exit");
    return 1;
}
I have also command for it (using zcmd)
pawn Code:
COMMAND:test1(playerid, params[])
    {
    CreateCarSchoolDialog(playerid);
    return 1;
    }
However, now it says SERVER: Uknown command. Why?

On compile, there is no errors/warnings at all.


Re: Problem with loading dialog list items from file - woaha - 12.06.2011

bump, I need really now somekind way to load dialog list items from file, when format is somelike this id,question