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=356504)



Dialog Response Help. - Snip3d - 03.07.2012

Hello, I have a dialog with id of 1 and the follow code works although I would like when it sends the message "please actually enter a password" for the menu to not dissapear, basically right now it spawns the user after sending the message.

I would like for the menu to only dissapear when strlen > 1.

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) { // Login Dialogue


		if(!response) {
  		SendClientMessage(playerid, 0xFFFFFFFF, "You clicked Quit");
		return Kick(playerid); //They clicked quit
}

        if (strlen(inputtext) >= 1) {
        SendClientMessage(playerid, 0xFFFFFFFF, "Strlen was > 1");
}
		else if (strlen(inputtext) <= 0) {
  		SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password");
   		return 0;
		}
	}

        return 0;
    }



Re: Dialog Response Help. - Dolby - 03.07.2012

pawn Код:
else if (strlen(inputtext) <= 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password"),ShowPlayerDialog(playerid...(rest of code).



Re: Dialog Response Help. - Snip3d - 03.07.2012

Quote:
Originally Posted by Gustavo_Araujo
Посмотреть сообщение
pawn Код:
else if (strlen(inputtext) <= 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password"),ShowPlayerDialog(playerid...(rest of code).
It still spawns the player after reshowing the dialogue.

EDIT: That's probably psuedo code but your code doesnt' compile if you didn't know.


Re: Dialog Response Help. - Dolby - 03.07.2012

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) // Login Dialogue
    {
        if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You clicked Quit"),Kick(playerid);
        if(strlen(inputtext) >= 1) return SendClientMessage(playerid, 0xFFFFFFFF, "Strlen was > 1");
        if(strlen(inputtext) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password"),SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password");
    }
    return 1;
}
Try.


Re: Dialog Response Help. - Snip3d - 04.07.2012

Quote:
Originally Posted by Gustavo_Araujo
Посмотреть сообщение
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) // Login Dialogue
    {
        if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You clicked Quit"),Kick(playerid);
        if(strlen(inputtext) >= 1) return SendClientMessage(playerid, 0xFFFFFFFF, "Strlen was > 1");
        if(strlen(inputtext) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password"),SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password");
    }
    return 1;
}
Try.
error 079: inconsistent return types (array & non-array)

EDIT: nevermind, testing it out.

EDIT: It still spawns the player after sending the "Please actually enter a password"

I show the dialogue onPlayerConnection if the name is found in a SQLite database table using the following code
Код:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "That account already exists!\n Please enter your password below:", "Login", "Quit");
		print(szOut);



Re: Dialog Response Help. - Dolby - 04.07.2012

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) // Login Dialogue
    {
        if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You clicked Quit"),Kick(playerid);
        if(strlen(inputtext) >= 1) return SendClientMessage(playerid, 0xFFFFFFFF, "Strlen was > 1");
        if(strlen(inputtext) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password"),SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password");
        return 1;
    }
    return 1;
}



Re: Dialog Response Help. - Snip3d - 04.07.2012

Quote:
Originally Posted by Gustavo_Araujo
Посмотреть сообщение
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) // Login Dialogue
    {
        if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You clicked Quit"),Kick(playerid);
        if(strlen(inputtext) >= 1) return SendClientMessage(playerid, 0xFFFFFFFF, "Strlen was > 1");
        if(strlen(inputtext) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password"),SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password");
        return 1;
    }
    return 1;
}
Still spawns the user.


Re: Dialog Response Help. - Dolby - 04.07.2012

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) // Login Dialogue
    {
        if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You clicked Quit"),Kick(playerid);
        if(strlen(inputtext) >= 1) return SendClientMessage(playerid, 0xFFFFFFFF, "Strlen was > 1");
        if(strlen(inputtext) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password"),ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "That account already exists!\n Please enter your password below:", "Login", "Quit");
    }
    return 1;
}



Re: Dialog Response Help. - Snip3d - 04.07.2012

Quote:
Originally Posted by Gustavo_Araujo
Посмотреть сообщение
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) // Login Dialogue
    {
        if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You clicked Quit"),Kick(playerid);
        if(strlen(inputtext) >= 1) return SendClientMessage(playerid, 0xFFFFFFFF, "Strlen was > 1");
        if(strlen(inputtext) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password"),ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "That account already exists!\n Please enter your password below:", "Login", "Quit");
    }
    return 1;
}
It's still spawning my character after showing the menu for the second time. here's my onplayerspawn but I doubt that it's the problem.

Код:
public OnPlayerSpawn(playerid)
{
	SetPlayerSkin(playerid, 125);
	SetPlayerInterior(playerid,0);
	TogglePlayerClock(playerid,0);
	SendClientMessage(playerid, COLOR_WHITE, "Spawned");
	return 1;
}



Re: Dialog Response Help. - Dolby - 04.07.2012

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN) // Login Dialogue
    {
        if(!response) return SendClientMessage(playerid, 0xFFFFFFFF, "You clicked Quit"),Kick(playerid);
        if(strlen(inputtext) >= 1) return Permission[playerid] = true,SpawnPlayer(playerid);
        if(strlen(inputtext) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Please actually enter a password"),ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "That account already exists!\n Please enter your password below:", "Login", "Quit");
    }
    return 1;
}
If bug,you need to use SetSpawnInfo before the SpawnPlayer(playerid);.
and in OnPlayerRequestSpawn,you need return 0.

#Edit:
put on top of Script:
pawn Код:
new bool:Permission[MAX_PLAYERS];
and in OnPlayerRequestSpawn:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(Permission[playerid]) return ? 1; : ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "That account already exists!\n Please enter your password below:", "Login", "Quit");
    return 0;
}