First plugin, need feedback
Hey guys,
I just build my first plugin and it works! I know that there is a plugin doing exactly that but I couldn't find it anymore so I thought it would be a good first project :) Would bee cool if someone more experienced could tell me if this would be considered good code. I'm normally ruby programmer where everything is an object and pawn doesn't even know the concept. That's also the reason why I did not put in any semicolons :) Thanks in advance! And as I like gists much more because you can comment on lines and stuff: https://gist.github.com/2called-chao...ed2c09f1d3d7e9 Changes I made after feedback: https://gist.github.com/2called-chao...d7e9/revisions PHP Code:
|
Re: First plugin, need feedback
I didn't really understand the returns to be honest. I've read this post and concluded to always return PLUGIN_CONTINUE except in plugin_init and if I want to prevent a chat command from being displayed in chat.
|
Re: First plugin, need feedback
Thanks, I think I understand it! So basically no function has to return PLUGIN_HANDLED if I would nest or combine the if conditions?
PHP Code:
|
Re: First plugin, need feedback
Returns values are not related to conditions.
Some functions can be blocked, then you use returns values depending if you want to block or not. Some callbacks are sent after something has been executed, and you can't block anything, so returns values have no effects in it. |
Re: First plugin, need feedback
Yeah sure they are not related. I couldn't find the information what pawn return by default if you have no explicit return in your function. To illustrate my thoughts (assuming no return would be NULL and the constants would represent strings rather than integers):
PHP Code:
Thank you very much so far! |
Re: First plugin, need feedback
Some forwards can be blocked (client_command, ...) some can not be blocked (plugin_init, client_connect ...)
Event (callbacks from register_event) can not be blocked Commands (register_clcmd, register_concmd) can be blocked Menus (register_menu) can be blocked Things that can't be blocked don't need returns values, if you need to exit functions, just use 'return' with no value. In things that can be blocked, you should use return values, though when you don't return any value, PLUGIN_CONTINUE is assumed. On specific modules (hamsandwich and fakemate) functions hooks, you need to use specific modules return values (HAM_IGNORED, HAM_HANDLED, HAM_OVERRIDE, HAM_SUPERCEDE, FMRED_IGNORED, FMRED_HANDLED, FMRED_OVERRIDE, FMRED_SUPERCEDE) |
Re: First plugin, need feedback
Thank you for the clarification. I think these changes should do it then. Not sure if I should return HAM_HANDLED in the event_player_spawned function but default would be HAM_IGNORED anyway.
https://gist.github.com/2called-chao...d7e9/revisions Thanks for the help! |
Re: First plugin, need feedback
FMRES_*
|
| All times are GMT -4. The time now is 23:17. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.