Dialogs unique identifiers (no longer maintained)
#61

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...
I really think you should be promoting this method, not trying to list every dialog as that's simply not maintainable, I don't want to have to worry about what IDs are and aren't taken, that should be a detail abstracted away from scripters. I would suggest a slight modification, as posted below, but it's only a minor thing. The major problem is that people are just choosing random IDs, so if you have three IDs and want to add another one, the next number may already be taken and you have to find another one - plus I can see arguments starting about who got an ID first, and why does one person get that one when I wanted it?

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;
}
The only real change is returning the new ID instead of getting it via pass by reference as it didn't make much sense. I also updated the examples with wiki code, but that's minor.
Reply


Messages In This Thread
Dialogs unique identifiers (no longer maintained) - by Donny_k - 18.09.2009, 15:22
Re: Dialogs unique identifiers - by Joske_Vermeulen - 18.09.2009, 15:38
Re: Dialogs unique identifiers - by Sergei - 18.09.2009, 15:40
Re: Dialogs unique identifiers - by V1ceC1ty - 18.09.2009, 15:44
Re: Dialogs unique identifiers - by Donny_k - 18.09.2009, 15:45
Re: Dialogs unique identifiers - by V1ceC1ty - 18.09.2009, 15:52
Re: Dialogs unique identifiers - by Donny_k - 18.09.2009, 15:55
Re: Dialogs unique identifiers - by V1ceC1ty - 18.09.2009, 15:57
Re: Dialogs unique identifiers - by Kalcor - 18.09.2009, 16:30
Re: Dialogs unique identifiers - by yom - 18.09.2009, 16:40
Re: Dialogs unique identifiers - by Sergei - 18.09.2009, 16:44
Re: Dialogs unique identifiers - by Kyosaur - 18.09.2009, 16:45
Re: Dialogs unique identifiers - by V1ceC1ty - 18.09.2009, 16:49
Re: Dialogs unique identifiers - by Kalcor - 18.09.2009, 16:54
Re: Dialogs unique identifiers - by V1ceC1ty - 18.09.2009, 16:59
Re: Dialogs unique identifiers - by erorcun - 18.09.2009, 17:15
Re: Dialogs unique identifiers - by V1ceC1ty - 18.09.2009, 17:17
Re: Dialogs unique identifiers - by Kalcor - 18.09.2009, 17:19
Re: Dialogs unique identifiers - by Donny_k - 18.09.2009, 17:31
Re: Dialogs unique identifiers - by Zeex - 19.09.2009, 04:10
Re: Dialogs unique identifiers - by Donny_k - 19.09.2009, 11:01
Re: Dialogs unique identifiers - by Dark_Kostas - 19.09.2009, 13:35
Re: Dialogs unique identifiers - by Donny_k - 19.09.2009, 14:00
Re: Dialogs unique identifiers - by Joe Staff - 19.09.2009, 17:16
Re: Dialogs unique identifiers - by Kurence - 19.09.2009, 17:28
Re: Dialogs unique identifiers - by Sayaron - 19.09.2009, 17:38
Re: Dialogs unique identifiers - by Donny_k - 19.09.2009, 17:44
Re: Dialogs unique identifiers - by Sayaron - 19.09.2009, 19:01
Re: Dialogs unique identifiers - by Sayaron - 19.09.2009, 19:33
Re: Dialogs unique identifiers - by Donny_k - 19.09.2009, 20:20
Re: Dialogs unique identifiers - by Sayaron - 19.09.2009, 20:36
Re: Dialogs unique identifiers - by Joe Staff - 19.09.2009, 20:49
Re: Dialogs unique identifiers - by Sayaron - 19.09.2009, 21:00
Re: Dialogs unique identifiers - by Donny_k - 19.09.2009, 21:19
Re: Dialogs unique identifiers - by Joe Staff - 19.09.2009, 21:51
Re: Dialogs unique identifiers - by Joe Staff - 19.09.2009, 22:04
Re: Dialogs unique identifiers - by Donny_k - 19.09.2009, 22:25
Re: Dialogs unique identifiers - by V1ceC1ty - 20.09.2009, 00:43
Re: Dialogs unique identifiers - by Joe Staff - 20.09.2009, 01:52
Re: Dialogs unique identifiers - by yezizhu - 20.09.2009, 06:13
Re: Dialogs unique identifiers - by Joe Staff - 20.09.2009, 07:06
Re: Dialogs unique identifiers - by Zeex - 20.09.2009, 08:02
Re: Dialogs unique identifiers - by Norn - 20.09.2009, 23:16
Re: Dialogs unique identifiers - by Donny_k - 21.09.2009, 09:32
Re: Dialogs unique identifiers - by V1ceC1ty - 21.09.2009, 09:38
Re: Dialogs unique identifiers - by Donny_k - 21.09.2009, 10:01
Re: Dialogs unique identifiers - by ded - 21.09.2009, 16:50
Re: Dialogs unique identifiers - by Correlli - 21.09.2009, 17:50
Re: Dialogs unique identifiers - by saiberfun - 21.09.2009, 18:33
Re: Dialogs unique identifiers - by Daren_Jacobson - 22.09.2009, 01:49
Re: Dialogs unique identifiers - by Kalcor - 22.09.2009, 03:16
Re: Dialogs unique identifiers - by yom - 22.09.2009, 09:44
Re: Dialogs unique identifiers - by Benne - 22.09.2009, 13:15
Re: Dialogs unique identifiers - by Daren_Jacobson - 23.09.2009, 02:26
Re: Dialogs unique identifiers - by Donny_k - 23.09.2009, 09:47
Re: [FS] Dialog - Interior Menu - by saiberfun - 23.09.2009, 21:11
Re: [FS] Dialog - Interior Menu - by Donny_k - 23.09.2009, 22:34
Re: [FS] Dialog - Interior Menu - by saiberfun - 23.09.2009, 23:12
Re: [FS] Dialog - Interior Menu - by Donny_k - 23.09.2009, 23:54
Re: [FS] Dialog - Interior Menu - by V1ceC1ty - 24.09.2009, 00:17
Re: Dialogs unique identifiers - by Y_Less - 28.09.2009, 13:04
Re: Dialogs unique identifiers - by Donny_k - 03.10.2009, 01:41
Re: Dialogs unique identifiers - by Y_Less - 15.10.2009, 13:08
Re: Dialogs unique identifiers - by Donny_k - 15.10.2009, 14:56
Re: Dialogs unique identifiers - by allarw - 15.10.2009, 15:09
Re: Dialogs unique identifiers - by Donny_k - 15.10.2009, 15:36
Re: Dialogs unique identifiers - by HydraX - 27.11.2009, 15:20
Re: Dialogs unique identifiers (no longer maintained) - by RyDeR` - 27.11.2009, 22:40

Forum Jump:


Users browsing this thread: 3 Guest(s)