View Single Post
DeathChaos25
Senior Member
Join Date: Jan 2014
Location: Puerto Rico
Old 03-27-2015 , 19:56   Re: [EXTENSION] [L4D2] Defibrillator Bug Fix (on servers higher than 8 players) [1.0.
Reply With Quote #198

Quote:
Originally Posted by Marcus101RR View Post
Tested it, and it does the same thing, did not revive the additional bots. Still replaces the same player with clones. I downloaded it, and did not use any txt file or other files. Come to think of it, its not even loading on my meta list:


] meta list
[01] L4DToolZ (1.0.0.9h-unknown) by Ivailosp
[02] SourceMod (1.7.0) by AlliedModders LLC
[03] SDK Tools (1.7.0) by AlliedModders LLC
[04] SDK Hooks (1.7.0) by AlliedModders LLC
Try using my Death Animations restore plugin and enable ragdoll deaths (they are enabled by default if it's the first time you use the plugin)

PHP Code:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* [L4D2] Death Animations Restore

* About : This plugin restores the Survivor Death Animations while
* also fixing the bug where the animations would endlessly loop and
* the survivors would never actually die

* =============================
* ===      Change Log       ===
* =============================
* Version 1.0    2014-09-02  (48 views)
* - Initial Release
* =============================
* Version 1.1    2014-09-05
* - Semi Major code re-write, moved from using a "player_hurt" event hook
*   to SDK_Tools OnTakeDamagePost (Huge thanks to Mr.Zero for that, as he did most of it)

* - Hopefully, there should no longer be any cases were survivors
*   endlessly loop through their death animations and never die
* =============================
* Version 1.3     2014-09-09
* - Survivors are no longer able to perform any actions while
*   in the middle of their death animations  (except vocalizing under certain circumstances).
* =============================
* Version 1.4    03-25-2015
* - Complete Plugin Rewrite, this plugin no longer uses shitty damage detection!
* - This plugin will now ALWAYS 100% Guarantee work as intended, this is done by the new check
* - The plugin now instead of predicting when you die, it will instead check for clients
*   to see if they are in the dying animation instead, this means now players will only
*   die when the game decides it and this thus removes any and all faulty damage detections
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


#include <sourcemod> 
#include <sdkhooks> 
#include <l4d_stocks>
#include <defibfix>

#define DEBUG 0

#define PLUGIN_VERSION "1.4" 
#define PLUGIN_NAME "[L4D2] Restore Survivor Death Animations" 

static const String:MODEL_NICK[]         = "models/survivors/survivor_gambler.mdl";
static const 
String:MODEL_ROCHELLE[]         = "models/survivors/survivor_producer.mdl";
static const 
String:MODEL_COACH[]         = "models/survivors/survivor_coach.mdl";
static const 
String:MODEL_ELLIS[]         = "models/survivors/survivor_mechanic.mdl";
static const 
String:MODEL_BILL[]         = "models/survivors/survivor_namvet.mdl";
static const 
String:MODEL_ZOEY[]         = "models/survivors/survivor_teenangst.mdl";
static const 
String:MODEL_FRANCIS[]         = "models/survivors/survivor_biker.mdl";
static const 
String:MODEL_LOUIS[]         = "models/survivors/survivor_manager.mdl";

static 
bool:g_bIsRagdollDeathEnabled 
static bool:g_bIsSurvivorInDeathAnimation[MAXPLAYERS+1] = false 

public Plugin:myinfo =  

    
name        PLUGIN_NAME
    
author        "DeathChaos25"
    
description    "Restores the Death Animations for survivors while fixing the bug where the animation would loop endlessly and the survivors would never die."
    
version        PLUGIN_VERSION
    
url        "https://forums.alliedmods.net/showthread.php?t=247488"


public 
OnPluginStart() 

    
SetConVarInt(FindConVar("survivor_death_anims"), 1
    
    
CreateTimer(0.1TimerUpdate_TIMER_REPEAT);
    new 
Handle:RagdollDeathEnabled CreateConVar("enable_ragdoll_death""1""Enable Ragdolls upon Death? 0 = Disable Ragdoll Death, 1 = Enable Ragdoll Death"FCVAR_PLUGINtrue0.0true1.0)  
    
HookConVarChange(RagdollDeathEnabledConVarRagdollDeathEnabled)  
    
g_bIsRagdollDeathEnabled GetConVarBool(RagdollDeathEnabled)  
    
HookEvent("defibrillator_begin"DefibStart_Event);
    
AutoExecConfig(true"l4d2_death_animations_restore")  ;
    
HookEvent("weapon_fire"Event_WeaponFire);


public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
}

public 
OnAllPluginsLoaded()
{
    for (new 
client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client) && GetClientTeam(client) == 2)
        {
            
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
        }
    }
}  

