Thread: About new
View Single Post
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-28-2019 , 23:41   Re: About new
Reply With Quote #2

Quote:
Originally Posted by undead52 View Post
In C we use char and int but instead of that, we use new in amxx and i want know something about that new. Why we use new ?
Pawn (the language used in AMX Mod X plugins) is a typeless language so you don't allocate memory based on a specific data type like you do in C. All 'cells' are signed 32-bit integers. There are tags that can be applied to variables that help functions change how they actually manipulate the data contained within them (effectively it's a way to say how the data is encoded into the 32-bit integer).


Quote:
Originally Posted by undead52 View Post
When we try to give value to global variables they only change at that local function but in amxx it doesnt, so is new actually a pointer ?
If you have a variable that only changes inside of a local function then it isn't a global variable.

If you declare a variable in the global scope then it's a global variable and can be changed from anywhere in that plugin (hence the world "global"). So, I guess you might be able to say it's kind of like having a pointer in C.

The most important part is that Pawn is not C. There may be some similarities in some syntax but that's just a convenience IMO (you can read up on the Pawn language if you're interested in the reasoning behind the language or more specifics about it).
__________________

Last edited by fysiks; 05-28-2019 at 23:45.
fysiks is offline