#1

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

You need to set 2 as a string i think "2" ..

or do somethin like "xyz_"#LOL""
Reply
#3

Same result isn't called, here is problem ABC:LOL(playerid) not in CallLocalFunction
Reply
#4

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

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

Quote:
Originally Posted by Jefff
Посмотреть сообщение
but i want xyz_2 not xyz_LOL

pawn Код:
//code
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;
}
Reply
#7

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
Reply
#8

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
Код:
xyz_LOL
Called: 345
You would not believe? Check it your self at http://slice-vps.nl:7070/
Did I? or I am just dreaming?
Reply
#9

Its still xyz_LOL not xyz_2
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)