View Single Post
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-07-2023 , 02:42   Re: What is the difference in the way these variables are declared?
Reply With Quote #4

"new" just creates a new variable of local scope. If it's used on the top-level, it's effectively a global variable with respect to the plugin's own code. When declared in this scope, there is no runtime execution happening so only constant expressions are allowed. When you create a variable in a local scope that is processed at runtime (like inside of a function) then you can initialize it with any normal code.

"new", "static", and "public" are mutually exclusive expressions so I'm not sure why you have any combination of those. References:

Quote:
Originally Posted by Pawn Language Guide
To declare a global variable as static, replace the keyword new by static.
Quote:
Originally Posted by Pawn Language Guide
Global “simple” variables (no arrays) may be declared “public”
in two ways:
⋄ declare the variable using the keyword public instead of new;
...
__________________

Last edited by fysiks; 10-07-2023 at 02:45.
fysiks is offline