SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 13/04/2015, 03:24 AM   #21
arakuta
High-roller
 
arakuta's Avatar
 
Join Date: Jan 2011
Location: Itajaí - Brazil
Posts: 2,184
Reputation: 184
Default 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.
arakuta is offline   Reply With Quote
Old 13/04/2015, 03:26 AM   #22
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,851
Reputation: 1312
Default 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.
Pottus is offline   Reply With Quote
Old 13/04/2015, 04:15 AM   #23
hotspicytaco
Huge Clucker
 
hotspicytaco's Avatar
 
Join Date: Dec 2011
Location: Taco Bell
Posts: 230
Reputation: 44
Default Respuesta: Stop the abuse of stock!

Use comments instead.
hotspicytaco is offline   Reply With Quote
Old 13/04/2015, 04:54 AM   #24
n0minal
Banned
 
Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,054
Reputation: 784
Default 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.
n0minal is offline   Reply With Quote
Old 13/04/2015, 08:01 AM   #25
iZN
High-roller
 
Join Date: Jun 2010
Posts: 2,378
Reputation: 569
Default Re: Stop the abuse of stock!

Quote:
Originally Posted by Onfroi View Post
I thought stock is faster as well, more optimized, it's not?
Quote:
Originally Posted by Gammix View Post
No, i think bit slower than a function.
Quote:
Originally Posted by ipsLeon View Post
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 View Post
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.
__________________
iZN is offline   Reply With Quote
Old 13/04/2015, 08:56 AM   #26
arlindi
Banned
 
Join Date: May 2014
Posts: 870
Reputation: 27
Default Re: Stop the abuse of stock!

Nicee but

i have stock in my server

how can i change to functions ?
arlindi is offline   Reply With Quote
Old 13/04/2015, 09:02 AM   #27
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,636
Reputation: 1179
Default Re: Stop the abuse of stock!

Quote:
Originally Posted by arlindi View Post
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)
{
}
Dignity is offline   Reply With Quote
Old 13/04/2015, 09:07 AM   #28
arlindi
Banned
 
Join Date: May 2014
Posts: 870
Reputation: 27
Default Re: Stop the abuse of stock!

So withhout stock i can call function again like before ?
arlindi is offline   Reply With Quote
Old 13/04/2015, 11:06 AM   #29
yugecin
Big Clucker
 
Join Date: Oct 2009
Location: Belgium
Posts: 81
Reputation: 82
Default Re: Stop the abuse of stock!

Quote:
Originally Posted by arlindi View Post
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.
__________________
robin_be
yugecin is offline   Reply With Quote
Old 13/04/2015, 01:18 PM   #30
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,338
Reputation: 138
Default 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.
__________________
nope[IMG]http://*******/1r0SOkH_[/IMG]
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
G abuse Cerealguy Scripting Help 3 12/01/2015 03:40 PM
Repair Abuse MBilal Scripting Help 12 30/09/2013 04:03 PM
Pickup abuse.. ThePhill97 Scripting Help 1 23/11/2012 07:14 PM
How to make stock stop a script? ddnbb Scripting Help 12 27/08/2012 02:29 PM
[AJUDA] Stock stock GetVehicleModelID(nome[]) Baigou Português/Portuguese 1 09/11/2011 12:21 AM


All times are GMT. The time now is 09:16 PM.


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