SA-MP Forums Archive
Problem with dialog.. - 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: Problem with dialog.. (/showthread.php?tid=546396)



Problem with dialog.. - FailerZ - 15.11.2014

So...I was trying to limit the strval(inputtext) between 0 and 299 but when i type 0 in the input dialog it will return the dialog again like if he didnt accept it [I mean didnt accept that input so he shows me the dialog again]
So, anyone able to help me? what shall i do to make it accept the 0 input?
pawn Код:
case DIALOG_SKIN:
        {
            if(response) //Continue
            {
                if(!strval(inputtext)) return ShowPlayerDialog(playerid, DIALOG_SKIN, DIALOG_STYLE_INPUT, ""COL_WHITE"Skin", ""COL_WHITE"Input the Skin ID below:\n"COL_YELLOW"*Min: 0 || Max: 299*", "Change", "Back");
                if(strval(inputtext) > 299 || strval(inputtext) < 0) return ShowPlayerDialog(playerid, DIALOG_SKIN, DIALOG_STYLE_INPUT, ""COL_WHITE"Skin", ""COL_WHITE"Input the Skin ID below:\n"COL_YELLOW"*Min: 0 || Max: 299*", "Change", "Back");
                SetPlayerSkin(playerid, strval(inputtext));
                new string[128];
                format(string, sizeof(string), ""TAG" Changed your Skin "COL_WHITE"[ID: %d]", strval(inputtext));
                SCM(playerid, -1, string);
                ShowPlayerDialog(playerid, DIALOG_SPAWN, DIALOG_STYLE_LIST, ""COL_GREEN"Spawn Menu", sstr, "Select", "Back");
            }
            else ShowPlayerDialog(playerid, DIALOG_SPAWN, DIALOG_STYLE_LIST, ""COL_GREEN"Spawn Menu", sstr, "Select", "Back"); //Back



Re: Problem with dialog.. - DavidBilla - 15.11.2014

I recommend using sscanf, because strval returns 0 both when the string is not an integer and also when the value of the string is zero which is causing the trouble in your case


Re: Problem with dialog.. - FailerZ - 15.11.2014

Quote:
Originally Posted by DavidBilla
Посмотреть сообщение
I recommend using sscanf, because strval returns 0 both when the string is not an integer and also when the value of the string is zero which is causing the trouble in your case
Hmmm...So the only way is using sscanf? and if yes can u give me an example how to use it here? am kind of not really good scripter :/


Re: Problem with dialog.. - DavidBilla - 15.11.2014

pawn Код:
case DIALOG_SKIN:
        {
            if(response) //Continue
            {
                new skinid;
                if(sscanf(inputtext,"d",skinid)) return ShowPlayerDialog(playerid, DIALOG_SKIN, DIALOG_STYLE_INPUT, ""COL_WHITE"Skin", ""COL_WHITE"Input the Skin ID below:\n"COL_YELLOW"*Min: 0 || Max: 299*", "Change", "Back");
                if(skinid > 299 || skinid < 0) return ShowPlayerDialog(playerid, DIALOG_SKIN, DIALOG_STYLE_INPUT, ""COL_WHITE"Skin", ""COL_WHITE"Input the Skin ID below:\n"COL_YELLOW"*Min: 0 || Max: 299*", "Change", "Back");
                SetPlayerSkin(playerid, skinid);
                new string[128];
                format(string, sizeof(string), ""TAG" Changed your Skin "COL_WHITE"[ID: %d]", skinid);
                SCM(playerid, -1, string);
                ShowPlayerDialog(playerid, DIALOG_SPAWN, DIALOG_STYLE_LIST, ""COL_GREEN"Spawn Menu", sstr, "Select", "Back");
            }
            else ShowPlayerDialog(playerid, DIALOG_SPAWN, DIALOG_STYLE_LIST, ""COL_GREEN"Spawn Menu", sstr, "Select", "Back"); //Back



Re: Problem with dialog.. - FailerZ - 15.11.2014

Thank you very much really appreciate it +rep for you