04.09.2011, 22:34
gDialog 1.0
Functionspawn Код:
//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[])
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;
}
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;
}
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