Raised This Month: $51 Target: $400
 12% 

Could you give me feedback on my plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
decowboy
AlliedModders Donor
Join Date: Oct 2015
Location: Guadalajara, Mexico
Old 10-16-2015 , 11:18   Could you give me feedback on my plugin?
Reply With Quote #1

Hi guys,

I wrote a plugin and posted it on the forum yesterday.

This is the link:
https://forums.alliedmods.net/showthread.php?t=273251

I wrote some CS 1.6 plugins for AMX Mod X back in the day, but this is my first SourceMod plugin and my return to Pawn after many years.

I've been using the plugin on my own server for a couple of days and everything seems to work fine. Still there might be things that you would've done differently.

That's why I'm hoping that there are people out there who might be willing to briefly look through the code and give me feedback on it.

I'd be very thankful for your time.
decowboy is offline
SoulSharD
Member
Join Date: Oct 2013
Location: United Kingdom
Old 10-16-2015 , 17:37   Re: Could you give me feedback on my plugin?
Reply With Quote #2

Looks nicely written to me.

One point, although there is absolutely NOTHING wrong with this: there's more comments than code.
Again, nothing wrong with that, very useful for someone who's learning from your source.
__________________

SoulSharD is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 10-16-2015 , 17:39   Re: Could you give me feedback on my plugin?
Reply With Quote #3

My private plugins have a MINIMIUM comment:code ratio of 2:1. It is mandatory to prevent me from going insane with pawn.

Last edited by Potato Uno; 10-16-2015 at 17:39.
Potato Uno is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 10-16-2015 , 18:07   Re: Could you give me feedback on my plugin?
Reply With Quote #4

I rarely use comments. I usually only use comments to help others that might read it. But your code seems good. I didn't see anything wrong in the quick look I took.

Last edited by thecount; 10-16-2015 at 18:11.
thecount is offline
decowboy
AlliedModders Donor
Join Date: Oct 2015
Location: Guadalajara, Mexico
Old 10-16-2015 , 23:47   Re: Could you give me feedback on my plugin?
Reply With Quote #5

Thanks for taking a look, guys! Really appreciate it.
I would agree the commenting is pretty extensive. I figured that if I was going to ask other people to have a look at the code, it'd be nice to at least make it easy to comprehend.

Do you see any reason why this code wouldn't work for CS:Source? I unfortunately have no experience with that game, so I can't tell for sure.
decowboy is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 10-17-2015 , 15:51   Re: Could you give me feedback on my plugin?
Reply With Quote #6

I don't bother to comment out code unless I need to remember something in particular of I need to remember what my mindset while making the code was.
Drixevel is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 10-17-2015 , 15:54   Re: Could you give me feedback on my plugin?
Reply With Quote #7

For work and for sourcemod, my rule is as following: If your code needs a comment, code it again so it doesn't need that comment.

There are always exceptions though.
Maxximou5 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 10-17-2015 , 16:23   Re: Could you give me feedback on my plugin?
Reply With Quote #8

Quote:
Originally Posted by Maxximou5 View Post
For work and for sourcemod, my rule is as following: If your code needs a comment, code it again so it doesn't need that comment.

There are always exceptions though.
I like that, thank you
headline is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 10-17-2015 , 18:33   Re: Could you give me feedback on my plugin?
Reply With Quote #9

At lines 83 and 91 you save the same cvar twice.

You can register a new command at line 207, and although you can't unregister the old one, you can find the command used to call the command callback with GetCmdArg on the 0th argument and do nothing if it's not the current command.

At line 222 you check if PluginActive() is nonzero before announcing, but I'm guessing you want to check if PluginActive() == TOGGLE_ACTIVE, since two other inactive states are also nonzero.

At line 703 you use the constant 1 rather than TOGGLE_ACTIVE, although your comment retains the information.

At line 744 you unnecessarily retrieve the toggle command from the cvar.

At lines 753 and 758 the 1 char long string togglePrepend is referenced as a zero-terminated string, but if it holds only '!', it's not zero-terminated, and it'll overrun the buffer. It needs to be at least 2 chars long to hold a character and a null. You can also use an inline ternary:

PHP Code:
PrintToChat(client">> Want to play without bots? Say: %s%s"GetConVarInt(sm_bot_toggle_chat) != "!" ""toggleCommand); 
You can do the same thing around line 435 instead of incrementing it:

PHP Code:
PrintToChat(client"You need to wait %d second%s before disabling bots."cooldownRemainingcooldownRemaining "s" ""); 
At line 414 processToggle never needs to return different values, so there's no point in having a return value.

You also sorta mix new and old syntax all over but it doesn't matter I guess.
Miu is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 10-17-2015 , 18:37   Re: Could you give me feedback on my plugin?
Reply With Quote #10

It seems you are using a mixture of transitional and old syntax. Over use of spaces, Could improve the variable names, Too many comments.

#include <sourcemod> is not required.

Hope that's some help.
SM9 is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 07:42.


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