View Single Post
Author Message
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 01-28-2015 , 17:00   Writing Include Files (.inc)
Reply With Quote #1

So I searched the alliedmodders wiki on sourcemod code writing and haven't found much about this subject. Even the search bar is returning a lot of false positives here. Basically I have a plugin I wrote that is huge, and I originally intended to merge it with another plugin. However, since the source code is massive, I'd rather write an .inc file and use #include <filename> in the other plugin for the sake of cleanliness and maintenance.

I've seen some discussion of include files in the wiki, but it's mostly geared to how to read them, not how to write them.

Suppose I have the following as a plugin (this is a purposely contrived example)

PHP Code:
new Handle:MyArray INVALID_HANDLE;
new 
String:Derp[100];
new 
counter;

public 
OnPluginStart()
{
    
MyArray CreateArray();
    
Derp "Hello";
    
counter ++;
}

public 
FetchArray(index)
{
    
counter ++;
    return 
GetArrayCell(MyArrayindex);

How can I make the FetchArray() function, the MyArray handle, the counter variable, and the Derp string accessible to the other plugins?

In other words, how do I write the inc file such that I can make all those variables/functions accessible to other plugins?

If there's any article or some tutorial on this that I managed to not find, I'd gladly read that (and ask any further clarifying questions here).

Thank you!
Potato Uno is offline