[Tutorial] Stop the abuse of stock!
#41

Great! Didn't know this. Been taught everything from this community including Stock, so now I'll get rid of it.

Does the include part apply for ".pwn" files as well as ".inc" files? I use .pwn's as #includes.
Reply
#42

Quote:
Originally Posted by introzen
Посмотреть сообщение
Great! Didn't know this. Been taught everything from this community including Stock, so now I'll get rid of it.

Does the include part apply for ".pwn" files as well as ".inc" files? I use .pwn's as #includes.
You shouldn't need stock if you organize your gamemode through .pwn include files(for things such as a housing system, a vehicle system, etc). If you are using an include that has certain functions available such as an include displaying additional player data(such as when they joined, their name using a variable rather than through the GetPlayerName function, etc) then most of the time a stock is appropriate since the function isn't going to always be used.
Reply
#43

Didn't know that, thanks vince
Reply
#44

Any other way to return a string other than using stock?

P.s good tut.
Reply
#45

Quote:
Originally Posted by Itzhak E.
Посмотреть сообщение
Any other way to return a string other than using stock?
Damn, if you'd read it, they're not stocks but normal functions... Functions can return anything.

You're calling them stocks, when they are actually functions, and thus, your usage of stock is more than likely incorrect.
Reply
#46

I always compared the stock keyword in pawn to the @SuppressWarnings("unused") annotation in Java.
Reply
#47

Quote:
Originally Posted by Michael@Belgium
View Post
I like to use stock, it's short to write and easy to use. Don't tell me what to do. If it works .. it works.
So you're basicly saying to always write publics and forward them ? I don't like to type much.
You are an idiot. Stock tells the compiler that the function may also not be used and compiler takes more time to compile the script.
Reply
#48

Quote:
Originally Posted by KevinExec
View Post
You are an idiot. Stock tells the compiler that the function may also not be used and compiler takes more time to compile the script.
Does stock improve performance on server? I don't care on compiler
Reply
#49

Muito ъtil, parabйns.
Reply
#50

Quote:
Originally Posted by vannesenn
View Post
Does stock improve performance on server? I don't care on compiler
Nope

Regarding about this entire thing, I preffer to place stock at almost every function due to simple reason and that is searching. Nothing else really
Reply
#51

Quote:
Originally Posted by TwinkiDaBoss
View Post
Nope

Regarding about this entire thing, I preffer to place stock at almost every function due to simple reason and that is searching. Nothing else really
No?

Quote:
Originally Posted by vannesenn
View Post
Does stock improve performance on server? I don't care on compiler
Yes, it does. Just check main thread and it explains you why.

Quote:

It means you have functions which do nothing but waste your scroll wheel.

You are going to have a fresh script with less functions, faster gamemode loading.
Reply
#52

Quote:
Originally Posted by KevinExec
View Post
You are an idiot. Stock tells the compiler that the function may also not be used and compiler takes more time to compile the script.
Negative, 1,326 stock functions compiles in 0.2 seconds on my PC. The difference is vastly MINOR, most people hardly have 300 functions in their gamemodes. Not to mention that 1,066 stock functions (random number, tested however) compiles in 0.1 seconds on my end.



http://pastebin.com/KB8zrs35

Quote:
Originally Posted by Private200
View Post
No?



Yes, it does. Just check main thread and it explains you why.



You are going to have a fresh script with less functions, faster gamemode loading.
Also negative, it's useless to point out things without prior testing. It definitely WON'T be faster, stock functions are left out of the .amx file (the file which the server uses on execution), as if they didn't exist in the source code (.pwn file).

To the date, there is no proof that using "stock" has any impact on the server's performance whatsoever, so why bother giving false claims out? Show your evidence instead.

With or without using "stock", your server WILL perform the same, and even if you have a "cluttered" gamemode (source code). However, whether having a cluttered gamemode or not depends on the programmer. I use the keyword "stock" when creating functions and in dispute of that, I do not leave unused functions laying around.

So, yeah... I do agree that when creating a function (in gamemodes and filterscripts) the keyword "stock" is not a requirement, though. BUT, when there are no differences between using it or not (as long as the user knows the keyword's purpose/use), then people should be able to use "stock" without being told otherwise.

I would also like to say something about this:
Quote:
Originally Posted by Pottus
View Post
Why even do that? Just put #define Function at the top of your script then.

Ex.
Function Test();
A lot of people prefer to use "stock" instead of a define due to terms of ease and laziness (for people that uses "stock" when writing functions). I don't want to be bringing/passing that define all around the place.

And dispute the fact that there is no difference in using stock or that define, so why should people do that anyway?
Reply
#53

Quote:
Originally Posted by Private200
View Post
No?



Yes, it does. Just check main thread and it explains you why.



You are going to have a fresh script with less functions, faster gamemode loading.
Why then we should use public? I don't understand now anything.
Reply
#54

Quote:
Originally Posted by vannesenn
View Post
Why then we should use public? I don't understand now anything.
You miss the main point of this thread. stock is not a MUST when writing a function as many people still think. The only thing it does is hiding the warning if the function is not used anywhere in your script.

You shouldn't use public functions without a reason as well. Use public functions only if it is called by a timer, Call Local/Remote Function or a callback specified to some functions from plugins such as mysql_tquery or mysql_pquery.
Reply
#55

A lot of people think normal functions are actually called stock.
stock is a word you place to hide the 'unused' warning.

It doesn't only work in functions, it also works in arrays and variables.
Code:
new stock Unused_Array[50];
Reply
#56

It doesn't just only hide the warning, it also leaves unused functions out of the compiled source as if it didn't exist.

Functions with stock in front of them can/are called stock functions.
Reply
#57

Quote:
Originally Posted by Vince
View Post
What is stock?
Baby don't hurt me.
Reply
#58

Quote:
Originally Posted by PeanutButter
View Post
Baby don't hurt me.
You bump the old topic
Reply
#59

Quote:
Originally Posted by Humza
View Post
You bump the old topic
I wouldnt really call it a bump, or any kind of rule break, however for the reason he did it & what he posted, is indeed unappropriated.
Reply
#60

From pawn documentation (https://www.compuphase.com/pawn/pawn.htm page 86)
Quote:

Stockfunctions A “stock” function is a function that the PAWN parser must “plug into” the program when it is used, and that it may simply “remove” from the program (without warning) when it is not used.

Use alright stock continues happy
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)