/** * Called everytime Friendly is self-toggled to determine if the player can do so. * Return Plugin_Continue to allow, anything else denies them access. * * This is ONLY called if the player is toggling Friendly on themselves, either through running * sm_friendly with no arguments, or using sm_friendly without access to sm_friendly_targetothers * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. * @param friendly TRUE if the player is CURRENTLY Friendly, FALSE otherwise. * @param cancel True if the player is trying to cancel a previously * requested and pending switch out of/into Friendly Mode. */ forward Action:TF2Friendly_CanToggleFriendly(client, bool:friendly, bool:cancel);
/** * Called immediately after a player has spawned into Friendly Mode, has spawned while KEEPING * Friendly Mode enabled, or was Friendly until spawning. * * This is not called if the player was hostile before AND after spawning. * * @param client Client Index. * @param isFriendly True if the player is in Friendly Mode. * @param changed True if the spawn triggered a change in the player's Friendly status */ forward TF2Friendly_OnSpawn(client, bool:isFriendly, bool:changed);
/** * Called during a Friendly player's refreshing of Friendly Mode. * * To "refresh" Friendly Mode means to apply/reapply all attributes that may * have been removed by other plugins, such as transparency, FL_NOTARGET, etc. * This happens every time a Friendly player enters Friendly Mode, hits * a resupply cabinet, respawns while remaining in Friendly Mode, has * TF2Friendly_RefreshFriendly() called on him, etc. * * This is when most custom Friendly Mode limitations should be activated. * You may also want to look into TF2Friendly_OnEnableFriendly(). * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. */ forward TF2Friendly_OnRefreshFriendly(client);
/** * Called during a player's transition into Friendly Mode. Any one-time limitations/effects to * Friendly players should probably be applied here, such as "destroy all their buildings," "make * them drop the intel," or "destroy all their sticky bombs." * * You will most likely want to use TF2Friendly_OnRefreshFriendly() instead. * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. */ forward TF2Friendly_OnEnableFriendly(client);
/** * Called during a player's transition out of Friendly Mode. Any limitations to * Friendly players should probably be removed here. * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. */ forward TF2Friendly_OnDisableFriendly(client);
/** * Called immediately BEFORE a player enters Friendly Mode. If your plugin needs * to somehow prepare something BEFORE a player goes Friendly, this is the time to do it. * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. */ forward TF2Friendly_OnEnableFriendly_Pre(client);
/** * Called immediately AFTER a player's transition into Friendly Mode. * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. */ forward TF2Friendly_OnEnableFriendly_Post(client);
/** * Called immediately BEFORE a player exits Friendly Mode. If your plugin needs * to somehow prepare something BEFORE a player goes Hostile, this is the time to do it. * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. */ forward TF2Friendly_OnDisableFriendly_Pre(client);
/** * Called immediately AFTER a player's transition out of Friendly Mode. * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. */ forward TF2Friendly_OnDisableFriendly_Post(client);
/** * Called immediately BEFORE a player has Friendly Mode "refreshed" on them. * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. */ forward TF2Friendly_OnRefreshFriendly_Pre(client);
/** * Called immediately AFTER a player has Friendly Mode refreshed. * * The player is not guaranteed to be alive when this is called. * * @param client Client Index. */ forward TF2Friendly_OnRefreshFriendly_Post(client);
/** * Called immediately after Friendly Mode is enabled through changing * sm_friendly_enabled to 1. This is NOT called when the plugin is loaded. * It is ONLY called when the cvar has been changed AFTER the plugin is loaded. */ forward TF2Friendly_OnPluginEnabled();
/** * Called immediately after Friendly Mode is enabled through changing * sm_friendly_enabled to 1. All Friendly players will be removed from * Friendly Mode before this forward is called. */ forward TF2Friendly_OnPluginDisabled();
/** * Called immediately after the core Friendly Mode plugin has loaded, * and all cvars and configs have been loaded/cached. * * @param enabled TRUE if the plugin is enabled with sm_friendly_enabled */ forward TF2Friendly_OnPluginLoaded(bool:enabled);
/** * Called when Friendly Mode core plugin is unloaded. All Friendly players will * be removed from Friendly Mode before this forward is called. */ forward TF2Friendly_OnPluginUnloaded();
Please note that all these "natives" run a simple check to see if friendly_core.smx is even loaded before calling the real native; this ensures that an unavailable native is never called, since calling an unavailable native will result in the current callback being aborted. However, this check is considered to be expensive. If you will be using one or more of these natives repeatedly (such as OnGameFrame, OnTouch, etc), you may want to bypass the check. You can do so by simply adding a '2' to the end of the native name. For example, TF2Friendly_IsFriendly() becomes TF2Friendly_IsFriendly2().
Before manually calling a '2' native, you must do your own checking to see if the plugin is loaded. This can be done by using OnAllPluginsLoaded()+LibraryExists(), OnLibraryAdded(), and OnLibraryRemoved() with the library name "[TF2] Friendly Mode", and storingthe result in a boolean variable. Check that the variable is true before calling the '2' native!!
/** * Returns whether or not a given player is Friendly. * * @param client Client Index. * @return TRUE if Friendly * FALSE if not Friendly, if invalid client, or if friendly_core cannot be reached. */ stock bool:TF2Friendly_IsFriendly(client) { if (GetFeatureStatus(FeatureType_Native, "TF2Friendly_IsFriendly2") == FeatureStatus_Available) return TF2Friendly_IsFriendly2(client); else return false; }
/** * Sets Friendly mode on a client. * * @param client Client Index. * * @param direction -1 to toggle, 0 to disable, or 1 to enable * * @param action 0 to make the change without punishment, * -1 to slay the player and apply the change upon respawn, * Any positive integer will have the player slapped for that * amount of damage. If the player is slapped to death, the * change will be re-applied upon respawn. * * @return -4 if there was an error communicating with friendly_core.smx * -3 if client is not a valid client index, * -2 if client is not connected and 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, * 2 if the player was made non-Friendly and was slapped to death, * 3 if the player was made Friendly and was slapped to death. */ stock TF2Friendly_SetFriendly(client, direction=-1, action=0) { if (GetFeatureStatus(FeatureType_Native, "TF2Friendly_SetFriendly2") == FeatureStatus_Available) return TF2Friendly_SetFriendly2(client, direction, action); else return -4; }
/** * Returns whether or not a given player is Friendly Locked. * * @param client Client Index. * @return TRUE if Locked * FALSE if not locked, if invalid client, or friendly_core could not be reached */ stock bool:TF2Friendly_IsLocked(client) { if (GetFeatureStatus(FeatureType_Native, "TF2Friendly_IsLocked2") == FeatureStatus_Available) return TF2Friendly_IsLocked2(client); else return false; }
/** * Sets or removes Friendly Lock on a client. * * @param client Client Index. * * @param direction -1 to toggle, 0 to remove lock, or 1 to place lock. * * @return -4 if there was an error communicating with friendly_core * -3 if client is not a valid client index, * -2 if client is not connected and in game, * -1 if no change was made (the client was already in the requested state) * 0 if the player was unlocked, * 1 if the player was locked. */ stock TF2Friendly_SetLock(client, direction=-1) { if (GetFeatureStatus(FeatureType_Native, "TF2Friendly_SetLock2") == FeatureStatus_Available) return TF2Friendly_SetLock2(client, direction); else return -4; }
/** * Forces the client to undergo Friendly Mode refreshing, if Friendly. * * @param client Client Index. * * @return -4 if there was an error communicating with friendly_core * -3 if client is not a valid client index, * -2 if client is not connected and in game, * -1 if the client was not in Friendly Mode. * 1 if the function appeared to be successful. */ stock TF2Friendly_RefreshFriendly(client) { if (GetFeatureStatus(FeatureType_Native, "TF2Friendly_RefreshFriendly2") == FeatureStatus_Available) return TF2Friendly_RefreshFriendly2(client); else return -4; }
/** * Returns whether the plugin is enabled/disabled through the cvar sm_friendly_enabled. * * @return TRUE if enabled * FALSE if disabled or there was an error communicating with friendly_core */ stock bool:TF2Friendly_IsPluginEnabled() { if (GetFeatureStatus(FeatureType_Native, "TF2Friendly_IsPluginEnabled2") == FeatureStatus_Available) return TF2Friendly_IsPluginEnabled2(client); else return false; }
public OnAllPluginsLoaded() { UPD_OnAllPluginsLoaded(); } public OnLibraryAdded(const String:name[]) { UPD_OnLibraryAdded(); }
public Plugin:myinfo = { name = "[TF2] Friendly Mode - No RTD", author = "Derek D. Howard", description = "Disables RTD for Friendly players.", version = PLUGIN_VERSION, url = "" }
public OnPluginStart() { hcvar_nortd = CreateConVar("friendly_nortd", "1", "(0/1) If enabled, plugin prevents Friendly Players from Rolling the Dice", FCVAR_PLUGIN); }
public Action:RTD_CanRollDice(client) { if (TF2Friendly_IsFriendly(client) && GetConVarBool(hcvar_nortd)) { PrintToChat(client, "You cannot RTD while Friendly!"); return Plugin_Handled; } return Plugin_Continue; }
new Handle:hcvar_pumpkins; new bool:cvar_pumpkins; new bool:FriendlyExists;
public OnAllPluginsLoaded() { UPD_OnAllPluginsLoaded(); if (LibraryExists("[TF2] Friendly Mode")) { FriendlyExists = true; } } public OnLibraryAdded(const String:name[]) { UPD_OnLibraryAdded(); if (StrEqual(name, "[TF2] Friendly Mode")) { FriendlyExists = true; } } public OnLibraryRemoved(const String:name[]) { if (StrEqual(name, "[TF2] Friendly Mode")) { FriendlyExists = false; } }
public Plugin:myinfo = { name = "[TF2] Friendly Mode - No Pumpkin Bombs", author = "Derek D. Howard", description = "Disables a Friendly player's ability to trigger pumpkin bombs.", version = PLUGIN_VERSION, url = "" }
public OnPluginStart() { hcvar_pumpkins = CreateConVar("friendly_pumpkins", "1", "(0/1) If enabled, Friendly players will be unable to blow up pumpkins.", FCVAR_PLUGIN); }
public OnConfigsExecuted() { cvarChange(INVALID_HANDLE, "", ""); HookConVarChange(hcvar_pumpkins, cvarChange); if (cvar_pumpkins) { HookPumpkins(); } }
HookPumpkins() { if (cvar_pumpkins) { new ent = -1; while ((ent = FindEntityByClassname(ent, "tf_pumpkin_bomb"))!=INVALID_ENT_REFERENCE) { SDKHook(ent, SDKHook_OnTakeDamage, PumpkinTakeDamage); } } }
public OnEntityCreated(entity, const String:classname[]) { if (cvar_pumpkins) { if (StrEqual(classname, "tf_pumpkin_bomb", false)) { SDKHook(entity, SDKHook_OnTakeDamage, PumpkinTakeDamage); } } }
public OnAllPluginsLoaded() { UPD_OnAllPluginsLoaded(); } public OnLibraryAdded(const String:name[]) { UPD_OnLibraryAdded(); }
public Plugin:myinfo = { name = "[TF2] Friendly Mode - No Goomba", author = "Derek D. Howard", description = "Disables Goomba Stomp for Friendly players.", version = PLUGIN_VERSION, url = "" }
public OnPluginStart() { hcvar_nogoomba = CreateConVar("friendly_nogoomba", "1", "(0/1) If enabled, plugin turns off Goomba Stomps for Friendly Players", FCVAR_PLUGIN); }
public Action:OnStomp(attacker, victim, &Float:damageMultiplier, &Float:damageBonus, &Float:JumpPower) { if ((TF2Friendly_IsFriendly(attacker) || TF2Friendly_IsFriendly(victim)) && GetConVarBool(hcvar_nogoomba)) { return Plugin_Handled; } return Plugin_Continue; }
what would be the cvar for change it to like another admin flag im guessing in admin overides i would have to input this sm_friendly_targetothers "what ever flag i want maybe?" like that ?
First of all, thanks for the plug-in! and all the work that has obviously gone into updating and improving it over time!
Regarding this ...
Quote:
A way to distinguish Friendly players without alpha changing.
I do find the alpha-changing somewhat confusing for servers (like mine) that also have the "Roll-the-Dice" plug-in also - since RTD's "God Mode" throw also uses alpha-changing.
Some alternate suggestions:
Some sort of "glow" effect instead of the alpha-change?
Make "friendly" players only visible to other "friendly" players? (like this option the best myself, it would be like being in an alternate "phase" of existence).
Forcing a particular custom model - not normally associated with any class? (seem to recall some "Poni" servers doing something like that).
All of these things have been discussed in past pages in the thread. I eventually want to create sub-plugins for all of them.
The second option (which would involve SDKHook_SetTransmit) is problematic in certain respects. I'm having difficulty having it apply to heavies who have any sort of minigun equipped, and whenever an "invisible" pyro shoots his flamethrower, users who cannot see the pyro will see a random stream of flame at the last location that their game client knew the pyro to be at. I'm working on it though. I've just been swamped with real life lately, and I'm still working on the massive fucking overhaul of the plugin at large.
All of these things have been discussed in past pages in the thread. I eventually want to create sub-plugins for all of them.
The second option (which would involve SDKHook_SetTransmit) is problematic in certain respects. I'm having difficulty having it apply to heavies who have any sort of minigun equipped, and whenever an "invisible" pyro shoots his flamethrower, users who cannot see the pyro will see a random stream of flame at the last location that their game client knew the pyro to be at. I'm working on it though. I've just been swamped with real life lately, and I'm still working on the massive fucking overhaul of the plugin at large.
Also abought that forward, can you add another parameter that says if the player is going into or out of friendly, just having one on any toggle isn't what I really need it for.
Edit: Also can you make forward work with non-self-toggled friendly use.
Also abought that forward, can you add another parameter that says if the player is going into or out of friendly, just having one on any toggle isn't what I really need it for.
That's what the second parameter is for? @_@
Quote:
Edit: Also can you make forward work with non-self-toggled friendly use.
Hahaha i actually started working on this recently. Here's what the line in the inc will look like (so far, anyway)
PHP Code:
/**
* Called when Friendly is toggled to determine if the toggle actually happens. Return Plugin_Continue
* to allow the toggle. Return Plugin_Stop to deny the toggle.
*
* Plugins using TF2Friendly_SetFriendly can optionally bypass this forward and cause it to not be called.
*
* @param client Client Index.
* @param enabling TRUE if Friendly is being ENABLED, false if it's being DISABLED.
* @param plugin A handle to the plugin making the toggle request.
* @param reason Optional parameter, indicates the reason that the plugin is making the request.
* The meaning of this value depends on the plugin making the request. Some plugins
* might not even use it at all.
*/
forward Action:TF2Friendly_OnToggleFriendly(client, bool:enabling, Handle:plugin, reason);
Hahaha i actually started working on this recently. Here's what the line in the inc will look like (so far, anyway)
PHP Code:
/**
* Called when Friendly is toggled to determine if the toggle actually happens. Return Plugin_Continue
* to allow the toggle. Return Plugin_Stop to deny the toggle.
*
* Plugins using TF2Friendly_SetFriendly can optionally bypass this forward and cause it to not be called.
*
* @param client Client Index.
* @param enabling TRUE if Friendly is being ENABLED, false if it's being DISABLED.
* @param plugin A handle to the plugin making the toggle request.
* @param reason Optional parameter, indicates the reason that the plugin is making the request.
* The meaning of this value depends on the plugin making the request. Some plugins
* might not even use it at all.
*/
forward Action:TF2Friendly_OnToggleFriendly(client, bool:enabling, Handle:plugin, reason);