Raised This Month: $ Target: $400
 0% 

[TF2] Remove Damage Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dyl0n
Member
Join Date: Oct 2011
Old 08-31-2012 , 18:45   [TF2] Remove Damage Plugin
Reply With Quote #1

Edit: I found this http://forums.alliedmods.net/showpos...08&postcount=9 but I cannot get it to work.

Edit Edit: From code that I've found and threw together I have made what I was looking for.
Here it is.

To use friendly: sm_friendly (toggles)
Cvar to enable/disable blocked weapons: sm_friendly_blockweps 1/0 (enable/disable) default: 0 (disabled)
Cvar to remember friendly after you die/switch classes: sm_friendly_remember 1/0 (enable/disable) default 0: (disabled)
To use this you have to have admin flag "d" (ADMFLAG_BAN)

This plugin does the following:
Enables Buddha mode
Gives you immunity to sentries (they cannot target you)
Stops damage you do to others
Stops damage done to buildings (sentries, dispensers, teleporters)

Blocks the following weapons if cvar is enabled: tf_weapon_flamethrower(prevent airblasting non friendlies) tf_weapon_medigun(prevent healing non friendlies) tf_weapon_builder(prevent buliding stuff/sappers) tf_weapon_bonesaw(prevent performing ubersaw taunt on non friendlies) tf_weapon_compound_bow(prevent performing huntsman taunt on non friendlies) tf_weapon_bat_wood(prevent using sandman ball on non friendlies) tf_weapon_jar(prevent throwing piss on non friendlies) tf_weapon_jar_milk(prevent throwing milk on non friendlies) tf_weapon_fireaxe(prevent destroying sappers(homewrecker)) tf_weapon_lunchbox(prevent healing non friendlies) tf_weapon_crossbow(prevent healing non friendlies)
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <sdkhooks>

new bool:ClientIsBuddah[MAXPLAYERS+1] = {false, ...};
new 
Handle:hBlockWeps INVALID_HANDLE;
new 
Handle:hRemember INVALID_HANDLE;

public 
OnPluginStart()
{
    for(new 
i=1i<MAXPLAYERS+1i++)
        
ClientIsBuddah[i] = false;
    
hBlockWeps CreateConVar("sm_friendly_blockweps""0""Enable/Disable(1/0) Blocked Weapons"FCVAR_PLUGIN|FCVAR_NOTIFY);
    
hRemember CreateConVar("sm_friendly_remember""0""Enable/Disable(1/0) Remember Friendly"FCVAR_PLUGIN|FCVAR_NOTIFY);
    
RegAdminCmd("sm_friendly"OnToggleFriendlyADMFLAG_BAN"Toggles friendly on/off");
    
HookEvent("player_death"OnPlayerDeath);
    
HookEvent("player_spawn"OnPlayerSpawned);
}

public 
Action:OnToggleFriendly(clientargs)
{
    if(
IsPlayerAlive(client))
    {
        if (
ClientIsBuddah[client] == true) {
            
ClientIsBuddah[client] = false;
            new 
flags GetEntityFlags(client)&~FL_NOTARGET;
        
SetEntityFlags(clientflags);
        
SetEntProp(clientProp_Data"m_takedamage"21);
        
ReplyToCommand(client"Freindly mode disabled.");
        }
        else {
            
ClientIsBuddah[client] = true;
            new 
flags GetEntityFlags(client)|FL_NOTARGET;
        
SetEntityFlags(clientflags);
        
SetEntProp(clientProp_Data"m_takedamage"11);
        
ReplyToCommand(client"Friendly mode enabled.");
        }
     }
     else
         
ReplyToCommand(client"You cannot apply !friendly when dead.");

    return 
Plugin_Handled;
}  

public 
OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
ClientIsBuddah[client] && !GetConVarBool(hRemember))
    {
        
ClientIsBuddah[client] = false;
        
SetEntProp(clientProp_Data"m_takedamage"21);
        new 
flags GetEntityFlags(client)&~FL_NOTARGET;
        
SetEntityFlags(clientflags);
        
ReplyToCommand(client"Freindly mode disabled on death.");
    }
}

public 
OnPlayerSpawned(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
ClientIsBuddah[client] && GetConVarBool(hRemember))
    {
        
ClientIsBuddah[client] = true;
        new 
flags GetEntityFlags(client)|FL_NOTARGET;
    
SetEntityFlags(clientflags);
    
SetEntProp(clientProp_Data"m_takedamage"11);
    
ReplyToCommand(client"Friendly mode re-enabled on spawn.");
    }
}

public 
OnEntityCreated(building, const String:classname[])
{
    
SDKHook(buildingSDKHook_SpawnOnEntitySpawned);
}

