Fast help with inputtext[Repp +]
#1

hey guys
i was curious on how can i know if player has written the required thing
for example
Код:
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Test","Write\nHi down on box","Ok","Cancel");
So on the dialogid 2 how can i get if player has written "Hi" ??
Thanks for help in advance
Reply
#2

Use OnDialogResponse.

Click here for more information about OnDialogResponse.

You may use the parameter; inputtext (which is the field you are talking about). And to check if the player presses the left or right button, Use response (if response returns 1, It means the player pressed the left button, if it is null (zero) they pressed the right button)

Here's an example for you.

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(
strcmp(cmdtext"/mycommand"true) == 0)
    {
        
ShowPlayerDialog(playerid7DIALOG_STYLE_INPUTTEXT"Server Dialog""Type something in the field please""Left""Right");
        return 
1;
    }
    return 
0;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
7:
        {
            if(
response// Player presses the left button (it returned one)
            
{
                
SendClientMessage(playerid, -1"You have typed something on the field.");
                if(
strcmp(inputtext"hi"true) == 0// Checks if the inputtext returns the word; hi
                
{
                    
SendClientMessage(playerid, -1"Hi there!");
                }
            }
            else 
// Otherwise, they pressed the right one (null)
            
{
                
SendClientMessage(playerid, -1"You have decided to close the dialog.");
            }
        }
    }
    return 
1;

Reply
#3

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 2)
    {
        if(!
response// Wrote nothing
        
if(!strcmp("Hi"inputtext)) //have wrote Hi
        //Have wrote something else
    
}
 
    return 
0;

Reply
#4

Thank you.You gave me all i needed

Repped +1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)