SA-MP Forums Archive
Include inside an include - 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: Include inside an include (/showthread.php?tid=600720)



Include inside an include - vassilis - 12.02.2016

Tittle says it all could i call an include inside other include?

I want to make an include which will have all my server global variables. Could i include it to another include i use? or it will cause errors ?


Re: Include inside an include - Sawalha - 12.02.2016

that's normal, you can, and no errors will be occurred as long as directories declaring in the script is correct. (if there were includes in various directories)


Re: Include inside an include - Ritzy2K - 12.02.2016

You can.


Re: Include inside an include - Sew_Sumi - 12.02.2016

Read up a lot on it.

You can, you just have to be careful, and plan a bit more.


It can however make things more confusing, so it is a double edged sword.


Re: Include inside an include - Vince - 12.02.2016

A file only gets included once unless you specifically tell the compiler to include it a second time. It is however not smart to split up your mode by declaration type (e.g. all variables in one include and all forward declarations in another). It is far more useful to split up by functionality, e.g. all house stuff in one include and all vehicle stuff in another.


Re: Include inside an include - vassilis - 12.02.2016

Thanks and one more question. Can i call for example onplayerdeath in 2 different includes but for different functionality?


Re: Include inside an include - PrO.GameR - 12.02.2016

Quote:
Originally Posted by vassilis
Посмотреть сообщение
Thanks and one more question. Can i call for example onplayerdeath in 2 different includes but for different functionality?
You need to hook callbacks to essentially have two OPD's that get called together, more info on that here:
https://sampforum.blast.hk/showthread.php?tid=570910


Re: Include inside an include - vassilis - 12.02.2016

Ok and how can i use global static inside an include? i want to move my admin command and calling it through an include and i am using some global statics inside the command and it is causing errors. I tried to create an include seperately only for these global statics and call it but i noticed it is causing errors calling an include which has global statics.


Re: Include inside an include - PrO.GameR - 12.02.2016

I really doubt you understand how static works, global statics are for that file and that file only, so if you have static blabla; in one of your includes you can't use it whereever you include it, if you want to use a static var it should be declared in same file.


Re: Include inside an include - vassilis - 12.02.2016

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
I really doubt you understand how static works, global statics are for that file and that file only, so if you have static blabla; in one of your includes you can't use it whereever you include it, if you want to use a static var it should be declared in same file.
Indeed, thanks!