event define produces invalid function error
#1

Hello. I am working on a system where you can dynamically create "event" type functions. This is what I have however it gives an invalid function error. As this is something ****** seems to do I know there is a possible way to get it working as such but I just can't think of a probable method of doing so.

pawn Код:
#include <a_samp>
#define EVENT_PLAYER{%0,%1,%2,%3} public OnPlayer%0(%0, %2, %3)

EVENT_PLAYER("EnterVehicle", playerid, vehicleid, ispassenger)
{
    printf("Player Event: Enter Vehicle - %d %d %d", playerid, vehicleid, ispassenger);
    return 1;
}
Reply
#2

Alright, that got rid of that issue however when I am getting a weird symbol is never used error stating that "EVENT_PLAYER" isn't used, however it clearly is right there so I am doubting that this method will even properly call the public. And also, what would be the best method of having one define parameter for all possible parameters(ofcourse excluding the function name) which in this case is playerid, vehicleid and ispassenger.
Reply
#3

I just checked the code ,remove the quotes from the first parameter,but i got a better idea for detecting events and also printing them,if you want me to post it then reply.
Reply
#4

Its not about "detecting events", it's mainly about an organized way of calling them and I already did that however the warning is still persistent. The only thing I don't understand is how "EVENT_PLAYER" can be unused, when it's used clearly - I also am stumped about an efficient use of having one parameter(%number) in the define to represent all the possible parameters, and at the same time call them properly to the public.

The only method of doing this I can imagine would be to call a public, or stock function which would directly call the callback / function based on the parameters given however I don't know how I can get the parameter specifiers for use in CallLocalFunction - and aswell this would probably not be a very efficient method of coding.
Reply
#5

The warning occurs because the line simply does not match your define pattern (using brackets () instead of braces {}). So you have just created yourself a function called EVENT_PLAYER which is never called and thus, according to the compiler, never used.

That said, I hardly think that this is "more organized". If anything, I think it makes things less organized. Besides, not every callback has 3 parameters so this thing can't be used for something like ExitVehicle.
Reply
#6

Thats why i told you that i got a better way,because your parameters wont match all of the callbacks.
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
That said, I hardly think that this is "more organized". If anything, I think it makes things less organized. Besides, not every callback has 3 parameters so this thing can't be used for something like ExitVehicle.
That's what I've said in my last few posts:
Quote:
Originally Posted by Puppy
And also, what would be the best method of having one define parameter for all possible parameters(ofcourse excluding the function name) which in this case is playerid, vehicleid and ispassenger.
Quote:
Originally Posted by Puppy
I also am stumped about an efficient use of having one parameter(%number) in the define to represent all the possible parameters, and at the same time call them properly to the public.
And I don't know how I didn't see that I used brackets, that part is my fault.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)