public 
OnEntitySpawned(building)
{
    
SDKHook(buildingSDKHook_OnTakeDamageBuildingTakeDamage);
}

public 
OnClientPutInServer(client)
{
    
ClientIsBuddah[client] = false;
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
    
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
}

public 
Action:OnWeaponSwitch(clientweapon)
{
    
decl String:sWeapon[32];
    
GetEdictClassname(weaponsWeaponsizeof(sWeapon));

    if(
ClientIsBuddah[client] && GetConVarBool(hBlockWeps))
    {
        if(
StrEqual(sWeapon"tf_weapon_flamethrower") || StrEqual(sWeapon"tf_weapon_medigun") || StrEqual(sWeapon"tf_weapon_builder") || StrEqual(sWeapon"tf_weapon_bonesaw") || StrEqual(sWeapon"tf_weapon_compound_bow") || StrEqual(sWeapon"tf_weapon_bat_wood") || StrEqual(sWeapon"tf_weapon_jar") || StrEqual(sWeapon"tf_weapon_jar_milk") || StrEqual(sWeapon"tf_weapon_fireaxe") || StrEqual(sWeapon"tf_weapon_lunchbox") || StrEqual(sWeapon"tf_weapon_crossbow"))
            return 
Plugin_Handled;
    }

    return 
Plugin_Continue;
}

