[Question] How to share the same function?
#1

There are 2 files included:

test1.inc
PHP Code:
/*
// imitation lack of function
#if !defined  debug_1
stock debug_1() {
    print("debug file 1");
}
#endif*/ 
test2.inc
PHP Code:
#if !defined  debug_1
stock debug_1() {
    print(
"debug file 2");
}
#endif 
gamemode:
PHP Code:
#include <a_samp>
#include <test1> 
#include <test2>
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
    
    print(
"sta");
    
debug_1();
    print(
"eof");

One function debug_1();

Question: What are the methods of using directives? Condition: You can not delete function physically. One of the functions can be commented out and must operate the other

My method for some reason, causes an error:
HTML Code:
[12:35:10] sta
[12:35:10] Script[gamemodes/new.amx]: Run time error 6: "Invalid instruction"
Add: Method found. Decided:

test1.inc > If not available
PHP Code:
#if !defined  debug_1
#define debug_1 new_debug_1
stock debug_1() {
    print(
"debug file 1");
}
#endif 
test2.inc < used functions
PHP Code:
#if !defined  debug_1
#define debug_1 new_debug_1
stock debug_1() {
    print(
"debug file 2");
}
#endif 
gamemode:
PHP Code:
#include <a_samp>
#include <test1> //faworite functions
#include <test2> //alternative functions
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
    
    print(
"sta");
    
debug_1();
    print(
"eof");

Print if all included:
Code:
sta
debug file 1
eof
Print if one #include <test2> included:
Code:
sta
debug file 2
eof
Reply


Messages In This Thread
[Question] How to share the same function? - by Logofero - 14.05.2015, 11:50
Re: [Question] How to share the same function? - by ikkentim - 14.05.2015, 13:07
Re: [Question] How to share the same function? - by Logofero - 14.05.2015, 17:33
Respuesta: [Question] How to share the same function? - by admantis - 14.05.2015, 18:17

Forum Jump:


Users browsing this thread: 1 Guest(s)