public 
Action:TimerUpdate(Handle:timer)
{
    if (!
IsServerProcessing()) return Plugin_Continue;
    
    for (new 
i=1i<=MaxClientsi++)
    {
        if (
IsSurvivor(i) && IsPlayerAlive(i) && !g_bIsSurvivorInDeathAnimation[i])
        {
            new 
i_CurrentAnimation GetEntProp(iProp_Send"m_nSequence");
            
decl String:model[PLATFORM_MAX_PATH];
            
GetClientModel(imodelsizeof(model));
            
            
// Zoey & Francis Death Animation is 555
            // Louis & Bill Death Animation is 552
    
            // Nick Death Animation is 644
            // Ellis Death Animation is 649
            // Coach Death Animation is 638
            // Rochelle Death Animation is 652
            
            
if(i_CurrentAnimation == 555 && StrEqual(modelMODEL_FRANCISfalse)
            || 
i_CurrentAnimation == 555 && StrEqual(modelMODEL_ZOEYfalse)
            || 
i_CurrentAnimation == 552 && StrEqual(modelMODEL_BILLfalse
            || 
i_CurrentAnimation == 552 && StrEqual(modelMODEL_LOUISfalse)
            || 
i_CurrentAnimation == 644 && StrEqual(modelMODEL_NICKfalse)
            || 
i_CurrentAnimation == 649 && StrEqual(modelMODEL_ELLISfalse)
            || 
i_CurrentAnimation == 638 && StrEqual(modelMODEL_COACHfalse)
            || 
i_CurrentAnimation ==  652 && StrEqual(modelMODEL_ROCHELLEfalse))
            {
                
g_bIsSurvivorInDeathAnimation[i] = true
                CreateTimer
(3.03ForcePlayerSuicideTimerGetClientUserId(i), TIMER_FLAG_NO_MAPCHANGE
                return 
Plugin_Continue
            
}
        }
    }
    return 
Plugin_Continue;
}

public 
Action:ForcePlayerSuicideTimer(Handle:timerany:userid

    new 
client GetClientOfUserId(userid
    if (
client MaxClients || !IsClientInGame(client)) 
        return 
Plugin_Continue
    
    
if (g_bIsRagdollDeathEnabled == true) { 
        
        
SetEntProp(clientProp_Send"m_isFallingFromLedge"1
        
        new 
weapon GetPlayerWeaponSlot(client1
        if (
weapon && IsValidEntity(weapon)) { 
            
SDKHooks_DropWeapon(clientweapon// Drop their secondary weapon since they cannot be defibed 
        

        
// This section will be re-enabled later if/when spummer
        // publicly releases the new defibfix
        
        // Now we create a static death model for this person
        // this is simply compatibility
        // with mournfix
        
        // EDIT : Spummer compiled a new defibfix, THIS PLUGINS
        // DEATHMODELS ARE NOW LEGIT, THEY WORK CORRECTLY WOOT
        
        
new entity;
        new 
String:modelname[128];
        
GetEntPropString(clientProp_Data"m_ModelName"modelname128);
        
        
entity CreateEntityByName("survivor_death_model");
        
SetEntityModel(entitymodelname);
        
        new 
Float:g_Origin[3];
        new 
Float:g_Angle[3];
        
        
GetClientAbsOrigin(clientg_Origin);
        
GetClientAbsAngles(clientg_Angle);
        
        
TeleportEntity(entityg_Origing_AngleNULL_VECTOR);
        
DispatchSpawn(entity);
        
SetEntityRenderMode(entityRENDER_NONE);
        
DefibFix_AssignPlayerDeathModel(cliententity);
        new 
character_type GetEntProp(clientProp_Send"m_survivorCharacter")
        
SetEntProp(entityProp_Send"m_nCharacterType"character_type);
        
#if DEBUG
        
{
            
decl String:message[PLATFORM_MAX_PATH]="";
            
Format(messagesizeof(message), "Client %N has been slain because he was in Dying Animation!"client);
            
PrintToChatAll(message);
        }
        
#endif
    

    
    
ForcePlayerSuicide(client
    
g_bIsSurvivorInDeathAnimation[client] = false 
    
    
return Plugin_Continue 


public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:ang[3], &weapon)
{
    if (!
IsClientInGame(client) || L4DTeam:GetClientTeam(client) != L4DTeam_Survivor || !IsPlayerAlive(client) || !g_bIsSurvivorInDeathAnimation[client]) 
        return 
Plugin_Continue
    
return Plugin_Handled
}  

public 
ConVarRagdollDeathEnabled(Handle:convar, const String:oldValue[], const String:newValue[]) 

    
g_bIsRagdollDeathEnabled GetConVarBool(convar)  
}

stock bool:IsSurvivor(client)
{
    new 
maxclients GetMaxClients();
    if (
client && client maxclients && IsClientInGame(client) && GetClientTeam(client) == 2)
    {
        return 
true;
    }
    return 
false;
}

// blocks weapon change when in dying animation
public Action:OnWeaponSwitch(clientweapon)
{
    if (
IsSurvivor(client) && IsPlayerAlive(client))
    {
        if (
g_bIsSurvivorInDeathAnimation[client])
        {
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;
}

public 
DefibStart_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
subject GetClientOfUserId(GetEventInt(event"subject"));
    
#if DEBUG
    
{
        
//SetEntProp(client, Prop_Send, "m_reviveTarget", subject);
        
decl String:message[PLATFORM_MAX_PATH]="";
        
Format(messagesizeof(message), "Player %N is reviving Player %N with a Defib!"clientsubject);
        
PrintToChatAll(message);
    }
    
#endif
}

// Even with all the checks and action blocks, survivors are still able to attempt to use
// medkits while in the death animation, and while they can't heal they can still
// interrupt the death animation, so we use weapon_fire to (hopefully) stop that
public Action:Event_WeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
{        
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (!
IsSurvivor(client))
    {
        return 
Plugin_Continue
    
}
    
    if (
g_bIsSurvivorInDeathAnimation[client])
    {
        
#if DEBUG
        
{
            
decl String:message[PLATFORM_MAX_PATH]="";
            
Format(messagesizeof(message), "Player %N is trying to use a weapon while in Death Animation!"client);
            
PrintToChatAll(message);
        }
        
#endif
        
return Plugin_Handled
    
}    
    return 
Plugin_Continue

With ragdoll deaths I create a custom invisible death model and manually assign it to the player it should belong to.
I'm still trying to work out the incorrect names issue, but I assure you it works 100% as intended and does not revive the wrong player.
Attached Files
File Type: sp Get Plugin or Get Source ([L4D2] Death Animations Restore.sp - 338 views - 9.3 KB)
File Type: smx [L4D2] Death Animations Restore.smx (8.0 KB, 412 views)
__________________

Last edited by DeathChaos25; 08-05-2015 at 09:12.
DeathChaos25 is offline