AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Is ti possible to include .sp files? (https://forums.alliedmods.net/showthread.php?t=315783)

blackdevil72 04-24-2019 11:23

Is ti possible to include .sp files?
 
Hello!

First I've searched for that quite a lot and don't seem to have found any answer not in the sourcepawn/sourcemod doc nor on this forum. So if the answer is somewhere out there I'm sorry just please point me to the right direction. Thank a lot.

Cominf fom other language I've taken some habit.

For more easy reading and maintainance of my code I want to include various .sp in my main plugin file. Is that possible and how?

I tried to do:

PHP Code:

#include <sourcemod>
#include <myplugin_folder/myplugin_func.sp>
#include <myplugin_folder/myplugin_func2.sp> 

But when I try to compile I always end up with a "fatal error 183 can't read file".

Thank you again for your help.

eyal282 04-24-2019 11:27

Re: Is ti possible to include .sp files?
 
I think the file should go into scripting rather than scripting/include when including an .sp file but I am not sure in general as I prefer a large plugin.

farawayf 04-24-2019 11:39

Re: Is ti possible to include .sp files?
 
try #include "myplugin_folder/myplugin_func.sp"
instead of #include <myplugin_folder/myplugin_func.sp>

Powerlord 04-24-2019 15:38

Re: Is ti possible to include .sp files?
 
Quote:

Originally Posted by farawayf (Post 2648758)
try #include "myplugin_folder/myplugin_func.sp"
instead of #include <myplugin_folder/myplugin_func.sp>

I second this.

I like to break large plugins into multiple files based on a separation of concerns.

While it's not exactly well maintained anymore, the NativeVotes plugin is split into 3 files:
  • main plugin, which houses the main API declarations and general housekeeping
  • data storage functions which back the NativeVote methodmap
  • functions that vary based on the game engine in use

The data storage stuff was originally separate so that I could change out the implementation in a way that would be transparent to plugins that use the NativeVote API.

The third file probably should have been split into multiple different plugins instead and if I ever rewrite said plugin it probably will be, which would also allow it to support non-Valve games too.

ThatKidWhoGames 04-25-2019 12:57

Re: Is ti possible to include .sp files?
 
Quote:

Originally Posted by Powerlord (Post 2648786)
I second this.

I like to break large plugins into multiple files based on a separation of concerns.

While it's not exactly well maintained anymore, the NativeVotes plugin is split into 3 files:
  • main plugin, which houses the main API declarations and general housekeeping
  • data storage functions which back the NativeVote methodmap
  • functions that vary based on the game engine in use

The data storage stuff was originally separate so that I could change out the implementation in a way that would be transparent to plugins that use the NativeVote API.

The third file probably should have been split into multiple different plugins instead and if I ever rewrite said plugin it probably will be, which would also allow it to support non-Valve games too.

I second this as well, makes organization so much easier.

blackdevil72 04-25-2019 20:43

Re: Is ti possible to include .sp files?
 
Thank you every one that is what I was searching for. For the sake of any one searching this in the future here is a short resume of this:

PHP Code:

#include <something> 

Will search .inc files in the "include" folder

PHP Code:

#include <something.sp> 

wilt search .sp files in the "include" folder

PHP Code:

#include "something.sp" 

will search .sp files in the same folder

sdz 04-26-2019 21:57

Re: Is ti possible to include .sp files?
 
includes inside of angle brackets (<this>) should be used for compiler specific inclusion or something like that, this is a c and c++ thing
anything else like externals, go enclosed in quotations like "this.sp"

although im fairly sure it will also include .inc files if you do like #include <includefile>


All times are GMT -4. The time now is 15:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.