SA-MP Forums Archive
Dialog response help - 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: Dialog response help (/showthread.php?tid=353600)



Dialog response help - PaulDinam - 23.06.2012

I made a dialog that you need to insert your age but after i put my age i shows ok so you are 0 years old.
how do i make a good dialog response for the user input?


Код:
	
if(dialogid == 959)
	{
		if(response)
		{
		    new text[256];
		    new age = strvalEx(text);
		    PlayerInfo[playerid][pAge] = age;
			format(string, sizeof(string), "Ok, so you are %d year old.",PlayerInfo[playerid][pAge]);
			SendClientMessage(playerid, COLOR_YELLOW2, string);
   			RegistrationStep[playerid] = 3;
			SendClientMessage(playerid, COLOR_NICEBLUE, "What is your Origin? (Type in: USA, Europe, Asia or Africa)");
		}
		else{}
		return 1;
	}



Re: Dialog response help - Kindred - 23.06.2012

Show us strvalEx, it's obviously a custom function or something.

Otherwise, changing it to strval should work. (not completely sure)


Re: Dialog response help - PaulDinam - 23.06.2012

Код:
stock strvalEx( const string[] ) 
{
	// written by mabako in less than a minute :X
	if( strlen( string ) >= 50 ) return 0; // It will just return 0 if the string is too long
	return strval(string);
}



Re: Dialog response help - Kindred - 23.06.2012

Could it be because you randomly created a text variable, and you do not do anything to it?

pawn Код:
new text[256];
new age = strvalEx(text);
Since this is a dialog, shouldn't it just be inputtext?


Re: Dialog response help - PaulDinam - 23.06.2012

Код:
	if(dialogid == 959)
	{
		if(response)
		{
		if(!strlen(inputtext)) //If they didn't enter any password
            {// then we will tell to them to enter the password to register
			    ShowPlayerDialog(playerid, 959, DIALOG_STYLE_INPUT, "What is your Age? (16-80)", "Insert your age", "OK", "");
                return 1;
            }
			new age = strvalEx(text);
			if(age < 16 || age > 80)
			{
			    SendClientMessage(playerid, COLOR_NICEBLUE, "What is your Age? (16-80)");
			    return 0;
			}
			PlayerInfo[playerid][pAge] = age;
			format(string, sizeof(string), "Ok, so you are %d year old.",PlayerInfo[playerid][pAge]);
			SendClientMessage(playerid, COLOR_YELLOW2, string);
			RegistrationStep[playerid] = 3;
			SendClientMessage(playerid, COLOR_NICEBLUE, "What is your Origin? (Type in: USA, Europe, Asia or Africa)");
		}
		else{}
		return 1;
	}
now i added if he doesn't write age the dialog will popup again.
now it says after compiling no symbol "text"
but before the dialogrespone the "text" exist. here
Код:
		else if(RegistrationStep[playerid] == 2)
	    {
			 new age = strvalEx(text);
			if(age < 16 || age > 80)
			{
			    SendClientMessage(playerid, COLOR_NICEBLUE, "What is your Age? (16-80)");
			    return 0;
			}
			PlayerInfo[playerid][pAge] = age;
			format(string, sizeof(string), "Ok, so you are %d year old.",PlayerInfo[playerid][pAge]);
			SendClientMessage(playerid, COLOR_YELLOW2, string);
			RegistrationStep[playerid] = 3;
			SendClientMessage(playerid, COLOR_NICEBLUE, "What is your Origin? (Type in: USA, Europe, Asia or Africa)");
			return 0;
	    }



Re: Dialog response help - Kindred - 23.06.2012

Like I said, change text to inputtext. You're still using a random text variable.


Re: Dialog response help - PaulDinam - 23.06.2012

Oh, thanks buddy.
Helped me.