SA-MP Forums Archive
#define function help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: #define function help (/showthread.php?tid=251835)



#define function help - blackwave - 28.04.2011

Take a look at that:

pawn Код:
#define Msg(%1, %2, %3) \
foreach(Player, players) \
if(players != %1 || %1 != players) \
SendClientMessage(%1, %2, %3)

#define MsgForAll(%1, %2) \
foreach(Player, players) \
Msg(players, %1, %2)
And gives me:

Код:
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : warning 236: unknown parameter in substitution (incorrect #define pattern)
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : warning 236: unknown parameter in substitution (incorrect #define pattern)
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : warning 236: unknown parameter in substitution (incorrect #define pattern)
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : warning 236: unknown parameter in substitution (incorrect #define pattern)
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : error 029: invalid expression, assumed zero
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : warning 215: expression has no effect
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : error 029: invalid expression, assumed zero
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : warning 215: expression has no effect
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : error 001: expected token: ";", but found ")"
E:\SAMP SERVER 0.3C\gamemodes\Roleplay.pwn(158) : fatal error 107: too many error messages on one line
If I remove the line 158, gives me same errors on other lines, since I use these functions other times. What's wrong with the #define function?

pawn Код:
Msg(playerid, color_white, string);
I used to use this function as stock, but now I want as #define. Thanks,


Re: #define function help - Memoryz - 28.04.2011

Just use it as a stock, no point in using a define.


Re: #define function help - blackwave - 28.04.2011

lol, I need it as #define now. This function I got from this forum:

pawn Код:
#define SendFormattedMessage(%1,%2,%3,%4) \
new str[150]; \
format(str, sizeof str, %3, %4); \
SendClientMessage(%1, %2, str)
And works.. Almost same thing as am trying to do .


Re: #define function help - TheGarfield - 28.04.2011

pawn Код:
#define  SendFormattedMessage(%1,%2,%3,%0) ((do{new %0;format(%0, sizeof(%0),%3,%4),SendClientMessage(%1, %2, %0)while(false)))
try this seu feio!


Re: #define function help - blackwave - 28.04.2011

Quote:
Originally Posted by TheGarfield
Посмотреть сообщение
pawn Код:
#define  SendFormattedMessage(%1,%2,%3,%0) ((do{new %0;format(%0, sizeof(%0),%3,%4),SendClientMessage(%1, %2, %0)while(false)))
try this seu feio!
Problemas eram com essas duas aq abaixo x_ x..
pawn Код:
#define Msg(%1, %2, %3) \
foreach(Player, players) \
if(players != %1 || %1 != players) \
SendClientMessage(%1, %2, %3)

#define MsgForAll(%1, %2) \
foreach(Player, players) \
Msg(players, %1, %2)
Just showed the example I've got.


Re: #define function help - aircombat - 28.04.2011

try :
pawn Код:
#define Msg(%1, %2, %3) {foreach(Player, players) if(players != %1 || %1 != players) SendClientMessage(%1, %2, %3)}



Re: #define function help - blackwave - 28.04.2011

Just forget that. Looks impossible, and I made as stock as before. Thanks always ;