#define + Strings | Compiler do what it wants ...
#1

.:: SOLVED (see my last post) ::.

Hello people
I have a big problem with the following code:
Code:
Acc("Level","47");

#define Acc("%0","%1"); \
	EditAccount(playerid,"%0","%1", 0); \
	Account[playerid][%0] = %1;

forward EditAccount(playerid,fieldname[],value[MAX_PLAYER_NAME], finished);
THIS is working:
Code:
EditAccount(playerid,"Level","47", 0);
I dont know why it fails ...
Do not wonder about the string "47", it will be converted to an integer under EditAccount!

Here is the result, the "failing" query:
Code:
UPDATE spieler SET %0=0 WHERE SpielerID = 1
"EditAccount(playerid,"Level","47", 0);" will bring:
Code:
UPDATE spieler SET Level=47 WHERE SpielerID = 1
I Hope anyone can help me with this!
If more details are needed -> Say it here.

Greetz Kevin
Reply
#2

Thank you for your answer!
I changed this two things:
-> define Acc(%0,%1);
-> EditAccount(playerid,%0,%1, 0);

Now there are these Errors:
error 001: expected token: "-string end-", but found "-identifier-"
error 006: must be assigned to an array
On the Line "Acc("Level","47");"

Don`t know what i should do next ...
Reply
#3

Southclaw,
Thank you for your great post!
It helped me a lot!

Quote:
Originally Posted by [HLF]Southclaw
View Post
Okay definitions are EXACT replacements, so to debug one simply put the code in the place of the definition:
Therefore, after the compiler replaces that code you end up with:
pawn Code:
Account[playerid]["Level"] = "47";
The first line is fine, it's the second line that doesn't look like you've anticipated!
I was only concentrated on the first EditAccount-stuff ....
I already got it ... but i didn`t know how to work without the "`s and with the #-character (saw it in pawn-lang.pdf).
I didn`t know what i do.

Its working:
pawn Code:
Acc(Level,"47");

#define Acc(%0,%1);
    EditAccount(playerid, #%0, #%1, 0);
    Account[playerid][%0] = %1;
My "edited" version:
pawn Code:
Acc("Level",47);

#define Acc("%0",%1); \
    EditAccount(playerid,#%0,#%1, 0); \
    Account[playerid][%0] = %1;
There isn`t a big difference, but maybe it helps me (and others) to understand it!


.:: SOLVED ::.


~ Kevin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)