SA-MP Forums Archive
Macro need little help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Macro need little help (/showthread.php?tid=599166)



Macro need little help - graef - 21.01.2016

PHP код:
#define _@CoreH_0 hook_main(){
#define _@CoreH_1 #if defined core_main core_main(); #endif                
#define _@CoreH_2 }#if defined _ALS_core_main #undef core_main #else #define _ALS_core_main #endif #define core_main hook_main
#define _coreHook _@CoreH_0_@CoreH_1_@CoreH_2
#define CMD:%1(%2) _coreHook forward cmd_%1(%2); public cmd_%1(%2) 
                        
CMD:test(playeridparams[]) {
    return 
1;

Basically, i need a macro for doing something like this:
Код:
hook_main() {
#if defined core_main
core_main();
#endif
}
#if defined _ALS_core_main
    #undef core_main
#else
    #define _ALS_core_main
#endif
#define core_main hook_main
forward cmd_test(playerid, params[]);
public cmd_test(playerid, params[]) {
    // Content
}
But i got little confused with this error
Код:
error 010: invalid function or declaration



Re: Macro need little help - brandypol - 21.01.2016

Quote:
Originally Posted by graef
Посмотреть сообщение
PHP код:
#define _@CoreH_0 hook_main(){
#define _@CoreH_1 #if defined core_main core_main(); #endif                
#define _@CoreH_2 }#if defined _ALS_core_main #undef core_main #else #define _ALS_core_main #endif #define core_main hook_main
#define _coreHook _@CoreH_0_@CoreH_1_@CoreH_2
#define CMD:%1(%2) _coreHook forward cmd_%1(%2); public cmd_%1(%2) 
                        
CMD:test(playeridparams[]) {
    return 
1;

Basically, i need a macro for doing something like this:
Код:
hook_main() {
#if defined core_main
core_main();
#endif
}
#if defined _ALS_core_main
    #undef core_main
#else
    #define _ALS_core_main
#endif
#define core_main hook_main
forward cmd_test(playerid, params[]);
public cmd_test(playerid, params[]) {
    // Content
}
But i got little confused with this error
Код:
error 010: invalid function or declaration
In which line exactly is the error located ?


Re: Macro need little help - graef - 21.01.2016

When i use
Код:
CMD:test(playerid, params[]) { 
    return 1; 
}
of course