#define function help
#1

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,
Reply
#2

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

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 .
Reply
#4

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!
Reply
#5

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.
Reply
#6

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)