Problem with loading dialog list items from file
#1

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)
Reply
#2

bump
Reply
#3

bump
Reply
#4

bump
Reply
#5

bump
Reply
#6

Do you get and warning / errors?
Reply
#7

Nope.
Reply
#8

Bump ... eh...

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

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.
Reply
#10

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


Forum Jump:


Users browsing this thread: 2 Guest(s)