This is my version of Friendly with quite a bit of code borrowed from ddhoward's Friendly Mode, so a lot of credit goes to the author of the original plugin.
Friendly Simple should NOT run alongside the original Friendly plugin.
Differences:
This plugin has 0 ConVars thus very easy to set up,
Friendly players are wholly unable to attack (except with Rocket/Sticky Jumper),
Friendly mode can be toggled only in spawn,
Friendly players, along with their cosmetics and weapons, are semi-transparent and are colored green,
For developers: Has its own include file, see below for more information,
Lots of potential bug/exploit fixes due to a different way of managing Friendlies.
Similarities:
Friendly players cannot be damaged nor deal damage,
Hostile players are able to clip through Friendly players,
Friendly players are unable to interact with the world in any way*,
Friendly players cannot use Teleporters or acquire metal from Dispensers,
Friendly players are not targeted by enemy Sentries,
Friendly players cannot RTD or Goomba stomp/get Goomba stomped,
Friendly players cannot capture Control Points, grab the Intelligence, etc.
The list goes on
Commands:
sm_friendly - Toggles Friendly mode on the activator (only works once the client is in spawn).
sm_f - Same as above.
Overriding access:
By default, sm_friendly is accessible to everyone. To restrict access, use Overrides.
Simply add a restriction to sm_friendly and sm_f will follow.
For developers:
Compiling
Compiling will work just fine without any special requirements, however:
Due to a certain Roll The Dice's deficiency, you should use the rtd.inc attached to this post. If you are including rtd, that is.
The long story is that you need that edited .inc file of the plugin because it makes it possible to mark the rtd include in friendlysimple as optional, therefor being able to load friendlysimple without having rtd loaded.
Include file
Table of Contents:
Forwards:
FriendlySimple_OnEnableFriendly(client) - Fired when a client goes Friendly.
FriendlySimple_OnDisableFriendly(client) - Fired when a client goes hostile.
Natives:
bool:FriendlySimple_IsFriendly(client) - Returns whether or not a given player is Friendly.
bool:FriendlySimple_IsInSpawn(client) - Returns whether or not a given player is in their spawn.
bool:FriendlySimple_HasAccess(client) - Returns whether or not a given player has access to Friendly.
FriendlySimple_SetFriendly(client, direction=-1) - Sets Friendly on a client:
direction:
-1 to toggle (default),
0 to disable,
1 to enable.
returns:
-3 if client is not a valid client index,
-2 if client is not in game,
-1 if no change was made (the client was already in the requested state),
0 if the client was made hostile,
1 if the client was made Friendly.
PHP Code:
/****************************\
- F O R W A R D S -
\****************************/
/**
* Called during a player's transition into Friendly Mode. This fires before any
* changes are applied but after the client notification.
*
* @param client Client Index.
*/
forward FriendlySimple_OnEnableFriendly(client);
/**
* Called during a player's transition out of Friendly Mode. This fires before any
* changes are applied but after the client notification. Note that it also fires
* for every client upon unloading/reloading friendlysimple.smx.
*
* @param client Client Index.
*/
forward FriendlySimple_OnDisableFriendly(client);
/**************************\
- N A T I V E S -
\**************************/
/**
* Returns whether or not a given player is Friendly.
*
* @param client Client Index.
* @return TRUE if Friendly, FALSE if not Friendly or if invalid client.
*/
native bool:FriendlySimple_IsFriendly(client);
/**
* Returns whether or not a given player is in their spawn.
*
* @param client Client Index.
* @return TRUE if is in their spawn, FALSE if not in their spawn or if invalid client.
*/
native bool:FriendlySimple_IsInSpawn(client);
/**
* Returns whether or not a given player has access to Friendly.
*
* @param client Client Index.
* @return TRUE if has access, FALSE if doesn't have access or if invalid client.
*/
native bool:FriendlySimple_HasAccess(client);
/**
* Sets Friendly mode on a client.
*
* @param client Client Index.
*
* @param direction -1 to toggle, 0 to disable, or 1 to enable
*
* @return -3 if client is not a valid client index,
* -2 if client is not in game,
* -1 if no change was made (the client was already in the requested state)
* 0 if the player was made non-Friendly,
* 1 if the player was made Friendly.
*/
native FriendlySimple_SetFriendly(client, direction=-1);
Changelog
v0.924: (5 Mar 2016)
Fixed a bug where MediGuns would continue healing and wouldn't stop after the medic switching to Friendly.
Updated the .inc file for thrid-party plugins for them to be able to mark the plugin as optional.
Fix not being able to load the plugin without Roll The Dice loaded (RTD's imperfection).
Unable to taunt with any Pyro secondary.
v0.921: (12 Dec 2015)
Sappers are now being removed when going friendly.
v0.92: (4 Dec 2015)
Friendly players are now so unable to attack, that no animation is being played.
Fixed FriendlySimple_OnEnableFriendly and FriendlySimple_OnDisableFriendly forwards not working.
Friendly players can use Rocket Jumper, Sticky Jumper and B.A.S.E. Jumper freely.
Players can go friendly while having the Holiday Punch Equipped
You cannot taunt with the following weapons:
(Festive) Ubersaw //Can stun enemy players
Equalizer //The explosion can still interact with the world (blowing up explosives, destroying buildings)
Amputator //Can heal allies
Scorch Shot //Pushback is still present (removed in v0.922 because its classname's been banned)
Escape Plan //Same as Equalizer
All spy knifes //Can still destroy buildings
All sniper bows //Can stun enemy players
v0.91: (11 Nov 2015)
Updated the plugin for Mannpower mode.
Fixed IsClientInSpawn check not working properly.
Fixed plugin working incorrectly after reloading it.
General fixes and improvements.
v0.908: (10 Nov 2015)
Tidied up the code quite a bit.
Optimization improvement.
Confirmed that rubberbanding does not occur anymore.
v0.907: (10 Nov 2015)
Different way of giving Friendlies godmode which doesn't contradict with other plugins.
Possible rubberbanding fix? (none reported so far)
v0.906: (7 Nov 2015)
Unable to taunt with the Amputator.
v0.905: (3 Nov 2015)
Unable to swtich to Friendly while having the Holiday Punch equipped.
Fixed being able to attack with right click in certain situations.
v0.904: (1 Nov 2015)
Unable to to taunt with the Equalizer, the Escape Plan and all spy knifes.
The first two cause the pumpkins to explode and all of them are able to destroy buildings.
v0.903: (1 Nov 2015)
Fixed tauntkills not dealing any damage whether the client is Friendly or not.
v0.902: (1 Nov 2015)
Added two forwards:
FriendlySimple_OnEnableFriendly(client),
FriendlySimple_OnDisableFriendly(client).
v0.901: (1 Nov 2015)
Fixed override inconvenience.
v0.9: (1 Nov 2015)
Initial release.
Todo/Known issues
Making bots unable to see friendly players.
Making friendly players unable to pick up fallen weapons.
Installation:
Simply click Get Plugin and place it in the sourcemod/plugins/ folder.
Now, either restart the server or type "sm plugins load friendlysimple" in the console.
NOTE: You will have to unload "friendly.smx" if you already have it installed.
The .inc file is only for developers and, therefore, is optional.
Final note: This is my first plugin I'm releasing and bugs are expected. Please report anything you can find and/or help me fix it. I assure you, I would appreciate that greatly!
Because the commands are sm_friendly and sm_f. There are also some variants of the first one, for example sm_firendly. I'm not sure if it's a good practice adding such a thing, but I happened to misspell it at first quite often (sm_f negates that though, so it'll probably get removed).
EDIT: Well, I understand what you mean now, going to fix it right away.
Hmm, I see what you mean. If you have multiple commands all going to the same function, I think the best thing to do would be to include a CheckCommandAccess right at the top of it, and have server owners use the "primary" command in their overrides file. That way overriding sm_friendly will affect all the other commands for it too. This isn't any sort of Sourcemod standard though, so it's totally up to you.
Observation: Bots still target you when friendly is active.
Desired effect: Bots ignore you when friendly is active.
Possible fix: Maybe use some of the coding already done by the amazing Tylerst on his 'Bot Ignore' plugin: https://forums.alliedmods.net/showthread.php?p=2087931
Thanks for the support! And as for that plugin, its way is a bit outdated - the client straight up becomes cloaked. Although that didn't seem to be the case in the past.
As I looked around, nobody seemed to had figured out to how have individual clients get ignored by bots. I will be in constant update about the this, though.
v0.905 - Unable to swtich to Friendly while having the Holiday Punch equipped. Also, fixed being able to attack with right click in certain situations.