/cmds in dialogbox -
NviDa - 30.03.2015
I have a few commands like:
/heal
/kill etc.
And I can view all these commands when I do /cmds.But it appears in chatbox.I want to show it in a dialog box.How can I do it ?
Re: /cmds in dialogbox -
CalvinC - 30.03.2015
Here's an example using ZCMD:
pawn Код:
enum
{
DIALOG_CMDS
}
COMMAND:commands(playerid)
{
ShowPlayerDialog(playerid, DIALOG_CMDS, DIALOG_STYLE_MSGBOX, "Title", "text", "Button1", "Button2");
return 1;
}
Source:
https://sampwiki.blast.hk/wiki/ShowPlayerDialog
Re: /cmds in dialogbox -
NviDa - 30.03.2015
@CalvinC
I know that but I don't wanna have button 1 and 2.Can I just put button 1?
And why do you use enum here?Could you explain the enum part?
Re : /cmds in dialogbox -
Wassimo - 30.03.2015
Код:
// This command lists all commands for normal players (admin-level 0)
COMMAND:cmds(playerid, params[])
{
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
CommandList_Create(playerid); // Create a list of commands (only the first 4 commands) and show the dialog
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
Re: /cmds in dialogbox -
CalvinC - 30.03.2015
Just make the second button contain nothing:
pawn Код:
ShowPlayerDialog(playerid, DIALOG_CMDS, DIALOG_STYLE_MSGBOX, "Title", "text", "Button1", "");
Then it wont be displayed.
And i use an enumerator so that the numbers gets assigned automatically, you can use #define as well to define numbers, but using an enumerator is easier and less confusing.
Re: /cmds in dialogbox -
NviDa - 30.03.2015
Which numbers do you mean?
Sorry..I am not really good @ pawn,just learning..
Re: /cmds in dialogbox -
NoDi522 - 30.03.2015
PHP код:
#include <a_samp>
#define DIALOG_COMMANDS 1 // This is alternative defining. I prefer enums but however..
#include <zcmd> // You have to download zcmd.inc and include it to use this command:
CMD:commands(playerid,params[])
{
ShowPlayerDialog(playerid,DIALOG_COMMANDS,DIALOG_STYLE_LIST,"Choose your command","- Heal\n- Suicide\n- Deagle\n- You Command","Choose","");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_COMMANDS:
{
if(response)
{
switch(listitem)
{
case 0:
{
SetPlayerHealth(playerid,100); //Healing player
SendClientMessage(playerid,-1,"You have been healed"); // done healing
}
case 1:
{
SetPlayerHealth(playerid,0);
SendClientMessage(playerid,-1,"You did suicide");
}
case 2:
{
GivePlayerWeapon(playerid,24,500);
SendClientMessage(playerid,-1,"We gave you desert eagle");
}
case 3:
{
// Do some other commands
}
}
}
}
}
return 1;
}
Here is an example. Download ZCMD:
https://sampforum.blast.hk/showthread.php?tid=91354
Re: /cmds in dialogbox -
CalvinC - 30.03.2015
The dialog ID.
Each dialog has it's own dialogid, to be used in
OnDialogResponse where you can script different functions for different dialog ID's.
Basically some people use
Which makes
pawn Код:
ShowPlayerDialog(playerid, 1, ...);
The same as doing
pawn Код:
ShowPlayerDialog(playerid, DIALOG_CMDS, ...);
Which is more organised, and less confusing.
However using an enumerator is even less confusing, as it applies the ID's(numbers) automatically.