[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(playerid, response, ...) 
{ 
    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[], response, listitem) 
{ 
    if (
IsDialog(function, "test")) 
    { 
        
SendClientMessage(playerid, -1, "You are not allowed to answer this question!"); 
        return 
0; 
    } 
    return 
1; 
} 
Reply
#2

It's a nice idea, but something similar is already released from Emmet_ called easyDialog

https://sampforum.blast.hk/showthread.php?tid=475838
Reply
#3

Good job
Reply
#4

Nice work
Reply
#5

Good job, rep!
Reply
#6

New version:
  1. added the function IsPlayerUseDialog
  2. added a protect for dialogs
  3. added callback the OnPlayerUseDialogHider
Reply
#7

You should rename IsPlayerUseDialog to IsPlayerUsingDialog.
Reply
#8

Quote:
Originally Posted by kvann
Посмотреть сообщение
You should rename IsPlayerUseDialog to IsPlayerUsingDialog.
Thanks
Reply
#9

Good job.
Reply
#10

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
Good job.
Thank you :3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)