/cmds in dialogbox
#1

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 ?
Reply
#2

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
Reply
#3

@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?
Reply
#4

Код:
// 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;
}
Reply
#5

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.
Reply
#6

Which numbers do you mean?

Sorry..I am not really good @ pawn,just learning..
Reply
#7

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(playeriddialogidresponselistiteminputtext[])
{
    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
Reply
#8

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
pawn Код:
#define DIALOG_CMDS 1
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)