AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [TF2] Friendly - 09/14/2020 (https://forums.alliedmods.net/showthread.php?t=327373)

ratawar 09-14-2020 12:22

[TF2] Friendly - 09/14/2020
 
1 Attachment(s)
[TF2] Friendly


Friendly is a highly flexible plugin that allows players to enter into Friendly mode. While in it, they can't harm other players while being unable to receive damage.

Features
  • Translucent effect on Friendly players (toggleable)
  • Ammo regen on friendly players (toggleable)
  • SOAP TF2DM support for pug oriented servers - disables itself upon pug start
  • Configurable command cooldown
  • Ability to block command if player is not in spawn
  • Advertises itself once to a player who shoots at a friendly player (toggleable)
  • Translation support in English, Spanish and Portuguese
  • Real-time cvar changes

Console Variables
  • sm_friendly_version - Plugin Version
  • sm_friendly_enable - 1- Enable | 0- Disable (Default = 1)
  • sm_friendly_cooldown - Seconds before players can use the command again (Default = 3)
  • sm_friendly_translucid - 1- Set friendly players translucid | 0- Don't (Default = 1)
  • sm_friendly_jump - 1- Friendly players can jump | 0- They can't (Default = 1)
  • sm_friendly_regen - 1- Friendly players regen ammo | 0- They don't (Default = 1)
  • sm_friendly_onlyspawn - 1- Players can only become friendlies in spawn | 0- Players can become friendlies anywhere (Default = 0)
  • sm_friendly_advertise - 1- Players receive information about the plugin if they attack a friendly player (only the first time they attack, not every time) | 0- They don't (Default = 1)

Installation and Compiling

To install this plugin,unzip the attached .zip file and drop all of its folders inside your tf/addons/sourcemod folder.
To compile, I provide the folder with the source code and all its dependencies.

Source Code

Changelog
  • v1.0 (September 14, 2020)
    • Initial release

Acknowledges

Some features of this plugin and code snippets have been taken from Phil25's Friendly Simple plugin, such as the Spawn Only feature, IsValidClient stock and transcolor render modes for the translucent feature. It served a huge base for me to create this revamped Friendly plugin version. However, it is NOT as advanced as his plugin.

MAGNAT2645 09-15-2020 02:36

Re: [TF2] Friendly - 09/14/2020
 
There's already Friendly plugins with same functions on the forum.

1) As i know (non)friendlies still can hurt (non)friendlies by using some plugins. For example: RTD. You should add OPTIONAL support.
2) In your plugin friendlies can collide with non-friendlies which is bad.
3) You shouldn't use public keyword for normal functions (DisableFriendly, EnableFriendly etc.) because this keyword is mostly used by callbacks.
Normal functions are already "public" (only inside of your plugin, natives can be used outside), unless you have defined them as static.
4) It is best to make some includes OPTIONAL if you're going to publish your plugins.
First of all, you can use #tryinclude instead of #include for things like soap_tournament.
Also if optional include has some natives you can undefine REQUIRE_PLUGIN macro like:
Code:

#undef REQUIRE_PLUGIN
#tryinclude <myinclude>
#define REQUIRE_PLUGIN

Many includes have function (only if REQUIRE_PLUGIN is undefined) that makes natives optional.

ratawar 09-15-2020 12:10

Re: [TF2] Friendly - 09/14/2020
 
Quote:

Originally Posted by MAGNAT2645 (Post 2717838)
There's already Friendly plugins with same functions on the forum.

1) As i know (non)friendlies still can hurt (non)friendlies by using some plugins. For example: RTD. You should add OPTIONAL support.
2) In your plugin friendlies can collide with non-friendlies which is bad.
3) You shouldn't use public keyword for normal functions (DisableFriendly, EnableFriendly etc.) because this keyword is mostly used by callbacks.
Normal functions are already "public" (only inside of your plugin, natives can be used outside), unless you have defined them as static.
4) It is best to make some includes OPTIONAL if you're going to publish your plugins.
First of all, you can use #tryinclude instead of #include for things like soap_tournament.
Also if optional include has some natives you can undefine REQUIRE_PLUGIN macro like:
Code:

#undef REQUIRE_PLUGIN
#tryinclude <myinclude>
#define REQUIRE_PLUGIN

Many includes have function (only if REQUIRE_PLUGIN is undefined) that makes natives optional.

Thank you a lot for your feedback.

I started developing this with "normal" servers in mind like mine, (maybe) recklessly ignoring heavily modded servers with plugins such as RTD or others, and therefore not making that very clear in the plugin description. I'm working to add support for stuff that make friendlies as unintrusive to the world as possible, like not being able to collide, capture or carry stuff. Even though my learning pace is really good, messing with stuff like that is still new to me, so the project might be very far from good sometimes.

Still, I don't have in mind making this plugin as extense as the other 2 already existing friendly plugins, since as I pointed out earlier, it's meant for servers where it's not necessary to take care of too many details outside stock stuff.

As for the code suggestions, I appreciate them a lot, I will correct everything you pointed me out in no time, and keep it in mind for the future.
Regarding the includes - also a fairly unexplored topic for me - I will focus on improving SOAP's support with your tips as well.

RoseTheFox 03-26-2021 09:37

Re: [TF2] Friendly - 09/14/2020
 
I don't entirely know if this is still being worked on, looked at or anything; but player v.s player collisions seem to have an issue, as friendlies can go through other players, but if other non-friendly players move inside of a friendly, they get stuck and it's hard for them to move!


All times are GMT -4. The time now is 12:26.

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