AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   In general, when should I use stock vs public vs [blank] (https://forums.alliedmods.net/showthread.php?t=234477)

Chdata 01-31-2014 02:43

In general, when should I use stock vs public vs [blank]
 
Whenever I make new functions I usually just use stock Function() because I see that used a lot, or sometimes just Function() for absolutely no reason.

What difference does it all make? When should I use what?

(If its a native or something that normally requires public or whatever it requires, of course, I'll use that).

floube 01-31-2014 02:49

Re: In general, when should I use stock vs public vs [blank]
 
AFAIK when using something like SomeRandomFunction(data=0) you must use stock or [blank].

thetwistedpanda 01-31-2014 03:38

Re: In general, when should I use stock vs public vs [blank]
 
If you apply a stock prefix, then the compiler won't be yelling at you if you don't use the function somewhere in the plugin.

asherkin 01-31-2014 04:19

Re: In general, when should I use stock vs public vs [blank]
 
stock is for functions in include files (they don't get compiled into the plugin if unused), public is for functions that other plugins or SourceMod needs to be able to call (i.e. forward callbacks), and no specifier is for everything else (there is also static which is used for "internal" functions in include files, which are only visible to other functions in that file).

11530 01-31-2014 16:13

Re: In general, when should I use stock vs public vs [blank]
 
Try to avoid using stock in standard .sp files since the larger the code gets the more likely your source code will still be containing a function that you no longer require, and with stock you'll forget it's hiding there.

Mathias. 01-31-2014 21:11

Re: In general, when should I use stock vs public vs [blank]
 
stock are just going to get compile if you use the function, public is basically for callbacks (functions called into your plugin but that not coming from your plugin), nothing just mean your function is private, you use private function for everything that stay inside your codes.

EDIT: What asherkin said.

friagram 02-01-2014 04:52

Re: In general, when should I use stock vs public vs [blank]
 
use public for every function
new for every variable
IsValidClient in every loop

who needs parsimony in programming when you have 8+ core xeons at ~3ghz

berni 02-01-2014 07:56

Re: In general, when should I use stock vs public vs [blank]
 
Quote:

Originally Posted by friagram (Post 2093681)
use public for every function
new for every variable
IsValidClient in every loop

who needs parsimony in programming when you have 8+ core xeons at ~3ghz

Error: BIG FAIL detected

Mathias. 02-01-2014 14:19

Re: In general, when should I use stock vs public vs [blank]
 
Quote:

Originally Posted by friagram (Post 2093681)
use public for every function
new for every variable
IsValidClient in every loop

who needs parsimony in programming when you have 8+ core xeons at ~3ghz

There is more than that to it, IsValidClient can die long ago, such a lazy horrible piece of code, making every possible CHECKS that most of them is impossible to happen in every piece of code.

Sourcemod is a scripting language, every single variable you create are using 32 bits and every NEW clear the whole memory for you. If you understand the difference between static, new, decl and dynamic array (YEA DYNAMIC ARRAYS YEA YEA YEA), it shouldnt slow you down and it will optimize the process of your plugin which can definitely affect the game performance.

It like valve saying, cs:go going to use 4 gb of ram per server and a total of 8 threads doing back ground work because we have today technology (lazy and/or don't have knowledge). Hope you understand that the price of the servers come with it since the point is to host as many server as you can on a 8+ core xeons.

Quote:

Originally Posted by berni (Post 2093737)
Error: BIG FAIL detected

LOL

Dr. Greg House 02-01-2014 14:25

Re: In general, when should I use stock vs public vs [blank]
 
Quote:

Originally Posted by berni (Post 2093737)
Error: BIG FAIL detected

LOL

("But, can't Mantle optimize it?")


All times are GMT -4. The time now is 19:36.

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