Y-Less / sscanf

SA:MP sscanf plugin originally made by @Y-Less
Other
122 stars 51 forks source link

extract macro can't handle other tags #22

Closed AGraber closed 6 years ago

AGraber commented 6 years ago

Using the extract macro with other tags that the macro doesn't expect messes up the macro and fails compiling:

Example:

CMD:text3d(playerid, params[])
{
    extract params -> new Text3D:textid; else return SendClientMessage(playerid, -1, "Uso: /text3d <textid>");
    return 1;
}

Gets resolevd to:

forward pc_cmd_text3d(playerid, params[]); public pc_cmd_text3d(playerid, params[])
{
    new Text3D:textid;if (unformat(_:EXTRV:EXTR8:EXTR9:EXTR0:EXTR1: Text3D_EXTRN: params ,##,|||textid|||,)) return SendClientMessage(playerid, -1, "Uso: /text3d <textid>");
    return 1;
}

Which is incorrect and fails

test.pwn:3 (error) invalid expression, assumed zero
test.pwn:3 (error) expected token: ")", but found "return"
maddinat0r commented 6 years ago

I'd suggest just adding support for all the tags you want to use with the extract macro by yourself, even if those are builtin (i.e. officially provided by SAMP) tags. Just add the following code into your script (somewhere after including the sscanf include - although it should work practically everywhere just as fine):

#define Text3D_EXTRO:%0#%1,%2|||%3=%9|||%4,%5) EXTRY:%0#%1D"("#%9")"#,%2,%3|||%4|||%5)
#define Text3D_EXTRN:%0#%1,%2|||%3|||%4,%5) EXTRY:%0#%1d,%2,%3|||%4|||%5)
#define Text3D_EXTRW:%0#%1,%2|||%3[%7]|||%4,%5) EXTRY:%0#%1a<d>[%7],%2,%3|||%4|||%5)