This macro definition crashes the compiler with no outcome. -
Meller - 10.11.2017
PHP Code:
#define SendClientMessage(%0,%1) SendClientMessage(%0, 0xD4D9ECFF, %1)
that code, why?
urghhh
PHP Code:
public OnPlayerConnectEx(playerid) {
for(new i = 0; i < 21; i++)
SendClientMessage(playerid, "");
Re: This macro definition crashes the compiler with no outcome. -
Thomas Dallos - 10.11.2017
#undef SendClientMessage?
Re: This macro definition crashes the compiler with no outcome. -
Meller - 10.11.2017
Quote:
Originally Posted by Thomas Dallos
#undef SendClientMessage?
|
Look at my code again, rethink WHY I DON'T HAVE A %2, BUT ONLY %0 AND %1
and rethink of what a macro definition is versus a native.
k thx
Re: This macro definition crashes the compiler with no outcome. -
NaS - 10.11.2017
Quote:
Originally Posted by Meller
Look at my code again, rethink WHY I DON'T HAVE A %2, BUT ONLY %0 AND %1
and rethink of what a macro definition is versus a native.
k thx
|
He is kind of right, you cannot re-define a symbol even with changed amount of parameters.
Well, you can define it but once you use it the compiler will crash.
It results in an infinite loop, SendClientMessage gets replaced with the new SendClientMessage, which again gets replaced by SendClientMessage (etc).
Re: This macro definition crashes the compiler with no outcome. -
Meller - 10.11.2017
Quote:
Originally Posted by NaS
He is kind of right, you cannot re-define a symbol even with changed amount of parameters.
Well, you can define it but once you use it the compiler will crash.
It results in an infinite loop, SendClientMessage gets replaced with the new SendClientMessage, which again gets replaced by SendClientMessage (etc).
|
I've done this with other natives earlier (several months ago), I used Kick(%0,%1) to return a SetTimerEx with an interval of the players ping for example. I've done this before, however this time something went wrong.
Re: This macro definition crashes the compiler with no outcome. -
NaS - 10.11.2017
But there's a difference between defining a macro with different arguments that calls a
seperate function and a macro that would call itself.
OK:
#define Kick(%1,%2) DelayedKick(%1,%2)
Not OK:
#define Kick(%1,%2) Kick(%1)
#define printf(%1,%2) printf("%s%d",%1,%2)
Make a seperate function for SendClientMessage that has 2 arguments and then use that in the macro.
Code:
SendClientMessage2(playerid, text[]) SendClientMessage(playerid, 0xFFFFFFFFF, text);
#define SendClientMessage(%1,%2) SendClientMessage2(%1,%2)
Re: This macro definition crashes the compiler with no outcome. -
Meller - 10.11.2017
Quote:
Originally Posted by NaS
But there's a difference between defining a macro with different arguments that calls a seperate function and a macro that would call itself.
OK:
#define Kick(%1,%2) DelayedKick(%1,%2)
Not OK:
#define Kick(%1,%2) Kick(%1)
|
So why is these
#define Kick(%1,%2
) Kick(%1
)
being completely ignored then?
like it's only logical that if it's ended, it's ended. and that I'm only defining for i.ex.
Kick(%1,
%2)
to be
Kick(
%1)
Re: This macro definition crashes the compiler with no outcome. -
Marricio - 10.11.2017
Quote:
Originally Posted by Meller
I've done this with other natives earlier (several months ago), I used Kick(%0,%1) to return a SetTimerEx with an interval of the players ping for example. I've done this before, however this time something went wrong.
|
Dude. "re-think"
NaS workaround should work for you.
Code:
SendClientMessage2(playerid, text[]) SendClientMessage(playerid, 0xFFFFFFFFF, text);
#define SendClientMessage(%1,%2) SendClientMessage2(%1,%2)