Sharing Variables Across Includes
#1

There was a lot of saving code cluttering my mode, so I decided I would move all code that interacts with the database into an include file.
This is at the top the of gamemode.
pawn Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
I am trying to access that PlayerInfo variable in my include to save/load data. How do I do that? It was to my understanding that global variables are easily accessible throughout scripts, but my compiler whines that the variable is undefined in the include. Before you say, I have already looked at the scopes of variable, still haven't found a solution.
Reply
#2

Show me what you have in that include.
Reply
#3

Simply include your file after you have declared your global variables.

pawn Код:
new somevar;
#include <yourinclude>
When you include a file, the include line is replaced by the code in the include, so if you define global variables after including then they are not in scope of the include.
Reply
#4

Quote:
Originally Posted by FireCat
Посмотреть сообщение
Show me what you have in that include.
It's just like over 500 lines of irrelevant SQL code.

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Simply include your file after you have declared your global variables.

pawn Код:
new somevar;
#include <yourinclude>
When you include a file, the include line is replaced by the code in the include, so if you define global variables after including then they are not in scope of the include.
Learned something new today, thanks. It worked by the way.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)