#define MAX_DIALOGS 50
new bool:DIALOG_USED[MAX_DIALOGS];
#define DIALOG_%0(%1,%2,%3,%4,%5,%6) forward DIALOG_%0(%1,%2,%3,%4,%5,%6); \
DIALOG_USED[%0] = true; \
public DIALOG_%0(%1,%2,%3,%4,%5,%6)
DIALOG_0(playerid, response, listitem, inputtext[]) //gets a warning: warning 203: symbol is never used: "DIALOG_0"
{
print("Test");
return 1;
}
//This function will be called later at OnDialogResponse...
DIALOG_0(playerid, response, listitem, inputtext[]);
public DIALOG_0(playerid, response, listitem, inputtext[])
{
print("Test");
return 1;
}
#define DIALOG_%1%0(%2,%3,%4,%5,%6,%7) forward%0DIALOG_%1(%2,%3,%4,%5,%6,%7); \
DIALOG_USED[%1] = true; \
public%0DIALOG_%1(%2,%3,%4,%5,%6,%7)
pawn Код:
|
You can't assign to a variable outside a function. Also, you can't do "DIALOG_%0" because the compiler is "greedy", when it sees "DIALOG_0" it will NOT call "DIALOG_" with %0=0, because "DIALOG_0" is a valid symbol. Imagine if this were not the case:
pawn Код:
pawn Код:
|
Yes, the difference is that ZCMD uses ":", not "_" - it's a small but important different as colons aren't valid identifier characters, whereas underscores are.
|
#define DIALOG:%0(%1,%2,%3,%4,%5,%6) forward DIALOG:%0(%1,%2,%3,%4,%5,%6); \
DIALOG_USED[%0] = true; \
public DIALOG:%0(%1,%2,%3,%4,%5,%6)
DIALOG:0(playerid, response, listitem, inputtext[])
{
print("Test");
return 1;
}
//And this is how i call the function at OnDialogResponse:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(DIALOG_USED[dialogid] == true)
{
new function[32];format(function,sizeof function,"DIALOG:%i",dialogid);
return CallLocalFunction(function,"iiis",playerid,response,listitem,inputtext);
}
return CallLocalFunction("SD_OnDialogResponse","iiiis",playerid,dialogid,response,listitem,inputtext);
}
//Learnt this from you before you released Y_Hooks =P
#if defined _ALS_OnDialogResponse
#undef OnDialogResponse
#else
#define _ALS_OnDialogResponse
#endif
#define OnDialogResponse SD_OnDialogResponse
forward SD_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]);
forward DIALOG:Something(params..);
DIALOG_USED[Something] = true; //You cannot use this outside any function.
public DIALOG:Something(params..) {}