Dialog
- class pysamp.dialog.Dialog(type: int, title: str, content: str, button_1: str, button_2: str, on_response: Optional[Callable] = None)
Bases:
object
Class to create and show dialogs.
A dialog is a menu that the player can interact with. To create a new dialog, use
create()
.The player will see the dialog when you do
show()
. The Dialog class will behind the scenes keep track of if a dialog is shown to a player, and will that way automatically prevent traditional spoofing of dialogs.- classmethod create(type: int, title: str, content: str, button_1: str, button_2: str, on_response: Optional[Callable] = None) Dialog
Create/prepare a dialog for use later.
Use
show()
to show the dialog to a player after creating it.- Parameters
type – The type of dialog you want to make. There are 6 different types:
DIALOG_STYLE_MSGBOX
,DIALOG_STYLE_INPUT
,DIALOG_STYLE_LIST
,DIALOG_STYLE_PASSWORD
,DIALOG_STYLE_TABLIST``and ``DIALOG_STYLE_TABLIST_HEADERS
.title – The dialog title show at top.
content – The content of the dialog.
button_1 – The positive dialog response button. Can’t be longer than 8 characters, else it looks weird.
button_2 – The second button, negative response. If it is left empty, it will be hidden from the dialog.
on_response (Callable) – The function to call on response.
- Returns
This classmethod creates a new instance of
Dialog
.
- classmethod handle(player_id: int, dialog_id: int, response: int, list_item: int, input_text: str)
- static hide(for_player: Player) None
Shows a dialog with ID -1 to hide open dialog.
- Parameters
for_player (Player) – The player you’d like to hide open dialogs for.
- Returns
No return value.
- show(for_player: Player) None
Show the dialog created with
create()
to a specific player.- Parameters
for_player (Player) – The player you want to show the dialog for.
- Returns
No return value.
Note
You can only show one dialog to a player at a time. Showing a new dialog will close the old one, if shown.