Raised This Month: $ Target: $400
 0% 

PUBLIC and STOCK


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 02-28-2005 , 18:42   PUBLIC and STOCK
Reply With Quote #1

whats the diff between PUBLIC and STOCK? im feeling really noobish by askin this question..
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 02-28-2005 , 19:03  
Reply With Quote #2

You should not feel noobish for not knowing this information...there are many many other things you can feel noobish about.

I believe there are five types of functions in SMALL for AMXX.

Normal - functions w/o a definition
ex.
Code:
  func_area(Float:length,Float:width){return (length*width)}

Used:
When you want a function no one else can call, or its basically an inline (could simply be incorporated into other functions, but easier to make it its own)

Public - functions that are "public", that is, other plugins and AMXX itself can communicate through them

ex.
Code:
public func_area(Float:length,Float:width){return (length*width)}

Used:
Functions used for commands, tasks, etc etc. They are "public" to other AMXX plugins and such. I think they use a little more CPU and such.

Native - A function provided by a module or AMXX itself. It is "native" to the plugin that is to say, you do not have to remake it in SMALL.

ex.
Code:
replace(source[],with[],len)

Stock - the closest to "inlines" from C++. These are like natives, but you build them yourself. I believe that when you mark a function as stock, every time you use that function, the place where you used it is actually REPLACED by the stock function.

ex.
Code:
stock func_area(Float:length,Float:width){return (length*width)}

Now, every declaration of "func_area" is replaced by "length*width" or something similar. I might be wrong on that one.

The upshot is, stocks are not checked, and work like natives, but you make them on your own.

Forwards - Just like publics, but called when AMXX wants them to be called.

ex:
Code:
public client_prethink(id)

Those are the five, general function types in SMALL/AMXX scripting...I think. I could be wrong. Anyway, thats the difference between public and stock. One is open to all of AMXX to call, one is used as sort of a memory saving manuever.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 03-03-2005 , 16:23  
Reply With Quote #3

Some corrections:

1) public functions are just functions that AMXX can see.
2) The difference between "normal" and stock functions is that stock functions are not included in the output file if the function is unused
3) The forward declarations just tell the compiler which prototype a function should have
__________________
hello, i am pm
PM is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-03-2005 , 16:49  
Reply With Quote #4

Right....right...
I forgot exactly what the stock would do to be similar to inlines, and thats it.

But anyway, I think he understood.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
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 14:11.


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