Linking Pawn Files
#1

Is it possible to access my other pawn files from one pawn file ?? as in .. the main one can retrieve stuff from another pawn file..
Reply
#2

You can include all your other .pwn files into one.
pawn Код:
#include "other_file.pwn"
This will be compiled into one AMX file that has all the other pawn files included.
Reply
#3

Will Doing this only create ease in reading the script. or does it affect your script processing time or anything like that /
Reply
#4

Quote:
Originally Posted by JamesC
Посмотреть сообщение
You can include all your other .pwn files into one.
pawn Код:
#include "other_file.pwn"
This will be compiled into one AMX file that has all the other pawn files included.
no you can't

there's ways to retrieve variables and ways to retrieve functions from other scripts, which are you interested in? It might be better to convert one to an include or combine them in the one script
Reply
#5

It will not make a difference to performance as all the files are compiled into one amx file. Splitting up the gamemode just makes it easier for you to manage everything. For example, you can do the following:

pawn Код:
#include "gm_players"
#include "gm_timers"
#include "gm_cmds"
#include "gm_vehicles"
Reply
#6

Quote:
Originally Posted by cessil
Посмотреть сообщение
no you can't

there's ways to retrieve variables and ways to retrieve functions from other scripts, which are you interested in? It might be better to convert one to an include or combine them in the one script
Care to explain? As JamesC's way is correct and can be done like such.

@Original Poster: No, it will only affect the amount of time it takes to compile, which is of no worry.
Reply
#7

Quote:
Originally Posted by Bakr
Посмотреть сообщение
Care to explain? As JamesC's way is correct and can be done like such.

@Original Poster: No, it will only affect the amount of time it takes to compile, which is of no worry.
well then it'd be an include and should be named with the extension .inc, you could use the extension .pwn

you'd also have to edit the filterscript so it doesn't interfere with the current script, such as hooking duplicate uses of functions/callbacks or renaming them.
Reply
#8

Quote:
Originally Posted by cessil
Посмотреть сообщение
well then it'd be an include and should be named with the extension .inc, you could use the extension .pwn

you'd also have to edit the filterscript so it doesn't interfere with the current script, such as hooking duplicate uses of functions/callbacks or renaming them.
File Extension doesn't matters. As along as your writing the proper code onto the file without duplicate stuffs, you are good to go.
Reply
#9

Best way to do this is:

pawn Код:
#include "../gamemodes/larp.functions.pwn"
Of course you would name the "larp.functions" to whatever you have your file as. I currently do this and it works without flaws.
Reply
#10

that's fine for other languages that use classes and such, however for consistency and less problems you'd use .inc for includes.
it's fine if you're only going to keep the scripts to yourself, however if you're working in a team or releasing scripts and everyone else has to change their ways to match yours they might get annoyed instead of following what they'd normally do.
Reply
#11

Quote:
Originally Posted by cessil
Посмотреть сообщение
that's fine for other languages that use classes and such, however for consistency and less problems you'd use .inc for includes.
it's fine if you're only going to keep the scripts to yourself, however if you're working in a team or releasing scripts and everyone else has to change their ways to match yours they might get annoyed instead of following what they'd normally do.
For less problem? Like what? And when you say, "instead of following what they'd normally do," so YOU (as the person with the special extension) should do what you normally don't in those cases? Sounds absurd, after all, you'd be sharing the code.

Either way, I get what you mean as far as consistency and understand your concepts.
Reply
#12

I was planning on asking this question, since I've seen most gamemodes just having all code in one .pwn file, which is really annoying to read/understand.

What is the difference between a filterscript and an include file?
Reply
#13

Ok thanks, that clears it out. I'm still afraid of starting to write my first gamemode because I know there are so much more features in Pawn and in plugins that could save me a lot of time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)