28.09.2009, 13:04
Quote:
Originally Posted by ZeeX
After a bit of thinking I realized that the method which I posted above is not so good as I thought, so I wrote this one:
As you can see here I call special function called AddDialog for each my dialog only once and it stores new dialog ID in some variable passed by reference (dialog1, dialog2 and dialog3 in my case), then I use those IDs for ShowPlayerDialog and OnDialogResponse. Now it's more like a work with menus... |
pawn Code:
#include <a_samp>
new
dialog1,
dialog2,
dialog3;
public OnFilterScriptInit()
{
dialog1 = AddDialog();
dialog2 = AddDialog();
dialog3 = AddDialog();
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_CROUCH))
{
ShowPlayerDialog(playerid, dialog1, 0, "caption 1", "info 1", "button1 1", "button2 1");
}
if (PRESSED(KEY_JUMP))
{
ShowPlayerDialog(playerid, dialog2, 0, "caption 2", "info 2", "button1 2", "button2 2");
}
if (PRESSED(KEY_SPRINT))
{
ShowPlayerDialog(playerid, dialog3, 0, "caption 3", "info 3", "button1 3", "button2 3");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == dialog1)
{
SendClientMessage(playerid, 0xFFFFFFFF, "Dialog 1 response");
}
else if (dialogid == dialog2)
{
SendClientMessage(playerid, 0xFFFFFFFF, "Dialog 2 response");
}
else if (dialogid == dialog3)
{
SendClientMessage(playerid, 0xFFFFFFFF, "Dialog 3 response");
}
else
{
return 0;
}
return 1;
}
stock AddDialog()
{
new
dialogs;
dialogs = getproperty(0, "dialogs");
setproperty(0, "dialogs", dialogs + 1);
return dialogs;
}