11.04.2012, 17:31
I think I'm on the right way.
My macro:
Trying to compile that gives me two errors but if I run the pawn preprocessor using the -l command line option of the pawn compiler I find the following in the generated .list file:
So I just have to find a way to remove the #. If I remove it in the macro I get that:
My macro:
Code:
#include <a_samp> #define MYCONSTANT_A 1 #define MYCONSTANT_B 2 #define MYCONSTANT_C 3 #define MyTest:%0(%1) forward TestFunc_#%0(%1); public TestFunc_#%0(%1) main(){} public OnGameModeInit() { AddPlayerClass(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); SetGameModeText("Test GM"); new funcName[32]; format(funcName, sizeof(funcName), "TestFunc_%d", MYCONSTANT_B); printf("Trying to call %s", funcName); CallLocalFunction(funcName, "dd", 123, 456); return true; } MyTest:MYCONSTANT_B(var1, var2) { printf("Executed MYCONSTANT_B (%d, %d)", var1, var2); }
Code:
forward TestFunc_#2(var1, var2); public TestFunc_#2(var1, var2) { printf("Executed MYCONSTANT_B (%d, %d)", var1, var2); }
Code:
forward TestFunc_MYCONSTANT_B(var1, var2); public TestFunc_MYCONSTANT_B(var1, var2) { printf("Executed MYCONSTANT_B (%d, %d)", var1, var2); }