Variable. - 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: Variable. (
/showthread.php?tid=389847)
Variable. -
budelis - 03.11.2012
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.
Re: Variable. -
HyDrAtIc - 03.11.2012
Show your Variable please.
Re: Variable. -
budelis - 03.11.2012
AW: Variable. -
Skimmer - 03.11.2012
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;
}
Re: Variable. -
budelis - 03.11.2012
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.
Re: Variable. -
Vince - 03.11.2012
That code that MouseBreaker posted should give a tag mismatch. Use floatstr instead. Or, if you want to enforce it: use sscanf.
Re: Variable. -
budelis - 04.11.2012
Thanks. But can i do this, you can only input in dialog only numbers and don? if you put other letters then nothing happin.
Re: Variable. -
PrawkC - 04.11.2012
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.