SA-MP Forums Archive
Can I dynamically include a file? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Can I dynamically include a file? (/showthread.php?tid=134095)



Can I dynamically include a file? - iron_war_lord - 15.03.2010

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


Re: Can I dynamically include a file? - Mike Garber - 15.03.2010

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


Re: Can I dynamically include a file? - iron_war_lord - 15.03.2010

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


Re: Can I dynamically include a file? - Mike Garber - 15.03.2010

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.


Re: Can I dynamically include a file? - adsy - 15.03.2010

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


Re: Can I dynamically include a file? - Finn - 15.03.2010

No, you can't.

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


Re: Can I dynamically include a file? - iron_war_lord - 15.03.2010

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...


Re: Can I dynamically include a file? - Finn - 15.03.2010

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



Re: Can I dynamically include a file? - Jay_ - 15.03.2010

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.