Hi,
I'm a little bit confused about how a variable is declared and instantiated.
From what I understand, variables can be declared in 3 different ways (example using a StringMap variable):
1. new Float:myFloat
2. decl Float:myFloat
3. Float myFloat
All 3 methods declare a new variable named "myFloat".
Method 1 declares and instantiates myFloat, meaning that there is no previous data in this variable (data is set to 0, for other types everything would be 0, false etc).
Method 2 declares myFloat, but there may be "leftover" data. So depending on what is previously in computer memory, there may be some data in the variable. This can only be done in a local scope (inside a function).
Method 3 ???
The difference between method 1 and 2 are okay I guess, but what's the difference between method 1 and 3?
Is the data set to 0 when using method 3?
If I want a global variable in my plugin, should I use method 1 or 3?
Code:
#include <sourcemod>
Float myGlobalVariable;
public void OnPluginStart()
{
myGlobalVariable = 0.0;
}