Creating an interactive Dialog
#1

I've been attempting to create an interactive List dialog that allows me to get information from a command (question) and places it in the list so admins can see it later on, but I can't seem to find any guides on how to make it work, I would appreciate the help from someone and I am willing to give the person Rep+.

For example:

"/question [question] - the command I want it to register"
"/question This is a test - the question gets asked"
"The file is then moved into a list dialog"
"admin then can use /questions to see the recently added questions"
Reply
#2

pawn Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>

new gLastQuestion,gQuestions[100][128];

CMD:question(playerid, params[])
{
    new question[100], name[24], msg[128];
    if (sscanf(params, "s[100]", question)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: /question [question]");
    if (strlen(question) < 3 || strlen(question) > 100) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Question must be between 3 and 100 characters long.");
   
    GetPlayerName(playerid, name, sizeof(name));
    format(msg, sizeof(msg), "[QUESTION] {FFFFFF}%s (%d): %s", name, playerid, question);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerAdmin(i)) // Change this to your admin variable
        {
            SendClientMessage(i, 0xFF0000FF, msg);
        }
    }
   
    format(gQuestions[gLastQuestion], 128, msg[19]);
    gLastQuestion ++;
   
    SendClientMessage(playerid, -1, "Your question has been sent to online administrators.");
    return 1;
}

CMD:questions(playerid, params[])
{
    if (!IsPlayerAdmin(playerid)) return 0;
    if (!strlen(gQuestions[0])) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: No questions have been asked.");
    new msg[1024], last = (gLastQuestion > 10 ? (gLastQuestion - 10) : (0));
   
    for(new i = last; i < gLastQuestion; i++)
    {
        format(msg, sizeof(msg), "%s%s\n", msg, gQuestions[i]);
    }
   
    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "Recent Questions", msg, "Close", "");
    return 1;
}
Tested and working. /questions displays the 10 most reccent questions.
Reply
#3

Use a MySQL Table.
Reply
#4

Unfortunately, I'm not using zcmd I'm using the default, so this doesn't correspond with my script :/ any chance you could convert it?

Quote:
Originally Posted by iFarbod
Посмотреть сообщение
Use a MySQL Table.
I wouldn't even know where to start with MYSQL, I'm just beginning with scripting, otherwise I would gladly go with that
Reply
#5

What would you need it to be converted to?

The main point is that you have a 2d array and maybe an enum which will actually tell you what you are holding: Questions[NUMBER_OF_QUESTIONS_POSSIBLE][questionData]

This in return would allow you to populate your list dialog when required.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)