13.09.2014, 14:26
Here is what I usually.
1.) Create public functions that can access the data I want.
2.) Create an include to access those functions.
Example.
In gamemode.
Your include.
Some people might recommend using PVars I am going to say that is a very lousy method and I will explain why. Any time that variable changes you need to set the PVar as well which is inefficient or replace all instances of that variable with Set/Get PVar functions which is again inefficient and you would also lose the benefit of error checking incorrect variable names.
@Stinged You will always want to use #define rather than a function.
1.) Create public functions that can access the data I want.
2.) Create an include to access those functions.
Example.
In gamemode.
pawn Код:
new SomeVariable;
forward GetSomeVariable();
public GetSomeVariable() { return SomeVariable; }
forward SetSomeVariable(value);
public SetSomeVariable(value) { SomeVariable = value; }
pawn Код:
#define GetSomeVariable() CallRemoteFunction("GetSomeVariable","")
#define SetSomeVariable(%0) CallRemoteFunction("SetSomeVariable","i",%0)
@Stinged You will always want to use #define rather than a function.