[Include] Callback Dialogs (Faster processing dialogs)
#1

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 Код:
//
//   Made by Clavador
//  original idea by
//       gamer_Z (Thanks)
//    find it here:
// https://sampforum.blast.hk/showthread.php?tid=260298


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;
}

*/
Reply
#2

great!
Reply
#3

excellent!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)