DIALOG_STYLE_INPUT
#1

Hello everyone, I am trying to make a basic system with dialog style input, but I am failing to understand how to exactly use that, I am willing to make something similar to a clothes system, like "enter the clothes id below to get them", but all I am seeing in SAMP Wiki is that:

pawn Код:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
 
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) // If they clicked 'Cancel' or pressed esc
        {
            KickWithMessage(playerid, COLOR_RED, "You MUST login to play here. Please change your name.");
            //For info & code of this function please refer to the bottom of this article.
        }
        else // Pressed ENTER or clicked 'Login' button
        {
            if(CheckPassword(playerid, inputtext))
            {
                SendClientMessage(playerid, COLOR_RED, "You are now logged in!");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "LOGIN FAILED.");
 
                // Re-show the login dialog
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password:", "Login", "Cancel");
            }
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }
 
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
I don't really understand it, neither how to do the thing I want.
If anyone could help me taht would be great. Thanks in advance.
Reply
#2

When you use DIALOG_STYLE_INPUT, whatever you input (if you respond the dialog) will be in inputtext.

What's the problem with it?
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
When you use DIALOG_STYLE_INPUT, whatever you input (if you respond the dialog) will be in inputtext.

What's the problem with it?
I don't understand how to use that, it's the problem lol, could you give me a small example?
Thanks in advance.
Reply
#4

pawn Код:
// Somewhere:
ShowPlayerDialog(playerid, 789, DIALOG_STYLE_INPUT, "Skin", "Input the skin you want:", "Change!", "Cancel");

// OnDialogResponse: if the dialogid is 789 and response is 1.
if(IsNumeric(inputtext)) SetPlayerSkin(playerid, strval(inputtext));
You can change your skin via a dialog (input).
pawn Код:
stock IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
// Somewhere:
ShowPlayerDialog(playerid, 789, DIALOG_STYLE_INPUT, "Skin", "Input the skin you want:", "Change!", "Cancel");

// OnDialogResponse: if the dialogid is 789 and response is 1.
if(IsNumeric(inputtext)) SetPlayerSkin(playerid, strval(inputtext));
You can change your skin via a dialog (input).
pawn Код:
stock IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
Ow, well that made things a bit more clearer, lol thank you again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)