SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Tutorials (https://forum.sa-mp.com/forumdisplay.php?f=70)
-   -   [Tutorial] Stop the abuse of stock! (https://forum.sa-mp.com/showthread.php?t=570635)

arakuta 13/04/2015 02:24 AM

Re: Stop the abuse of stock!
 
There is no point to say whether write stock in front of functions in GM's/FS's or not.

It's the same discussion doing

PHP Code:

MyItem() {
    
// Some shit


PHP Code:

MyItem() 
{
    
// Some shit


Its just estetic, and will provoke only infinite discussions.

Pottus 13/04/2015 02:26 AM

Re: Stop the abuse of stock!
 
Let me explain again....

Put #define Function at the top of your script
Then denote any functions with that...

Function Test1() {}
Function Test2() {}
Function Test3() {}
Function Test4() {}
Function Test5() {}

It won't do anything but make it easier to search for your function declaration.

hotspicytaco 13/04/2015 03:15 AM

Respuesta: Stop the abuse of stock!
 
Use comments instead.

n0minal 13/04/2015 03:54 AM

Re: Stop the abuse of stock!
 
Nice tutorial, will help a lot of beginners, and one more reason for don't use stock: your code will be faster, stocks are "lazy". If you want to do a smart and fast script its a nice way to start.

iZN 13/04/2015 07:01 AM

Re: Stop the abuse of stock!
 
Quote:

Originally Posted by Onfroi (Post 3429479)
I thought stock is faster as well, more optimized, it's not?

Quote:

Originally Posted by Gammix (Post 3429503)
No, i think bit slower than a function.

Quote:

Originally Posted by ipsLeon (Post 3429558)
Nice tutorial, will help a lot of beginners, and one more reason for don't use stock: your code will be faster, stocks are "lazy". If you want to do a smart and fast script its a nice way to start.

Adding that modifier won't make a difference, it will NEVER make your function faster nor slower. Your piece of code reflects the optimization and the speed of it. For example, calculating something very intensive in your function will obviously make that function "abit" slower than the normal one having nothing just a "printf()" statement for say.

@ipsLeon: I don't know if you implied the laziness of the scripter, or the speed comparison of "stock", I apologize if I quoted you wrongfully.

Quote:

Originally Posted by arakuta (Post 3429528)
There is no point to say whether write stock in front of functions in GM's/FS's or not.

It's the same discussion doing

PHP Code:

MyItem() {
    
// Some shit


PHP Code:

MyItem() 
{
    
// Some shit


Its just estetic, and will provoke only infinite discussions.

Sorry but discussion about indentation is not the same with something logical. This discussion is not something "esthetic" it is just a piece of advice for scripters and it won't provoke infinite discussion, it will just answer some unanswered questions.

arlindi 13/04/2015 07:56 AM

Re: Stop the abuse of stock!
 
Nicee but

i have stock in my server

how can i change to functions ?

Dignity 13/04/2015 08:02 AM

Re: Stop the abuse of stock!
 
Quote:

Originally Posted by arlindi (Post 3429642)
Nicee but

i have stock in my server

how can i change to functions ?

Remove "stock" from the function. And also, pretty sure a stock is still a function, lol. It just tells the compiler to ignore it and it makes it so the "symbol is never used" warning doesn't show up.

pawn Code:
stock myFunction(params)
{
}

to

pawn Code:
myFunction(params)
{
}

arlindi 13/04/2015 08:07 AM

Re: Stop the abuse of stock!
 
So withhout stock i can call function again like before ?

yugecin 13/04/2015 10:06 AM

Re: Stop the abuse of stock!
 
Quote:

Originally Posted by arlindi (Post 3429648)
So withhout stock i can call function again like before ?

Yes; the only difference that stock makes is that if you compile it, and you never called the function somewhere in your script, the compiler will not add it to the amx because it is not needed.

Niko_boy 13/04/2015 12:18 PM

Re: Stop the abuse of stock!
 
yep. nice tutorial i actually have never made any include but had used stock quite a bit for functions that i will be using within other functions of inter-related types.
Though best part of this tutorial is static stock. i never knew the exact areas where it should be used.


All times are GMT. The time now is 01:28 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.