public 
Action:BuildingTakeDamage(building, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if (
attacker || attacker MaxClients)
    {
        return 
Plugin_Continue;
    }
    new 
String:classname[64];
    
GetEntityClassname(buildingclassnamesizeof(classname));
    if (
StrEqual(classname"obj_sentrygun"false) || StrEqual(classname"obj_dispenser"false) || StrEqual(classname"obj_teleporter"false))    // make sure it is a building
    
{
        if(
ClientIsBuddah[attacker])
        {
        
damage 0;
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;
}

public 
Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{
    
decl String:weapon[32];
    
GetClientWeapon(attackerweaponsizeof(weapon));

    if (
attacker || attacker MaxClients || client == attacker)
    {
        return 
Plugin_Continue;
    }

    if (
ClientIsBuddah[attacker] || ClientIsBuddah[client])
    {
        
damage 0;
        return 
Plugin_Handled;
    }

    return 
Plugin_Continue;

If you use this plugin please post here and let me know what you think

NOTE: You have to restart the current map after adding this plugin. You can also restart your server if you want.
Reason: SDKhooks checks damage by attaching a hook to a player when that player joins the game. If you start the plugin when the server/map is already going it will not attach the hook.

If you are curious about the plugin:
People like to be "friendly" on the server that I am an admin on. I have it set to admin flag "d" or the ban flag here because of possible abuse by non admins. People will find any way to abuse anything. (Ex: Turning friendly off right next to a player on the other team and killing them, then turning friendly back on right after they do so.)
They like to sit around and rocket jump or just sit and stare at each other (idk) and not kill or be killed by others. I have a lot of complaints about people killing other people that are trying to be friendly. This plugin should help the people that want to be friendly and still allow them to rocket jump/sticky jump without getting hurt from fall damage and at the same time not abusing buddha by killing other people while they are using it. I just felt like making this plugin for fun. I am happy with it. I used it on the server that I am an admin on for a little while but people can and will find any way to abuse it. So here is the code open for anyone to use/alter/do whatever they want with. Thanks for using/anything you do with it.

Last edited by Dyl0n; 09-07-2012 at 01:40.
Dyl0n is offline
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 08-31-2012 , 18:59   Re: [TF2] Remove Damage Plugin
Reply With Quote #2

This should work in some ways but I didn't test. No commands atm but I think someone else can write that for you, too tired at the moment =|
PHP Code:
#pragma semicolon 1

#include <sourcemod>

new Handle:cvarEnabled;
new 
Handle:cvarDamage;

public 
OnPluginStart()
{
    
cvarEnabled CreateConVar("sm_player_damage_enabled""1""Enabled no damage mod.\n0 = Disabled\n1 = Enabled"FCVAR_PLUGINtrue0.0true1.0);
    
cvarDamage CreateConVar("sm_player_damage""0""Set damage of attacks from players."FCVAR_PLUGINtrue0.0);
}

public 
Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{
    if(!
GetConVarBool(cvarEnabled) || !IsValidClient(client) || !IsValidClient(attacker) || client == attacker)
    {
        return 
Plugin_Continue;
    }
    
damage GetConVarFloat(cvarDamage);
    return 
Plugin_Continue;
}

stock IsValidClient(client)
{
    if(
client && client <= MaxClients && IsClientInGame(client))
    {
        return 
true;
    }
    return 
false;


Last edited by ReFlexPoison; 08-31-2012 at 18:59.
ReFlexPoison is offline
Dyl0n
Member
Join Date: Oct 2011
Old 08-31-2012 , 19:05   Re: [TF2] Remove Damage Plugin
Reply With Quote #3

Wow, extremely fast response. Thanks, I'll see if I can change anything from there.
Dyl0n is offline
Dyl0n
Member
Join Date: Oct 2011
Old 08-31-2012 , 20:03   Re: [TF2] Remove Damage Plugin
Reply With Quote #4

This is what I have so far and cannot get it to work.
It compiles fine. I have it set to enable buddha when someone types !friendly and it uses a bool to say if the client is buddha (true/false) and when they are buddha it should set damage to 0.0

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdkhooks>

new bool:ClientIsBuddah[MAXPLAYERS+1] = {false, ...};

new 
Handle:cvarEnabled;
new 
Handle:cvarDamage;

public 
OnPluginStart()
{
    
cvarEnabled CreateConVar("sm_player_damage_enabled""1""Enabled no damage mod.\n0 = Disabled\n1 = Enabled"FCVAR_PLUGINtrue0.0true1.0);
    
cvarDamage CreateConVar("sm_player_damage""0""Set damage of attacks from players."FCVAR_PLUGINtrue0.0);
    
RegAdminCmd("sm_friendly"OnToggleFriendlyADMFLAG_RESERVATION"Toggles friendly on/off");
}

public 
Action:OnToggleFriendly(clientargs)
{
        if (
ClientIsBuddah[client] == true) {
            
ClientIsBuddah[client] = false;
        
ServerCommand("sm_friendlybuddha #%d 0"GetClientUserId(client));
        
ReplyToCommand(client"Freindly mode disabled.");
        }
        else {
            
ClientIsBuddah[client] = true;
        
ServerCommand("sm_friendlybuddha #%d 1"GetClientUserId(client));
        
ReplyToCommand(client"Friendly mode enabled.");
        }
    return 
Plugin_Handled;
}  

public 
OnClientPutInServer(client)
{
    
ClientIsBuddah[client] = false;
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}


public 
Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{
    if(!
GetConVarBool(cvarEnabled) || ClientIsBuddah[attacker] == false || client == attacker)
    {
        return 
Plugin_Continue;
    }
    else
    {
        
damage 0.0;
    }

    return 
Plugin_Continue;


Last edited by Dyl0n; 08-31-2012 at 20:04.
Dyl0n is offline
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 08-31-2012 , 20:50   Re: [TF2] Remove Damage Plugin
Reply With Quote #5

Quote:
Originally Posted by Dyl0n View Post
This is what I have so far and cannot get it to work.
It compiles fine. I have it set to enable buddha when someone types !friendly and it uses a bool to say if the client is buddha (true/false) and when they are buddha it should set damage to 0.0

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdkhooks>

new bool:ClientIsBuddah[MAXPLAYERS+1] = {false, ...};

new 
Handle:cvarEnabled;
new 
Handle:cvarDamage;

public 
OnPluginStart()
{
    
cvarEnabled CreateConVar("sm_player_damage_enabled""1""Enabled no damage mod.\n0 = Disabled\n1 = Enabled"FCVAR_PLUGINtrue0.0true1.0);
    
cvarDamage CreateConVar("sm_player_damage""0""Set damage of attacks from players."FCVAR_PLUGINtrue0.0);
    
RegAdminCmd("sm_friendly"OnToggleFriendlyADMFLAG_RESERVATION"Toggles friendly on/off");
}

public 
Action:OnToggleFriendly(clientargs)
{
        if (
ClientIsBuddah[client] == true) {
            
ClientIsBuddah[client] = false;
        
ServerCommand("sm_friendlybuddha #%d 0"GetClientUserId(client));
        
ReplyToCommand(client"Freindly mode disabled.");
        }
        else {
            
ClientIsBuddah[client] = true;
        
ServerCommand("sm_friendlybuddha #%d 1"GetClientUserId(client));
        
ReplyToCommand(client"Friendly mode enabled.");
        }
    return 
Plugin_Handled;
}  

public 
OnClientPutInServer(client)
{
    
ClientIsBuddah[client] = false;
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}


public 
Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{
    if(!
GetConVarBool(cvarEnabled) || ClientIsBuddah[attacker] == false || client == attacker)
    {
        return 
Plugin_Continue;
    }
    else
    {
        
damage 0.0;
    }

    return 
Plugin_Continue;

Never use ServerCommand() for something like that. I'll write it in a bit.

And I'm curious, why not just use Godmode plugin. There are several of them.

Last edited by ReFlexPoison; 08-31-2012 at 20:51.
ReFlexPoison is offline
Dyl0n
Member
Join Date: Oct 2011
Old 09-01-2012 , 00:52   Re: [TF2] Remove Damage Plugin
Reply With Quote #6

Quote:
Originally Posted by ReFlexPoison View Post
Never use ServerCommand() for something like that. I'll write it in a bit.

And I'm curious, why not just use Godmode plugin. There are several of them.
I'd like to use buddha because people like to rocket jump/sticky jump. I'm pretty sure that the godmode plugins out there do not take away damage done by the person with godmode.

I want it to be this way because people like to be "friendly" on the server that I am an admin on.
They like to sit around and rocket jump or just sit and stare at each other (idk) and not kill or be killed by others. I have a lot of complaints about people killing other people that are trying to be friendly. This plugin should help the people that want to be friendly and still allow them to rocket jump/sticky jump without getting hurt from fall damage and at the same time not abusing buddha by killing other people while they are using it.

Last edited by Dyl0n; 09-01-2012 at 00:53.
Dyl0n is offline
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 09-01-2012 , 01:18   Re: [TF2] Remove Damage Plugin
Reply With Quote #7

Quote:
Originally Posted by Dyl0n View Post
I'd like to use buddha because people like to rocket jump/sticky jump. I'm pretty sure that the godmode plugins out there do not take away damage done by the person with godmode.

I want it to be this way because people like to be "friendly" on the server that I am an admin on.
They like to sit around and rocket jump or just sit and stare at each other (idk) and not kill or be killed by others. I have a lot of complaints about people killing other people that are trying to be friendly. This plugin should help the people that want to be friendly and still allow them to rocket jump/sticky jump without getting hurt from fall damage and at the same time not abusing buddha by killing other people while they are using it.
SetEntProp(client, Prop_Data, "m_takedamage", 1, 1);

Damage acts the same however the client doesn't loose hp.
ReFlexPoison is offline
Dyl0n
Member
Join Date: Oct 2011
Old 09-01-2012 , 01:51   Re: [TF2] Remove Damage Plugin
Reply With Quote #8

Quote:
Originally Posted by ReFlexPoison View Post
SetEntProp(client, Prop_Data, "m_takedamage", 1, 1);

Damage acts the same however the client doesn't loose hp.
I am saying that I don't want the person that has godmode/buddha doing damage to other people. I think I have figured it out and have it working now.

This compiles and I have tested it. It works great. If someone uses this plugin they would need to use SDKhooks and make sure that they reload the map or restart the server.

After someone types !friendly they have buddha and cannot damage other players.
The only other thing that would help now is having a timer that prevents someone from abusing it by turning it off and on real fast to kill someone.

SEE POST 1 FOR CURRENT CODE -> http://forums.alliedmods.net/showpos...47&postcount=1

EDIT: works amazingly. Thanks for your help ReFlexPoison

Last edited by Dyl0n; 09-07-2012 at 01:01.
Dyl0n is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 12-06-2012 , 23:35   Re: [TF2] Remove Damage Plugin
Reply With Quote #9

Abuse could easily be prevented by having friendly mode only be toggle-able while in a respawn room. If the player is not within a func_respawnroom, then sm_Friendly either does nothing, or slays the player and returns him to spawn before toggling. (perhaps this could be controlled by a cvar)

Also, some sort of outer indication of a player's friendlyness would be nice. Perhaps some sort of semi-transparency. The ideal for my own server would be if friendlies had complete invisibility in the eyes on non-friendlies.

Last edited by ddhoward; 12-06-2012 at 23:39.
ddhoward is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 04-11-2013 , 03:12   Re: [TF2] Remove Damage Plugin
Reply With Quote #10

Made a few changes to the plugin, uploading them here for my own sanity. Hoping to make more changes, clean up the existing code, and use this as an opportunity to learn this shit. Not really gunning for "approved" status just yet lol. Will make a new thread with better documentation if it ever comes to that.

Changes made so far:
  • A friendly user who disables friendly mode will be slain (slapped for 10,000 damage). This prevents abuse of friendly mode.
  • A friendly Engineer who leaves friendly mode will have their sentry destroyed. This prevents a "friendly sentry" suddenly becoming hostile when it's Engineer dies and leaves friendly mode. TF2-centric change.
  • Removed the "remember friendly mode" option. Players will have to manually re-enable it upon spawning.

EDIT: continuing modifications here: http://forums.alliedmods.net/showthread.php?t=213205
Attached Files
File Type: smx friendly.smx (4.9 KB, 250 views)
File Type: sp Get Plugin or Get Source (friendly.sp - 605 views - 4.8 KB)

Last edited by ddhoward; 04-16-2013 at 16:38.
ddhoward 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:03.


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