SA-MP Forums Archive
How to use inputtext? (Dialogs.) - 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)
+--- Thread: How to use inputtext? (Dialogs.) (/showthread.php?tid=483100)



How to use inputtext? (Dialogs.) - rangerxxll - 24.12.2013

I'm just trying to make a simple money dialog. A player enters the amount they want, and they get it. But this isn't working. Could I please get some help? Thanks. (I'm returning from a break of sa-mp, so I'm a bit rusty.)

pawn Код:
if(listitem == 4)
        {
            ShowPlayerDialog(playerid, mamount,DIALOG_STYLE_INPUT, "Money", "How much?", "OK","Cancel");
            return 1;
        }

    }
    if(dialogid == mamount)
    {
        GivePlayerMoney(playerid, inputtext[128]);
        return 1;
    }



Re: How to use inputtext? (Dialogs.) - Patrick - 24.12.2013

This code should work, you don't need to put 128 string cell because, it's already done on the callback as you have noticed.

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]/* the [] */)
pawn Код:
new amount = strval( inputtext );
if(listitem == 4)
{
    return ShowPlayerDialog(playerid, mamount,DIALOG_STYLE_INPUT, "Money", "How much?", "OK","Cancel");
}
if(dialogid == mamount)
{
    return GivePlayerMoney(playerid, amount);
}
EDIT: strval is used to convert string(inputtext) into integer


Re: How to use inputtext? (Dialogs.) - CutX - 24.12.2013

GivePlayerMoney(playerid, strval(inputtext));


Re: How to use inputtext? (Dialogs.) - rangerxxll - 24.12.2013

Just to clarify. strval = String Value? I like to learn things while I'm seeking help, nothing personal. Thank you.


Re: How to use inputtext? (Dialogs.) - CutX - 24.12.2013

wiki says
Quote:
Originally Posted by SA-MP Wiki
strval can be used to convert a string to an integer.
so, ya

the opposite would be Valstr
Quote:
Originally Posted by SA-MP Wiki
Convert an integer into a string.



Re: How to use inputtext? (Dialogs.) - Patrick - 24.12.2013

Quote:
Originally Posted by rangerxxll
Посмотреть сообщение
Just to clarify. strval = String Value? I like to learn things while I'm seeking help, nothing personal. Thank you.
Basically yes.

pawn Код:
new amount[4] = "hii"; // 911 = 3 character + 1 extra
new converamount = strval(amount); //strval will convert the string into integer ( in simple words letters into numbers )
EDIT: Late but added an example.


Re: How to use inputtext? (Dialogs.) - rangerxxll - 24.12.2013

Thank you everyone, testing the code now.

EDIT: Works. Thank you.