Variable.
#1

Hi,

I have variable with Float type.

I want player can change this value, but how to make format player must enter: (ex in dialog).

10.50

And set that value what player input in dialog to my Float variable.
Reply
#2

Show your Variable please.
Reply
#3

Код:
new Float:Gas
Reply
#4

pawn Код:
ShowPlayerDialog(playerid, 45, DIALOG_STYLE_INPUT, "Caption", "Enter the amount:", "Change", "Cancel");
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 45)
    {
        if(response)
        {
            new Float:amount = strval(inputtext);
            Gas = amount;
        }
    }
    return 1;
}
Reply
#5

Thanks you, but i want to do you must add a don (.). Just like a float number, if you enter normal number then nothing happing, if player enter a float number, then that inputted float set to my float variable.
Reply
#6

That code that MouseBreaker posted should give a tag mismatch. Use floatstr instead. Or, if you want to enforce it: use sscanf.
Reply
#7

Thanks. But can i do this, you can only input in dialog only numbers and don? if you put other letters then nothing happin.
Reply
#8

You could use either sscanf to check if the input is a float, or probably better use strfind and check for a decimal.. And if no devimal is found just have it show the dialog ahain.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)