Quote:
Originally Posted by --kml--
1) What is the usefull of static?
2) when i put g_ to a code does it changes it to global or just labelling and same to sz does it make it string? or just labelling.
|
1. Using static variables
- The function is being called very frequently.
- If the variable requires a lot of memory allocation. Commonly used for large strings\arrays.
- If you wish the data to remain static [stored in memory between function calls].
2. Pawn does not have different data types so keep that in mind; the language uses only a 4-byte data type called a cell for everything. You can tag a variable with 'Float:' or 'bool:' which tells Pawn how to handle the data stored in the cell but regardless of tagging, it is still a 4-byte cell. There is no string type; a string is only an array of cells, each cell holding a character.
Using g_ to prefix a variable is just to remind the scripter [or others looking at your code] that the variable is declared as global [is accessible throughout the script]. This will also prevent accidental use of the incorrect variable if you use the same name for a variable that is declared global and within a function. sz does not do any type of variable declaration either, it is just to signify what kind of data is stored in the variable. You may also see people tag other variables such as
iValue [signifying integer] or
fValue [signifying float] or
bValue [signifying bool [true\false]]
__________________