[Tutorial] Stop the abuse of stock!
#1

What is stock?
The stock keyword, like const, is a modifier that tells the compiler to hide a variable or a function if it is not used. Contrary to popular believe in the SA-MP community, stock is not a requirement. Functions do not require a special keyword in Pawn. The word "stock" is not interchangeable with the word "function" either.

Quote:
Originally Posted by random scripting help topic
Hi, I'm writing this stock ...
No, you're writing a function!

When to use stock?
  • I am writing a gamemode.
    • You don't need the stock keyword!
  • I am writing a filterscript.
    • You don't need the stock keyword!
  • I am writing an include.
    • Is the function or variable required to be used in a gamemode or filterscript? If yes, do not use the stock keyword. Do not use any keyword at all.
    • Is the function or variable for internal use only? If yes, use static.
    • Is the function or variable for internal use only, but is there a chance that it may not be used (conditional compiling)? If yes, use static stock
    • If none of the above are met, only then is it appropriate to use stock.
Removing the stock modifier from ALL functions in your gamemode or filterscript is a good way to start. If you receive a few "symbol is never used" warnings after doing so then that means your gamemode is cluttered. It means you have functions which do nothing but waste your scroll wheel. Consider removing those functions or move them to an appropriate include file.
Reply


Messages In This Thread
Stop the abuse of stock! - by Vince - 12.04.2015, 09:26
Re: Stop the abuse of stock! - by Glossy42O - 12.04.2015, 10:12
Re: Stop the abuse of stock! - by FernandoLight - 12.04.2015, 10:14
Re: Stop the abuse of stock! - by Emmet_ - 12.04.2015, 12:04
AW: Stop the abuse of stock! - by Mellnik - 12.04.2015, 12:05
Re: Stop the abuse of stock! - by Patrick - 12.04.2015, 16:12
Re: Stop the abuse of stock! - by Abagail - 12.04.2015, 18:06
Re: Stop the abuse of stock! - by iZN - 12.04.2015, 21:17
Re: Stop the abuse of stock! - by Michael@Belgium - 12.04.2015, 21:25
Re: Stop the abuse of stock! - by Vince - 12.04.2015, 21:30
Re: Stop the abuse of stock! - by iZN - 12.04.2015, 21:31
Re: Stop the abuse of stock! - by Michael@Belgium - 12.04.2015, 21:37
Re: Stop the abuse of stock! - by yugecin - 12.04.2015, 22:14
Re: Stop the abuse of stock! - by EiresJason - 12.04.2015, 23:42
Re: Stop the abuse of stock! - by Onfroi - 13.04.2015, 00:00
Re: Stop the abuse of stock! - by Gammix - 13.04.2015, 01:18
Re: Stop the abuse of stock! - by Abagail - 13.04.2015, 01:48
Re: Stop the abuse of stock! - by EiresJason - 13.04.2015, 01:59
Re: Stop the abuse of stock! - by Pottus - 13.04.2015, 02:11
Re: Stop the abuse of stock! - by Abagail - 13.04.2015, 02:21
Re: Stop the abuse of stock! - by arakuta - 13.04.2015, 02:24
Re: Stop the abuse of stock! - by Pottus - 13.04.2015, 02:26
Re: Stop the abuse of stock! - by iZN - 13.04.2015, 07:01
Re : Stop the abuse of stock! - by S4t3K - 13.04.2015, 15:31
AW: Stop the abuse of stock! - by Kaliber - 14.04.2015, 00:48
Re: AW: Stop the abuse of stock! - by Ahmad45123 - 17.04.2015, 23:32
Re: Re : Stop the abuse of stock! - by Bakr - 18.04.2015, 06:25
Re : Stop the abuse of stock! - by S4t3K - 18.04.2015, 18:18
AW: Re : Stop the abuse of stock! - by Kaliber - 25.04.2015, 12:51
Re: Stop the abuse of stock! - by vannesenn - 01.05.2015, 22:16
Re: Stop the abuse of stock! - by ThePhenix - 02.05.2015, 00:16
Re: Stop the abuse of stock! - by Jay_ - 03.05.2015, 14:07
Re: Stop the abuse of stock! - by Jonny5 - 18.05.2015, 00:50
Re: Stop the abuse of stock! - by Freezo - 03.09.2015, 19:25
Re: Stop the abuse of stock! - by Onfroi - 06.09.2015, 17:49
Re: Stop the abuse of stock! - by Variable™ - 06.09.2015, 17:54
Re: Stop the abuse of stock! - by SickAttack - 06.09.2015, 17:55
Re: Stop the abuse of stock! - by Tamer - 06.09.2015, 18:07
Re: Stop the abuse of stock! - by Darrenr - 15.09.2015, 11:15
Re: Stop the abuse of stock! - by DarkLored - 15.09.2015, 18:54
Re: Stop the abuse of stock! - by introzen - 04.04.2016, 16:29
Re: Stop the abuse of stock! - by Puppy - 05.04.2016, 00:11
Re: Stop the abuse of stock! - by Arastair - 05.04.2016, 03:11
Re: Stop the abuse of stock! - by Itzhak E. - 07.04.2016, 12:47
Re: Stop the abuse of stock! - by Sew_Sumi - 07.04.2016, 13:00
Re: Stop the abuse of stock! - by Sasino97 - 17.04.2016, 20:28
Re: Stop the abuse of stock! - by iKevin - 07.06.2016, 12:15
Re: Stop the abuse of stock! - by vannesenn - 07.06.2016, 16:36
Re: Stop the abuse of stock! - by LockedLucas - 07.06.2016, 18:26
Re: Stop the abuse of stock! - by TwinkiDaBoss - 07.06.2016, 19:04
Re: Stop the abuse of stock! - by Private200 - 07.06.2016, 19:16
Re: Stop the abuse of stock! - by SickAttack - 10.06.2016, 16:44
Re: Stop the abuse of stock! - by vannesenn - 10.06.2016, 18:47
Re: Stop the abuse of stock! - by Konstantinos - 10.06.2016, 18:56
Re: Stop the abuse of stock! - by Stinged - 11.06.2016, 10:12
Re: Stop the abuse of stock! - by SickAttack - 11.06.2016, 13:59
Re: Stop the abuse of stock! - by PeanutButter - 11.02.2017, 10:36
Re: Stop the abuse of stock! - by HydraHumza - 11.02.2017, 10:54
Re: Stop the abuse of stock! - by iLearner - 11.02.2017, 11:36
Re: Stop the abuse of stock! - by ATomas - 22.02.2017, 12:59
Re: Stop the abuse of stock! - by organe. - 22.02.2017, 13:13
Re: Stop the abuse of stock! - by BiosMarcel - 22.02.2017, 21:49
Re: Stop the abuse of stock! - by iKarim - 23.02.2017, 05:08
Re: Stop the abuse of stock! - by Kwarde - 16.10.2019, 20:49
Re: Stop the abuse of stock! - by [FMJ]PowerSurge - 04.05.2020, 02:57

Forum Jump:


Users browsing this thread: 1 Guest(s)