AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Request - l4d2 reflect damage plugin (https://forums.alliedmods.net/showthread.php?t=301815)

wendigo 10-05-2017 14:52

Request - l4d2 reflect damage plugin
 
I need a reflect damage plugin for my l4d2 server. I know there are 1 or 2 out there. But they are outdated, and doesnt offer what I need. I dont have the time or experience to do this myself.
So I am kindly asking a programmer or just someone with great knowldege, to help me out?
I do have some leftovers from an old plugin in .smx format on my desktop. But dont know if I'm allowed to attach it?

I need a reflect damage plugin for l4d2, for my server. The old plugin I got, is the one attached.


.....These items below, must be left unchanged. In other words, default settings:

-Molotov

-Pipebomb

-Gas can

-Propane


.....Stuff this reflect damage plugin must and needs to cover:

-Melee damage from all weapons (chainsaw also included)

-Grenade launcher

-Normal bullet and greande damage from weapons

-Incendiary ammo for all weapons

-Explosive ammo for all weapons

Bacardi 10-06-2017 02:59

Re: Request - l4d2 reflect damage plugin
 
Reflect damage all players or teammates ??

PHP Code:

#include <sdktools>
#include <sdkhooks>

public void OnPluginStart()
{
    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i)) OnClientPutInServer(i);
    }

}

public 
void OnClientPutInServer(client)
{
    
SDKHookEx(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype)
{
    if( !(
attacker <= MaxClients) || !IsClientInGame(attacker) || victim == attacker) return Plugin_Continue;

    if(
GetClientTeam(victim) == GetClientTeam(attacker))
    {
        
int weapon GetEntPropEnt(attackerProp_Send"m_hActiveWeapon");

        if(
attacker != inflictorweapon inflictor;

        
char classname[MAX_NAME_LENGTH];
        
GetEntityClassname(weaponclassnamesizeof(classname));

        if(
StrEqual(classname"inferno"false) || StrEqual(classname"pipe_bomb_projectile"false)) return Plugin_Continue;

        
//PrintToServer("classname %s", classname);
        //inferno
        //pipe_bomb_projectile

        
SDKHooks_TakeDamage(attackerinflictorattackerdamagedamagetypeweapon);

        
damage 0.0;
        return 
Plugin_Changed;
    }

    return 
Plugin_Continue;



wendigo 10-06-2017 13:44

Re: Request - l4d2 reflect damage plugin
 
I use my server as co-op only, so I just need teammates?

Bacardi 10-06-2017 13:47

Re: Request - l4d2 reflect damage plugin
 
Ok. Try that version what I posted.
I did it in hurry...

wendigo 10-06-2017 14:55

Re: Request - l4d2 reflect damage plugin
 
Thanks man. I'll upload it straight away and see how it goes :up:

wendigo 10-07-2017 17:41

Re: Request - l4d2 reflect damage plugin
 
I'm not sure if its related to the plugin. But I uploaded the plugin yesterday and around 1½ hour later my server crashed. It has never crashed before.
How do I know if this plugin causes the issue?
Can I check logs? If yes, what kinds of logs?

Bacardi 10-07-2017 17:49

Re: Request - l4d2 reflect damage plugin
 
Hmmm, try comment with double slash that take damage part.
//SDKHooks_TakeDamage
And try again, will it still crash?

*edit.
Maybe invalid weapon index -1 had passed through code...
I look later, need to go work.

Sourcemod logs

wendigo 10-15-2017 12:21

Re: Request - l4d2 reflect damage plugin
 
Cheers.
I really appreciate you are taking the time to help me with this plugin.
I'll upload the plugin again.

Bonus questions:
1) Is it possible to make the plugin bypass when a survivor is getting pinned by a special infected? It is very hard to save a fellow survivor from a hunter, without getting the damage reflected to yourself in the process.

2) Admin bypass, so admin can still harm survivors. Possible?

Bacardi 10-16-2017 09:36

Re: Request - l4d2 reflect damage plugin
 
1) yes, but after you said, server crashed because
2nd post plugin, I suggest remove SDKHooks_TakeDamage part. It not give dmg after this.
To see will it still crash.

2) yes possible.

...I'm little busy at work. Last two nights have been 16 hours.
I edit later or someone another can help to do this also.

Bacardi 10-17-2017 18:39

Re: Request - l4d2 reflect damage plugin
 
Updated. I added SDKHook_TakeDamage back.
And check is attacker still alive and weapon have not null index.
Added some pinned checks

PHP Code:

#include <sdktools>
#include <sdkhooks>

bool IsAdmin[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && IsClientAuthorized(i)) OnClientPostAdminCheck(i);
    }

}

public 
void OnClientPostAdminCheck(client)
{
    
SDKHookEx(clientSDKHook_OnTakeDamageOnTakeDamage);
    
IsAdmin[client] = CheckCommandAccess(client"sm_admin"ADMFLAG_GENERIC);
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype)
{
    if( !(
attacker <= MaxClients) || !IsClientInGame(attacker) || victim == attacker || IsAdmin[attacker]) return Plugin_Continue;

    if(
GetClientTeam(victim) == GetClientTeam(attacker))
    {
        
int weapon GetEntPropEnt(attackerProp_Send"m_hActiveWeapon");

        if(
attacker != inflictorweapon inflictor;

        
// Fix bug?
        
if(!IsPlayerAlive(attacker) || weapon == -1) return Plugin_Handled;

        
char classname[MAX_NAME_LENGTH];
        
GetEntityClassname(weaponclassnamesizeof(classname));

        if(
StrEqual(classname"inferno"false) || StrEqual(classname"pipe_bomb_projectile"false)) return Plugin_Continue;

        
//PrintToServer("classname %s %f", classname, damage);
        //inferno
        //pipe_bomb_projectile

        
if(  GetEntPropEnt(victimProp_Send"m_pounceAttacker") == -&& // hunter
             
GetEntPropEnt(victimProp_Send"m_jockeyAttacker") == -&& // jockey
             
GetEntPropEnt(victimProp_Send"m_tongueOwner") == -&& // tongue
             
GetEntPropEnt(victimProp_Send"m_carryAttacker") == -&& // charger
             
GetEntPropEnt(victimProp_Send"m_pummelAttacker") == -&& // charger ??
            
!GetEntProp(victimProp_Send"m_isIncapacitated") &&
            !
GetEntProp(victimProp_Send"m_isHangingFromLedge") )
            {
                
SDKHooks_TakeDamage(attackerinflictorattackerdamagedamagetypeweapon);
                
//PrintToServer("-classname %s %f", classname, damage);
            
}

        
damage 0.0;
        return 
Plugin_Changed;
    }

    return 
Plugin_Continue;




All times are GMT -4. The time now is 09:29.

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