Need help with function moving
#1

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
        //HERE I WANT TO CALL FUNCTION WITH SAME PARAMS (Same event only in other place)
        OnDialog2(playerid, dialogid, response, listitem, inputtext[]);
    return 1;
}
pawn Код:
//Function
forward OnDialog2(playerid, dialogid, response, listitem, inputtext[]);
public OnDialog2(playerid, dialogid, response, listitem, inputtext[])
{
        //blabla
        return 1;
}
But "error 029: invalid expression, assumed zero"
Basically i want to duplicate callback, to make code look better, and easier to work with.
Reply
#2

Try this

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
        //HERE I WANT TO CALL FUNCTION WITH SAME PARAMS (Same event only in other place)
        OnDialog2(playerid, dialogid, response, listitem, inputtext);
    return 1;
}
Reply
#3

Thanks, and one more question, will it take more resources?
Reply
#4

No, it's a simple call to a function, if you want to use it on more places the same code, this is the way to do it.
Reply
#5

Last question, which way better:

forward OnDialog2(playerid, dialogid, response, listitem, inputtext[]);
public OnDialog2(playerid, dialogid, response, listitem, inputtext[])
{
return ...
}

or

OnDialog2(playerid, dialogid, response, listitem, inputtext[])
{
return ...
}

if in the dialog2, i want to control returns of OnDialogResponse
Reply
#6

Use forward if you want it to be called from other includes also.
Reply
#7

Thanks +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)