Including files - 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: Including files (
/showthread.php?tid=647259)
Including files -
dicknyson - 02.01.2018
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?
Re: Including files -
MEW273 - 02.01.2018
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>
Re: Including files -
dicknyson - 02.01.2018
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.
Re: Including files -
MEW273 - 02.01.2018
Are you receiving any errors when you compile? Or are you just not able to use these functions?
Re: Including files -
dicknyson - 02.01.2018
I receive error 100 (cannot read from file).
Re: Including files -
MEW273 - 02.01.2018
You should check that the file (connections.pwn & time.pwn) and folder (definitely function
s with an 's'?) names are spelled correctly.
Re: Including files -
Misiur - 02.01.2018
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
Re: Including files -
dicknyson - 02.01.2018
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.