Including files
#1

This one has me scratching my head but I bet it's obvious.

I have my main gamemode file in my gamemodes folder which gets compiled. I have a folder in my gamemodes folder called "functions", with different pwn files for different types of functions. I also have a file called "functions.pwn" in my gamemodes folder which just includes all the files from the functions folder. But for some reason, when I include "functions.pwn" in my main gamemode file, it reads the file fine but can't read the individual functions files in the "functions" folder.

Is it not possible to include files on multiple levels like this?
Reply
#2

It works fine for me, does your code look similar to this:
gamemodes - gamemode.pwn
Код:
#include "functions.pwn"
gamemodes - functions.pwn
Код:
#include "functions/function_one.pwn"
gamemodes/functions - function_one.pwn
Код:
stock ClearChatForPlayerID(playerid)
{
    for(new i; i != 75; i++)
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "");
	}
	return 1;
}
Edit: Are you aware when including files that are in your gamemodes folder and not in the pawno/include folder that you should use #include "include_name.pwn" with quotation marks instead of #include <include_name>
Reply
#3

Quote:
Originally Posted by MEW273
Посмотреть сообщение
It works fine for me, does your code look similar to this:
Yeah, it does.

main.pwn:
Код:
#include "functions.pwn"
functions.pwn:
Код:
#include "functions/connections.pwn"
#include "functions/time.pwn"
Then connections.pwn and time.pwn contain functions relating to their names.
Reply
#4

Are you receiving any errors when you compile? Or are you just not able to use these functions?
Reply
#5

I receive error 100 (cannot read from file).
Reply
#6

You should check that the file (connections.pwn & time.pwn) and folder (definitely functions with an 's'?) names are spelled correctly.
Reply
#7

I don't know what causes your specific problem as the code is correct, but do not use "/" for folder separation, otherwise you'll get really weird results with subfolders and nested includes in future.

More detailed info: https://github.com/Misiur/YSI-Includ...Include-Guards
Reply
#8

Quote:
Originally Posted by Misiur
Посмотреть сообщение
I don't know what causes your specific problem as the code is correct, but do not use "/" for folder separation, otherwise you'll get really weird results with subfolders and nested includes in future.

More detailed info: https://github.com/Misiur/YSI-Includ...Include-Guards
Ah, thanks for that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)