[Include] gDialog - Easyer way of managing dialogs!
#1

gDialog 1.0
Functions
pawn Код:
//Creating a dialog and saving them into memory (usefull when you need to re-use them multiple times)
native CreateDialog(dialogid,style,caption[],info[],button1[],button2[])

//Showing saved dialogs:
native ShowPlayerDialog(playerid,dialogid)

//Showing dialogs normally like the normal ShowPlayerDialog()
native ShowPlayerDialogEx(playerid,dialogid,style,caption[],info[],button1[],button2[])
Callbacks NEW!
You can still use OnDialogResponse, BUT you can also use this method:
pawn Код:
DIALOG:0(playerid,response,listitem,inputtext[])
{
    //This will handle OnDialogResponse for dialogid 0!
    return 1;
}
Example usage
pawn Код:
#include <a_samp>
#include <gDialog>

public OnFilterScriptInit()
{
    /*
        CreateDialog(dialogid,style,caption[],info[],button1[],button2[])
        -Creates a dialog that you can use later again with ShowPlayerDialog()
    */

    CreateDialog(0,DIALOG_STYLE_INPUT,"Spawning a vehicle","Please type a VehicleID here","OK","Cancel");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/car", cmdtext, true, 10) == 0)
    {
        /*
            ShowPlayerDialog(playerid,dialogid)
            -Shows the dialog created with CreateDialog()
        */

        ShowPlayerDialog(playerid,0);
        return 1;
    }
   
    if (strcmp("/tele", cmdtext, true, 10) == 0)
    {
        /*
            ShowPlayerDialogEx(playerid,dialogid,style,caption[],info[],button1[],button2[])
            -Simular to the normal ShowPlayerDialog(), shows the dialog directly to player without futher saving it.
        */

        ShowPlayerDialogEx(playerid,1,DIALOG_STYLE_LIST,"Select a teleport","San Fierro\r\nLas Venturas\r\nLos Santos","OK","Cancel");
        return 1;
    }
    return 0;
}

/*
    *NEW!*  Method of handling dialogs:
   
    DIALOG:dialogid(playerid,response,listitem,inputtext[])
   
    This will handle everything of the id defined at DIALOG:idhere (simular to OnDialogResponse)
    WILL WORK ON ShowPlayerDialog() AND ShowPlayerDialogEX!!! (you can also still use OnDialogResponse() if you preffer!)
*/

DIALOG:0(playerid,response,listitem,inputtext[])
{
    if(response)
    {
        new Float:x,Float:y,Float:z;GetPlayerPos(playerid,x,y,z);
        new v = AddStaticVehicle(strval(inputtext),x,y,z,0,-1,-1);
        PutPlayerInVehicle(playerid,v,0);
    }
    return 1;
}

DIALOG:1(playerid,response,listitem,inputtext[])
{
    switch(listitem)
    {
        case 0: SetPlayerPos(playerid,0,0,0);
        case 1: SetPlayerPos(playerid,0,0,0);
        case 2: SetPlayerPos(playerid,0,0,0);
    }
    return 1;
}
Special thanks to
Zeex for ZCMD (to spy a bit on the source checking how to define the DIALOG: part)
****** for a little bit help

Download:
Pastebin
SA-MP
Reply


Messages In This Thread
gDialog - Easyer way of managing dialogs! - by gamer931215 - 04.09.2011, 22:34
Re: gDialog - Easyer way of managing dialogs! - by FireCat - 04.09.2011, 22:36
Re: gDialog - Easyer way of managing dialogs! - by [MNC]Azz - 04.09.2011, 23:31
Re: gDialog - Easyer way of managing dialogs! - by Phanto90 - 04.09.2011, 23:35
Re: gDialog - Easyer way of managing dialogs! - by gamer931215 - 04.09.2011, 23:53
Re: gDialog - Easyer way of managing dialogs! - by Darnell - 05.09.2011, 10:59
Re: gDialog - Easyer way of managing dialogs! - by Kaperstone - 05.09.2011, 15:22
Re: gDialog - Easyer way of managing dialogs! - by Gh0sT_ - 05.09.2011, 15:24
Re: gDialog - Easyer way of managing dialogs! - by Sascha - 06.09.2011, 11:03
Re: gDialog - Easyer way of managing dialogs! - by Gh0sT_ - 06.09.2011, 12:59
Re: gDialog - Easyer way of managing dialogs! - by gamer931215 - 06.09.2011, 14:30
Re: gDialog - Easyer way of managing dialogs! - by Gh0sT_ - 06.09.2011, 15:48
Re: gDialog - Easyer way of managing dialogs! - by Gamer_Z - 08.09.2011, 16:32
Re: gDialog - Easyer way of managing dialogs! - by gamer931215 - 08.09.2011, 16:55
AW: gDialog - Easyer way of managing dialogs! - by Nanory - 08.09.2011, 19:40
Re: gDialog - Easyer way of managing dialogs! - by Gamer_Z - 08.09.2011, 20:24
AW: gDialog - Easyer way of managing dialogs! - by BloodyEric - 08.09.2011, 20:59
Re: gDialog - Easyer way of managing dialogs! - by Gamer_Z - 08.09.2011, 22:42
Re: gDialog - Easyer way of managing dialogs! - by Sasino97 - 09.09.2011, 10:33
Re: gDialog - Easyer way of managing dialogs! - by Gamer_Z - 09.09.2011, 11:37
Re: gDialog - Easyer way of managing dialogs! - by Gamer_Z - 20.09.2011, 15:42
Re: gDialog - Easyer way of managing dialogs! - by [M.A]Angel[M.A] - 20.09.2011, 16:17
Re: gDialog - Easyer way of managing dialogs! - by Hade. - 13.11.2012, 08:10

Forum Jump:


Users browsing this thread: 1 Guest(s)