24.01.2020, 20:52
#emit is a way to write in-line P-Code/Bytecode (Pawn's compiled "Assembly" so to speak).
This is often done to either bypass limitations of the language, obsfucate code, increase execution speed (by hand-assembling specific code faster than the compiler would) or all of the above.
In this case I think it is bypassing a limitation of how arguments are managed by the Pawn language, as it seems to be pushing a variable amount of arguments to the stack in that while, which would not be possible by writing it properly.
In this portion of the code, the parameters "text", "144", "str", and "8" are pushed to the stack to be used as variables, before doing a system call to the sa-mp server to run the "format" function with these.
The Pawn Language Official Document by CompuPhase has a small bit where these preprocessor directives are explained, including #emit
TL-DR: All of those emits are just for a format(), but it cannot be done without emits as it was done this way in order to be able to send a variable amount of arguments
This is often done to either bypass limitations of the language, obsfucate code, increase execution speed (by hand-assembling specific code faster than the compiler would) or all of the above.
In this case I think it is bypassing a limitation of how arguments are managed by the Pawn language, as it seems to be pushing a variable amount of arguments to the stack in that while, which would not be possible by writing it properly.
Quote:
#emit PUSH.S text #emit PUSH.C 144 #emit PUSH.C str #emit PUSH.S 8 #emit SYSREQ.C format |
The Pawn Language Official Document by CompuPhase has a small bit where these preprocessor directives are explained, including #emit
TL-DR: All of those emits are just for a format(), but it cannot be done without emits as it was done this way in order to be able to send a variable amount of arguments