Problem about scripting
#1

Hello guys

recently i was trying ti make a password system (nothing special)

here is the code

all the dialogs pop up normal , but when i put a password is not print me the messages and this is why i am posting

thanks in advance

Код:
#include <a_samp>





new menu;

public OnFilterScriptInit()
{
    menu = CreatePickup(371, 2, 1061.3151, 1285.5503, 10.8203, -1);
}

public OnPlayerPickUpPickup(playerid, pickupid)
{

		if(pickupid == menu)
        {
                ShowPlayerDialog(playerid, 2, 2, "Gate", "Open the gate", "Select", "Cancel");


        }
	return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == 2)
	{
		if(response)
    	{
    	    switch(listitem)
    	    {
    	        case 0: 
    	        {
    	            ShowPlayerDialog(playerid, 1, 3, "Gate", "Write the secret password", "Select", "Cancel");
				}
			}
		}
	}
	return 1;

	if(dialogid == 1)
	{
	    if(response)
	    {
	        if(!strcmp(inputtext, "1234", true))
			{
			SendClientMessage(playerid, -1, "Password accepted");
			}
			else
			{
            SendClientMessage(playerid, -1, "Password is wrong");
			}
		}
	}
	return 1;
}
Reply
#2

pawn Код:
}
    return 1;

    if(dialogid == 1)
Why you returned 1 in the center?
Reply
#3

shouldn't i?
Reply
#4

Quote:
Originally Posted by Goldac
Посмотреть сообщение
shouldn't i?
Nope, just return in the last.
Reply
#5

You should return 1, to prevent it checking things it's wouldn't equal if it has already found the only thing it can be. After all you can only see one dialog at once. You should return 1, one indentation before where you have done it like so:

pawn Код:
#include <a_samp>





new menu;

public OnFilterScriptInit()
{
    menu = CreatePickup(371, 2, 1061.3151, 1285.5503, 10.8203, -1);
}

public OnPlayerPickUpPickup(playerid, pickupid)
{

        if(pickupid == menu) return ShowPlayerDialog(playerid, 2, 2, "Gate", "Open the gate", "Select", "Cancel");
    return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 2)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    ShowPlayerDialog(playerid, 1, 3, "Gate", "Write the secret password", "Select", "Cancel");
                }
            }
        }
                            return 1;
    }
   

    if(dialogid == 1)
    {
        if(response)
        {
            if(!strcmp(inputtext, "1234", true))
            {
            SendClientMessage(playerid, -1, "Password accepted");
            }
            else
            {
            SendClientMessage(playerid, -1, "Password is wrong");
            }
        }
                            return 1;
    }
    return 1;
}
EDIT: Sorry for poor indentation of my alterations, I can't get them to fit right xD - Edited in the Comment box.
Reply
#6

IceBube one works thank you dude
Reply
#7

[Deleted]
Reply
#8

Quote:
Originally Posted by IceCube!
Посмотреть сообщение
You should return 1, to prevent it checking things it's wouldn't equal if it has already found the only thing it can be. After all you can only see one dialog at once. You should return 1, one indentation before where you have done it like so:

pawn Код:
#include <a_samp>





new menu;

public OnFilterScriptInit()
{
    menu = CreatePickup(371, 2, 1061.3151, 1285.5503, 10.8203, -1);
}

public OnPlayerPickUpPickup(playerid, pickupid)
{

        if(pickupid == menu) return ShowPlayerDialog(playerid, 2, 2, "Gate", "Open the gate", "Select", "Cancel");
    return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 2)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    ShowPlayerDialog(playerid, 1, 3, "Gate", "Write the secret password", "Select", "Cancel");
                }
            }
        }
                            return 1;
    }
   

    if(dialogid == 1)
    {
        if(response)
        {
            if(!strcmp(inputtext, "1234", true))
            {
            SendClientMessage(playerid, -1, "Password accepted");
            }
            else
            {
            SendClientMessage(playerid, -1, "Password is wrong");
            }
        }
                            return 1;
    }
    return 1;
}
EDIT: Sorry for poor indentation of my alterations, I can't get them to fit right xD - Edited in the Comment box.
the last return should be, return 0;

Or be removed completely.
Because (OnDialogResponse) will not be called unless a player response to a dialog.

and if it ever gets to that last return, something is wrong.
Reply
#9

Correct, however that isn't a change I made. I never even looked at it. I would have done, should he have said his code never worked.

However return 0, simply says "If you never found anything here, send the request to my filterscripts". I also return 1 on my GM as I don't have any filterscripts. By returning 0 it used to slow an incorrect dialog ID to respond nothing by about half a second. Instead if my code gets that far, I simply SendClientMessage(playerid, -1, "Incorrect Dialog ID- Contact an administrator");

There used to lots of incorrect ID's back when there was a way to fake a DIALOG response. Hence why a lot of servers, recheck if the player who got the response to that ID is still an admin. As you used to be able to ban people with an admin dialog in a lot of servers, due to the exploit.

Back on Topic however, back when the exploit was in use... it would take a greater amount of time to check 0 filterscripts than returning 1, and preventing the code going further.

https://sampwiki.blast.hk/wiki/OnDialogResponse

return 1; Sucessful, do nothing.

Return 0; Failiure, send this to my filterscripts.
Reply
#10

Quote:
Originally Posted by Goldac
Посмотреть сообщение
IceBube one works thank you dude
PHP код:
pawn Code:
#include <a_samp>
new menu;
public 
OnFilterScriptInit()
{
    
menu CreatePickup(37121061.31511285.550310.8203, -1);
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
        if(
pickupid == menu) return ShowPlayerDialog(playerid22"Gate""Open the gate""Select""Cancel");
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 2)
    {
        if(
response)
        {
            switch(
listitem)
            {
                case 
0
                {
                    
ShowPlayerDialog(playerid13"Gate""Write the secret password""Select""Cancel");
return 
1;
                }
            }
        }
                         
// not here   return 1;
    
}
    
    if(
dialogid == 1)
    {
        if(
response)
        {
            if(!
strcmp(inputtext"1234"true))
            {
            
SendClientMessage(playerid, -1"Password accepted");
return 
1;
            }
            else
            {
            
SendClientMessage(playerid, -1"Password is wrong");
            }
        }
                     
//       return 1;
    
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)