SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 06/07/2011, 07:22 AM   #1
clavador
Huge Clucker
 
clavador's Avatar
 
Join Date: Jun 2007
Location: Argentina
Posts: 220
Reputation: 71
Default Callback Dialogs (Faster processing dialogs)

NOTE: After testing, switch statements are faster than this (not that much). Anyway, be free to use it if you want to have a more well presented script file, as this gives you the possibility to separate dialogs in functions.


This include will give you the ability to call dialogs directly as if they are callbacks (that means that you dont have to fill your code with lots of ifs or switches).

This include is similar to Gamer_Z one, but I made my own because I couldn't get it to work with JunkBuster and I thought of releasing it for whoever may need it.

Thanks to Gamer_Z for the idea:

(i fixed the bug where i forgot to remove the dialogid from the define)

pawn Code:
//
//   Made by Clavador
//  original idea by
//       gamer_Z (Thanks)
//    find it here:
// [url]http://forum.sa-mp.com/showthread.php?t=260298[/url]


new DialogToCall[24];

// REMOVE THIS CALLBACK FROM ALL YOUR OTHER SCRIPTS
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{  
        format(DialogToCall,24,"DialogResponse_%d",dialogid); // DONT USE NEGATIVE CALLBACKS
        if(isnull(inputtext))format(inputtext,2,"\1");
        if(funcidx(DialogToCall) != -1)
    return CallLocalFunction(DialogToCall,"iiis",playerid,response,listitem,inputtext);
       
        return 0;
}

// DEFINE THE FUNCTION
#define Dialog(%1) forward DialogResponse_%1(playerid, response, listitem, inputtext[]); \
                   public DialogResponse_%1(playerid, response, listitem, inputtext[])

/*

REPLACE YOUR if(dialogid == 1) with this function

Dialog(1) // (playerid,response,lisitem,inputtext[]) are passed as always
{
   if(response)
   {
       //do something  
   }
   return 1;
}

*/

Last edited by clavador; 11/07/2011 at 08:40 AM.
clavador is offline   Reply With Quote
Old 06/07/2011, 07:48 AM   #2
VivianKris
Big Clucker
 
Join Date: Jun 2010
Posts: 105
Reputation: 0
Default Re: Callback Dialogs (Faster processing dialogs)

great!
VivianKris is offline   Reply With Quote
Old 06/07/2011, 10:59 AM   #3
LZLo
Huge Clucker
 
LZLo's Avatar
 
Join Date: Jul 2010
Location: Central Europe
Posts: 489
Reputation: 21
Default Re: Callback Dialogs (Faster processing dialogs)

excellent!
__________________

CCFH 2.0 is out now! (preview: https://www.youtube.com/watch?v=Bubt5MykYj0)
LANGUAGE: (ENGLISH& Hungarian)
PAWN scripting since 2006

Show some love and appreciation by smashing the button!
LZLo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Sasi-Dialogs - A new way to add dialogs! Sasino97 Includes 10 02/05/2011 02:20 PM
Dialogs help.. sMog. Help Archive 4 18/03/2011 03:33 PM
DIALOGS HELP PLEASE !!! [Lsrcr]Rafa Help Archive 10 16/10/2010 12:10 PM
How to use dialogs Torran Help Archive 7 03/03/2010 05:12 PM
Dialogs Conflict with other Dialogs with different... HydraX Help Archive 33 01/01/2010 11:33 PM


All times are GMT. The time now is 10:03 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.