[Help] Define
#1

I got this code:

pawn Код:
#define GetPos(%1, %2, %3, %4) new Float:%2, Float:%3, Float:%4; GetPlayerPos(%1, %2, %3, %4);
And I'm getting these errors if I use it:

pawn Код:
warning 236: unknown parameter in substitution (incorrect #define pattern)
warning 236: unknown parameter in substitution (incorrect #define pattern)
warning 236: unknown parameter in substitution (incorrect #define pattern)
warning 236: unknown parameter in substitution (incorrect #define pattern)
warning 236: unknown parameter in substitution (incorrect #define pattern)
warning 236: unknown parameter in substitution (incorrect #define pattern)
warning 236: unknown parameter in substitution (incorrect #define pattern)
warning 236: unknown parameter in substitution (incorrect #define pattern)
warning 236: unknown parameter in substitution (incorrect #define pattern)
error 029: invalid expression, assumed zero
warning 215: expression has no effect
error 029: invalid expression, assumed zero
warning 215: expression has no effect
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
I used it this way (Just to test):

pawn Код:
GetPos(playerid, x, y, z);
I'm still new with doing that kind of defines, I'm alright with everything else tho.
Reply
#2

Bump....
Reply
#3

Try this.
pawn Код:
#define GetPos(%1,%2,%3,%4) new Float:%2, Float:%3, Float:%4; GetPlayerPos(%1, %2, %3, %4);
Reply
#4

pawn Код:
GetPos(%1, %2, %3, %4)
Doesn't works for this reason: The first space in a #define marks the beginning of the meaning of the macro (Can you still follow it? :P).

So right now it'll think as:
pawn Код:
Macro: GetPos(%1
Meaning: %2, %3, %4) new Float:%2, Float:%3, Float:%4; GetPlayerPos(%1, %2, %3, %4);
You'll need to place it all after eachother. Also note that a macro is used to tell the script something else then there exists, so you ARE saying "#define GetPos(blabla) GetPlayerPos(blabla);". Mention that the ";" IS in the meaning, while it IS NOT in the macro itself. Therefor, using "GetPos();" will error, as the script thinks you've got ";" place twice.

So your code should be:

pawn Код:
#define GetPos(%1,%2,%3,%4) new Float:%2, Float:%3, Float:%4; GetPlayerPos(%1, %2, %3, %4)
I hope my explanation was clear, ask questions if you have any
Reply
#5

Woha, nice.
Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)