AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Q] Best practices / Code snippets? (https://forums.alliedmods.net/showthread.php?t=295921)

LegacyCode 04-08-2017 12:20

[Q] Best practices / Code snippets?
 
Hello World,

I used to be a front-end developer and I tried many different languages
and programs (AutoIT, PHP, Python, JavaScript,...), so I'm kinda familiar
with some coding stuff.

I've set up Sublime Text 2 to compile my .sma files easily
(thanks to https://forums.alliedmods.net/showthread.php?t=293376)
and dived into some plugins to look into the code, only to find no comments
for the most part and different takes on certain things,
e.g. hooking SayText to manipulate the chat in certain ways.

Is there some kind of best practices coding snippets database?
Would some of you plugin gods mind to share some of your genius with us? :bee:

I hope this isn't too much to ask (and not a duplicate question), but I'm so confused.
I don't want to learn bad habits when coding plugins right off the bat and the API documentation
isn't too helpful sometimes either (https://www.amxmodx.org/api/).

Also it doesn't have to be actual code snippets, although I believe that's what I learn from best.
Looking at existing code I get the grasp of what's happening, but I lack the
details on why and when I should do stuff in certain ways.

- LegacyCode

PS: I'm mainly talking about plugins for CS 1.6, but I would love to see more on this topic obviously :)

wickedd 04-08-2017 12:35

Re: [Q] Best practices / Code snippets?
 
Everybody wants to learn how to code but no wants to search.

https://forums.alliedmods.net/clear.gif Code Snippets/Tutorials

HamletEagle 04-08-2017 12:38

Re: [Q] Best practices / Code snippets?
 
There is no collection of good snippets, just the tutorial section linked above(I would not consider everything from it as good code, though). Ask a concrete question and we will help you to understand, your current post is way too vague.

LegacyCode 04-08-2017 12:40

Re: [Q] Best practices / Code snippets?
 
Quote:

Originally Posted by wickedd (Post 2510378)
Everybody wants to learn how to code but no wants to search.

https://forums.alliedmods.net/clear.gif Code Snippets/Tutorials

I searched my ass off in this section and everybody has different takes on everything.
I'm talking about best practices, plus most stuff seemed to be outdated to me (as well as many plugins).

Quote:

Originally Posted by HamletEagle (Post 2510380)
There is no collection of good snippets, just the tutorial section linked above(I would not consider everything from it as good code, though). Ask a concrete question and we will help you to understand, your current post is way too vague.

Yeah kinda thought that would be the case, will do. Thank you!

- LegacyCode

fysiks 04-08-2017 13:08

Re: [Q] Best practices / Code snippets?
 
Quote:

Originally Posted by LegacyCode (Post 2510382)
I searched my ass off in this section and everybody has different takes on everything.
I'm talking about best practices, plus most stuff seemed to be outdated to me (as well as many plugins).

That's not uncommon among anything that is free and is primarily supported by "the internet" especially for something that is dying. Simply learn by doing and use your own common sense to evaluate trial methodologies. For more complicated code, you might need to learn whose posts are more likely to be more accurate. There is very little if any quality control on the internet in general including here.


All times are GMT -4. The time now is 18:05.

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