[Include] RDLG - Reliable/Fast Dialog Processor
#1

Description
  • This is a little include that uses OnPlayerDialogResponse( ) to process players Dialogs.
    Each dialog has his own function like the Command Processors( ZCMD, DCMD, YCMD ), such method is much faster than the normal way.
Usage
  • All you need to do is to add a public function using special pre-defined macros, like this:
    pawn Код:
    DIALOG:1( playerid, response, listitem, inputtext[ ] )
    {
        // Your code here, like in the Normal Dialogs with 'if else if else if else'

        return ( 1 ); // My style, it's not obligatory to use returns like that
    }
    or( another macro ):

    pawn Код:
    DLG:1( playerid, response, listitem, inputtext[ ] )
    {
        // Your code here, like in the Normal Dialogs with 'if else if else if else'

        return ( 1 );
    }
Here is all like the normal dialogs, but much faster.
That's all! Very easy, isn't it?

How to make two different dialogs doing the same thing( like in ZCMD )
  • For example, you have the dialog '123' :
    pawn Код:
    DIALOG:123( playerid, response, listitem, inputtext[ ] )
    {
        // Your stuff here...
        return ( 1 );
    }
    And you want to create another one that does the same thing:
    pawn Код:
    DIALOG:456( playerid, response, listitem, inputtext[ ] )
    {
        return dlg_123( playerid, response, listitem, inputtext );
    }
Notes
  • If you want to check whether inputtext string is empty( like in ZCMD with parameters ) you should not do it like:
    pawn Код:
    if( !strlen( inputtext ) )
    {
        // ...
    }
    or:
    pawn Код:
    if( !inputtext[ 0 ] )
    {
        // ...
    }
    Just use isnull( ), because its length will never be NULL:
    pawn Код:
    if( isnull( inputtext ) )
    {
        // ...
    }
    Actually, if you use sscanf[1] you don't need to do this as it has built-in isnull checking.
Speed Test
  • I did the test between mine and FDLG( because I think is the faster ) and here's the Result:
    Код:
    Time taken to show 32766 RDLG dialogs: 3 ms, average call time: 3/32766 ms.
    Time taken to execute 100,000,000 RDLG OnDialogResponse calls: 8805 ms.
    
    Time taken to show 32766 FDLG dialogs: 4 ms, average call time: 4/32766 ms.
    Time taken to execute 100,000,000 FDLG OnDialogResponse calls: 8818 ms.
    Both are almost the same at timing!
Requirements Downloads Special thanks to
  • ****** - For some Tips.
  • stuntman - For some Tips.
  • Gamer_Z - His Speed Test Filterscript.
Reply
#2

I like it, but execution time is not that far off from FDLG.
Reply
#3

Quote:
Originally Posted by coole210
Посмотреть сообщение
I like it, but execution time is not that far off from FDLG.
Exactly, I think I will work on it to increase the performance, if I can...
Reply
#4

i want without y hook.
Reply
#5

Quote:
Originally Posted by Unknown1234
Посмотреть сообщение
i want without y hook.
Allright Unknown1234

EDIT: Done.
Reply
#6

I'm not bothered about the speed, the performance matter...
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Speed IS performance, they mean the same thing!
I'm...
Reply
#8

Nice, relase Good Job!
Reply
#9

Mnoh...Good job
Reply
#10

Thank you
Reply
#11

Sorry for the double-post.

New things
  • Now it's faster and shorter.
  • Has support for y_hooks( it will detect by itself if you have y_hooks or not ).
  • Is using Ternary-Operator to increase the performance.
Reply
#12

Nice scripted, big performance ... well done Roach. ^^
Reply
#13

Not bad.
Reply
#14

Quote:
Originally Posted by iZN
Посмотреть сообщение
Not bad.
Thank you !
Reply
#15

That's one of the best dialog processors I ever seen. I am surely going to use this one! Epic job, thanks .
Reply
#16

please give me an example.... how to use this

Код:
SPD(playerid, 3, DIALOG_STYLE_MSGBOX,
	" TITLE ",
	"  MESSAJE "?",
	"BUTTON1", "BUTTON2");
Reply
#17

Quote:
Originally Posted by Bect
Посмотреть сообщение
please give me an example.... how to use this

Код:
SPD(playerid, 3, DIALOG_STYLE_MSGBOX,
	" TITLE ",
	"  MESSAJE "?",
	"BUTTON1", "BUTTON2");
In a callback:
Код:
ShowPlayerDialogid( playerid, DIALOG_ID, DIALOG_STYLE_MSGBOX, "Title", "Message", "Button1", "Button2" );
Whereever in the script, but not in a callback, just like CMD: from ZCMD:
Код:
DIALOG:DIALOG_ID( playerid, response, listitem, inputtext[ ] )
{
    if( !response ) // pressed button 2
        return 1;

    //Pressed button 1
    SendClientMessage( playerid, -1, "RDLG" );
    return 1;
}
Reply
#18

Quote:
Originally Posted by ******
Посмотреть сообщение
Do you have any evidence to support this claim? "if" and "?" generate more-or-less the same code!
Yeah, I know, but I else know that the Ternary-Operator is faster than 'if else if else if else..'...
Reply
#19

F**k, I give up, I don't know anything about the scripting in others languages and this sh*ts...
Reply
#20

Quote:
Originally Posted by ******
Посмотреть сообщение
I wasn't trying to make you give up, I was simply trying to show that you claiming you did it one way because it's "faster" needs PROOF which you didn't provide. Had you said "I've switched to using the ternary operator because it's faster, and here are several million runs to prove it", I would have been entirely happy. But your "evidence" was claiming that you "know" it is.

For reference, if you compile with the "-a" flag, you will get the assembly I posted and you can examine it.
How to compile it with the "-a" flag? I'd like to check it by myself too.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)