SA-MP Forums Archive
Split everything up and #include <everything>? - 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: Split everything up and #include <everything>? (/showthread.php?tid=614124)



Split everything up and #include <everything>? - TheBigFive - 04.08.2016

Ey ey boys and girls.

I just have a quick question. I want my codes to look as clean and good as possible, therefore I'm wondering if there's any cons by splitting up the code and include it all?

So I make one .inc for color defines, another one for other defines, one for stock functions, another one for variables, one for forwards and publics and so forth?

Will that work out just fine or isn't it worth it? Also wondering; if I include a command for instance, and that command is a zcmd command. That command is in another include, let's say commads.inc. Do I have to #include <zcmd> in that commands.inc file, or will it work since it is all included in the gamemode itself?

By the way, have a good day


Re: Split everything up and #include <everything>? - AndySedeyn - 04.08.2016

You shouldn't order your code by type but by functionality. It's still up to you, though.
As for your other question: no, you don't have to include zcmd in everything as long as zcmd is included in the main file above all the rest.


Re: Split everything up and #include <everything>? - TheBigFive - 04.08.2016

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
You shouldn't order your code by type but by functionality. It's still up to you, though.
As for your other question: no, you don't have to include zcmd in everything as long as zcmd is included in the main file above all the rest.
By functionality as for instance?
Okay so absolutely no cons as long as I know where I store it?


Re: Split everything up and #include <everything>? - AndySedeyn - 04.08.2016

Quote:
Originally Posted by TheBigFive
Посмотреть сообщение
By functionality as for instance?
Okay so absolutely no cons as long as I know where I store it?
For example: if you have a script that handles vehicles, bundle everything that has to do with vehicles in there.


Re: Split everything up and #include <everything>? - TheBigFive - 04.08.2016

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
For example: if you have a script that handles vehicles, bundle everything that has to do with vehicles in there.
Oh that's a good idea. Guess I'll be doing that instead


Re: Split everything up and #include <everything>? - Misiur - 04.08.2016

You can use
pawn Код:
#include "afile"
so you don't need to put files into includes folder as you can use relative paths and keep everything in gamemodes folder (and subfolders)


Re: Split everything up and #include <everything>? - SickAttack - 04.08.2016

Don't separate it into multiple files if you want it to "look clean and good as possible".

Hooks, missing a file, etc.


Re: Split everything up and #include <everything>? - TheBigFive - 04.08.2016

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Don't separate it into multiple files if you want it to "look clean and good as possible".

Hooks, missing a file, etc.
I don't get it?


Re: Split everything up and #include <everything>? - PrO.GameR - 04.08.2016

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Don't separate it into multiple files if you want it to "look clean and good as possible".

Hooks, missing a file, etc.
Keep your bad advice to yourself please, a hook looks more professional if you are going for the "look", provides amazing stuff, and splitting code into files provides for way easier debugging process as you can turn off or remove an entire system with two slashes ( // )

I hope you are not one of those guys who blab about their GM being 100k lines, when I can create a system way more advanced than theirs in 1000 lines.


also OT:
The only downside to having modular code is you sometimes need to change their order as to meet all the variable requirements (if you use for example VehI in admin file, you need to include admin file after veh file so it won't throw an error) and also you can't hook cmds, other than that there are lots and lots of pros to having a modular code.


Re: Split everything up and #include <everything>? - WhiteGhost - 04.08.2016

Nvrm..