macro -
Jefff - 19.12.2013
I have an example FS
pawn Код:
#define ABC:%1(%2) \
forward xyz_%1(%2); \
public xyz_%1(%2)
#define LOL 2
public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp(cmdtext,"/asd",true))
{
print("xyz_"#LOL);
CallLocalFunction("xyz_"#LOL, "i", 345);
return 1;
}
return 0;
}
ABC:LOL(playerid)
{
printf("Called: %d",playerid);
return 1;
}
Question is how can i call ABC:LOL(playerid) via CallLocalFunction("xyz_"#LOL, "i", 345); ?
it doesn't call, what i must change or it's possible ?
Re: macro -
iJumbo - 19.12.2013
You need to set 2 as a string i think "2" ..
or do somethin like "xyz_"#LOL""
Re: macro -
Jefff - 19.12.2013
Same result isn't called, here is problem ABC:LOL(playerid) not in CallLocalFunction
Re: macro - Patrick - 19.12.2013
I am not really sure why your code didn't worked, I tried it on
Slice's Pawn Playground the callback that you tried calling does not get called, maybe because you code differently or something, because people don't often use
#(Hashtag) they often use
" "(Quotation mark).
This code worked
pawn Код:
#include <a_samp>
#define ABC:%1(%2) \
forward %1(%2); \
public %1(%2)
new LoL = 2
main()
{
printf("%i", LoL);
CallLocalFunction("LOL", "i", 345);
}
ABC:LOL(playerid)
{
print("CallLocalFunction Worked.");
return 1;
}
Slice's Pawn Playground - Result
Код:
2
CallLocalFunction Worked.
Error: read EIO (EIO)
The server stopped.
Try the code I gave you your self using this link:
http://slice-vps.nl:7070/
Re: macro -
Jefff - 19.12.2013
but i want xyz_2 not xyz_LOL
pawn Код:
#include <a_samp>
#define ABC:%1(%2) \
forward xyz_%1(%2); \
public xyz_%1(%2)
#define LOL 2
main()
{
print("xyz_"#LOL);
CallLocalFunction("xyz_LOL", "i", 345);
}
ABC:LOL(playerid)
{
printf("Called: %d",playerid);
return 1;
}
result
xyz_2
Called: 345
so called xyz_LOL not _2
Re: macro - Patrick - 19.12.2013
Quote:
Originally Posted by Jefff
but i want xyz_2 not xyz_LOL
|
I am confused, It won't call the local function because
xyz_2 is not created yet and I don't think it's possible converting
LOL > 2 using a
definition
pawn Код:
#include <a_samp>
#define ABC:%1(%2) \
forward xyz_%1(%2); \
public xyz_%1(%2)
#define LOL 2
main()
{
print("xyz_"#LOL);
CallLocalFunction("xyz_"#LOL, "i", 345);
}
ABC:2(playerid)
{
printf("Called: %d",playerid);
return 1;
}
Re: macro -
Jefff - 19.12.2013
ABC:LOL(playerid)
should be
forward xyz_2(playerid);
public xyz_2(playerid)
we must convert LOL to 2 but i don't know how, and i even don't know it's possible
@EDIT
Yes if you put 2 instead LOL it works
Re: macro - Patrick - 19.12.2013
Quote:
Originally Posted by Jefff
ABC:LOL(playerid)
should be
forward xyz_2(playerid);
public xyz_2(playerid)
we must convert LOL to 2 but i don't know how, and i even don't know it's possible
|
I think I made it
Pawn Code
pawn Код:
#include <a_samp>
#define ABC:%1(%2) \
forward xyz_%1(%2); \
public xyz_%1(%2)
main()
{
print("xyz_"#LOL);
CallLocalFunction("xyz_"#LOL, "i", 345);
}
ABC:LOL(playerid)
{
printf("Called: %d",playerid);
return 1;
}
#define LOL \
2
Result
You would not believe? Check it your self at http://slice-vps.nl:7070/
Did I? or I am just dreaming?
Re: macro -
Jefff - 19.12.2013
Its still xyz_LOL not xyz_2
Re: macro - Patrick - 19.12.2013
Quote:
Originally Posted by Jefff
Its still xyz_LOL not xyz_2
|
I have tried everything I can do, but it seems impossible, I'm going to sleep now, you had me there

, that was a challenge.