Quote:
Originally Posted by Hyper Nova
the problem is that if file1.sinc and file2.sinc include file1.vinc then gvar2 and gvar will be defined twice.
it will couse the error : sombol already defined "gvar" ( and gvar2 )
what i want to know is how to make include what do not couse that error.
i need to use those variables in all inc files ( and in sma ofcourse )
|
I'm gonna be honest....that was a long post and i only read a bit of it. Answer to above quoted question:
The variables are defined IN THAT CLASS ONLY and do not effect anything outside of it. You can use cheeseGraterC as a var in every single plugin on a server and it will act independently in each plugin. Variables are block specific.....for instance you can define a global (for use in all of your plugin) and use it throughout all your functions and loops and blocks.
ex:
PHP Code:
#include <amxmodx>
new g_cheeseGraterC = 15 // This is a global var: usable anywhere in your plugin
public plugin_init() {
register_plugin("Your Mom", "Eats", "Vegetables")
new funcVar = 13 // This is a function-specific var: usable ONLY within the function
new varW = funcVar // This will effectively set varW as 13
}
public function1() {
new varW = g_cheeseGraterC // This will take your global and set it to a new variable
// varW can still be defined; it is separate from varW in plugin_init
new varK = funcVar // This WILL NOT WORK. funcVar was NOT defined within this function's scope; thus will give you an error
}
I hope that helped a little.