Raised This Month: $51 Target: $400
 12% 

About new


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
undead52
Senior Member
Join Date: Dec 2016
Old 05-28-2019 , 02:31   About new
Reply With Quote #1

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 ?, 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 ?

Last edited by undead52; 05-28-2019 at 02:32.
undead52 is offline
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
undead52
Senior Member
Join Date: Dec 2016
Old 05-29-2019 , 08:51   Re: About new
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
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.
That's what i want to mean.
undead52 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode