#define Problem
#1

Got this code:
Code:
new fq=false;
#define SendError(%0,%1)\
do{new _str[128];format(_str,sizeof(_str)," ERROR: {FFFFFF}%1");SendClientMessage(%0,Error,_str);}while(fq)
Code:
SendError(playerid,"You are not allowed to ...");
works fine, but
Code:
if(!var[playerid])return SendError(playerid,"You are not allowed...");
doesnt work:
Code:
error 029: invalid expression, assumed zero
 warning 217: loose indentation
 error 036: empty statement
 warning 217: loose indentation
Reply
#2

pawn Code:
#define SendError(%0,%1)\
SendClientMessage(%0,Error,%1)
I don't know why you need such complicated define.
Use this instead, this should work.
Reply
#3

I'm sure that your code would work. But i don't want it like that.

I don't always want to add " ERROR: {FFFFFF}" to my string. Therefor i wrote the #define.
Reply
#4

pawn Code:
#define SendError(%0,%1)\
new fstr[128]; format(fstr,sizeof(fstr),"ERROR:{FFFFFF}%s",%1);\
SendClientMessage(%0,Error,fstr)
Would this work?
Reply
#5

Wouldn't work; had nearly the same before.
Reply
#6

pawn Code:
if(!var[playerid])
(
SendError(...);
return 1;
)
Does this give any errors?
Reply
#7

Nope, thanks. But why?
Reply
#8

pawn Code:
new fq=false;
#define SendError(%0,%1)\ do{new _str[128];format(_str,sizeof(_str)," ERROR: {FFFFFF}%1");SendClientMessage(%0,Error,_str); return 1;}while(fq)
Try this define and try using
pawn Code:
if(!var[playerid]) return SendError(...);
Reply
#9

No, still the same errors. But thanks
Reply
#10

pawn Code:
define SendError(%0,%1)\
new fstr[128]; format(fstr,sizeof(fstr),"ERROR:{FFFFFF}%s",%1);\
return SendClientMessage(%0,Error,fstr)
Just use this define instead.
Reply
#11

Just create a function for it, it's more efficient and easier to change.

When you use a function many times, your amx will only hold a call to the function.
When you use a define, your amx will hold many copies of the same code and will eventually be much larger.
Reply
#12

Would not work. As is said, there would be the Error "undefinied symbol "fstr" or sth. like that

/edit:

Yep, but why doesn't the define work with "return" ?
Reply
#13

Does my define work?
when you are using return Function(); the script returns function's return value, but the define does not return anything in your case.
Reply
#14

Nope, your's didn't work.
I created a function.
Thanks 2 you 2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)