How to use inputtext? (Dialogs.)
#1

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;
    }
Reply
#2

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
Reply
#3

GivePlayerMoney(playerid, strval(inputtext));
Reply
#4

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

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

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

Thank you everyone, testing the code now.

EDIT: Works. Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)