OnPlayerKeyStateChange + dialog bug
#1

When you try to detect when a player presses the Enter key and display them a dialog after that (inside OnPlayerKeyStateChange) - OnDialogResponse will be automatically called with "response" parameter set to true.

Here's the video which describes what I mean: http://beta.xfire.com/video/5db67c

Code for testing:

pawn Code:
#include <a_samp>

main( ) { }

public OnGameModeInit()
{
    AddPlayerClass(0,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1);
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (newkeys & KEY_SECONDARY_ATTACK)
    {
        SendClientMessage(playerid, -1, "Enter pressed");
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Test", "Text\nText\nText\nText", "OK", "");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return SendClientMessage(playerid, -1, "OnDialogResponse called");
}
Reply
#2

Confirmed
Reply
#3

This is not a bug, it's intentional. If you open a dialog and press the "Enter" key, it will have the same effect as if you would press the first button. Same goes for Esc, it will close the dialog and have the same effect as the second button.

Try this instead:
Code:
if (!(newkeys & KEY_SECONDARY_ATTACK) && oldkeys & KEY_SECONDARY_ATTACK)
This will open the dialog after the player released his finger from the Enter key. If that still doesn't work, try adding a small timer delay between the key press and the opening of the dialog too.
Reply
#4

I think you didn't understand.
Dialog is not showed, player presses the Enter key, server shows a dialog and immediately calls OnDialogResponse.

The code you posted fixes the problem.
Reply
#5

This problem could be related to the video poker bug in casinos
Reply
#6

Quote:
Originally Posted by Pooh7
View Post
I think you didn't understand.
Dialog is not showed, player presses the Enter key, server shows a dialog and immediately calls OnDialogResponse
The dialog is shown, but it closes again after 1 millisecond because the Enter key is still pressed. This Enter key triggers button 1 too, which calls OnDialogResponse.
Reply
#7

whats the point in posting this shits? just set it as timer or find a way around it... no one will notice this little bugs because it doesnt matter ..
have u played sa-mp even? u will be posting bug reports for a life time lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)