Include inside an include
#1

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 ?
Reply
#2

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)
Reply
#3

You can.
Reply
#4

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.
Reply
#5

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.
Reply
#6

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

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
Reply
#8

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.
Reply
#9

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.
Reply
#10

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)