[Include] u_dlg.inc | ZCMD analog, but with SA-MP GUI
#1

This is just a little include what uses OnDialogResponse() to process dialogs. A method of creating dialogs like in zcmd. You can show dialog to a player in gamemode and to process dialog, you can in a filterscript.
I wrote this include to simplify the work with dialogs in large scripts (gamemodes).

Change log

Download the latest version.
Project page on GitHub.

Usage:
PHP код:
#include <a_samp> 
#include "u_dialogs" 
public OnPlayerConnect(playerid

    
ShowPlayerDialogEx
        
playerid"test"DIALOG_STYLE_MSGBOX
        
"Important "
        
"Today you are asleep?"
        
"Yes""No" 
    
); 
    return 
1

/*
** I decided to make the creation of handler functions similar
** the creation of common functions. Indeed, often, we do not need
** 4, to use all arguments, but rather only two.
**
** Unnecessary arguments can be hidden through
** #pragma unused <arg>
**
** The function should always return any value.
*/
DialogResponse:test(playeridresponse, ...) 

    if (!
response
    { 
        
SendClientMessage(playerid, -1"Why you didn't sleep?"); 
    } 
    else 
    { 
        
SendClientMessage(playerid, -1"It is good that you slept. Today there are a lot of affairs!"); 
    } 
    return 
1

/*
** This callback is before treatment and dialogue,
** In the case of the return of zero, it does not handle the dialogue.
** Any other value - handles.
*/
public OnDialogReceived(playerid, function[], responselistitem

    if (
IsDialog(function, "test")) 
    { 
        
SendClientMessage(playerid, -1"You are not allowed to answer this question!"); 
        return 
0
    } 
    return 
1

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)