Can I dynamically include a file?
#1

I've been working on quite a complicated .inc, and I have been worndering how to include a .inc to it if a certain statement is true?

like:
Код:
if(JockyRider == 1)
{
  #include <cash>
}
Would that work
Reply
#2

Is it that hard to try it? I mean the code is done, just put It in and try It.
Reply
#3

Quote:
Originally Posted by mavtias
Is it that hard to try it? I mean the code is done, just put It in and try It.
It doesn't work, I tried it already, I'm asking if there is any possible way to get the same result as above
Reply
#4

Quote:
Originally Posted by Zinglish
Quote:
Originally Posted by mavtias
Is it that hard to try it? I mean the code is done, just put It in and try It.
It doesn't work, I tried it already, I'm asking if there is any possible way to get the same result as above
Well that wasn't what you said.
Reply
#5

why dont you just include them all and add your line to check within the files themselves
Reply
#6

No, you can't.

What's wrong in including it on top of the script?
Reply
#7

Quote:
Originally Posted by Finn
No, you can't.

What's wrong in including it on top of the script?
If I distribute my .inc, if the scripter does not have the include (Which is not neccessary, only if wanted) then the scripter has to go find these includes...
Reply
#8

You can always do like other include files (this is taken from ZCMD):
pawn Код:
#if defined _zcmd_included
    #endinput
#endif
#define _zcmd_included
Obviously what you want to do is the opposite, in some other inc:
pawn Код:
#if !defined _zcmd_included
    #endinput
#endif
Edit:
If you want to give compiler-error when scripter doesn't have your include:
pawn Код:
#if !defined _zcmd_included
    #error "You don't have the ZCMD include files"
#endif
Reply
#9

The only way to do this is to use a preprocessor define. The script has to be compiled for the server to read it, therefore including the pawn file when an expression is true which may not necessarily be the case when compiling won't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)