SA-MP Forums Archive
Detecting if a player has a dialog open - 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: Detecting if a player has a dialog open (/showthread.php?tid=566839)



Detecting if a player has a dialog open - Nicker - 08.03.2015

Some of you may know about the dialog exploit (I just recently learned of its existence thanks to a friend) where one can press F6 to open the chat whilst a dialog is still open. This causes lots of problems, for example, players being able to chat before they've logged in thus being able to pose as an administrator.

Is there any way to detect when a dialog is open, or do I just need to go through every ShowPlayerDialog in my gamemode and add something like DialogOpen[playerid] = 1 (and then DialogOpen = 0 when they respond to the dialog)? Thanks.



Re: Detecting if a player has a dialog open - Zonoya - 08.03.2015

The only way I know of doing it is with a declared global variable, aka the DialogOpen[playerid] = 1 variable, its fairly simple though, you'd just add it as you need it, and OnPlayerText you'd return 0 if DialogOpen[playerid] = 1, its how mute and anti-caps systems work really.


Re: Detecting if a player has a dialog open - Kyance - 08.03.2015

You can just check if the player is logged in or not when they type a command/something in main chat.

For the dialog:
pawn Код:
ShowPlayerDialogEx(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[])
{
    ShowPlayerDialog(playerid, dialogid, style, caption[], info[], button1[], button2[]);
    DialogOpen[playerid] = 1;
}
(!) Reset "DialogOpen" at the "OnDialogResponse" callback.
And do it on the very top of that callback. ( Dialog[playerid] = 0; )
Should work


Re: Detecting if a player has a dialog open - Nicker - 08.03.2015

Alright, seems there's no shorter way. Thanks guys.


Re: Detecting if a player has a dialog open - PowerPC603 - 08.03.2015

Whenever my own players login and need to enter their password, the LoggedIn variable for that player (APlayerData[playerid][LoggedIn]) is still false.

It's only set to true after they input the correct password.

This variable is used everywhere, including chat and commands.

This blocks players to chat or use any command until they have logged in properly.
Also, all of my commands are blocked when they're still in class-selection.