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

Quote:
Originally Posted by spumer View Post
When you create death model entity you set the character type or not?

Also, i fix name logging. In original version this looks like like this:
[DefibFix] Found player (%N)11, distance -2.000000 .
Now name should be logged correctly.
Well, here is the code for the plugin I am currently using to test this;
PHP Code:
#include <sourcemod> 
#include <sdkhooks> 
#include <l4d_stocks>
#include <defibfix>

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

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)  
    
    
AutoExecConfig(true"l4d2_death_animations_restore")  


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;
    
    
// 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
    
    
for (new i=1i<=MaxClientsi++)
    {
        if (
IsSurvivor(i) && IsPlayerAlive(i) && !g_bIsSurvivorInDeathAnimation[i])
        {
            new 
i_CurrentAnimation GetEntProp(iProp_Send"m_nSequence");
            if(
i_CurrentAnimation == 555 || i_CurrentAnimation == 552 || i_CurrentAnimation == 644 || i_CurrentAnimation == 649 || i_CurrentAnimation == 638 || i_CurrentAnimation ==  652)
            {
                
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);
    } 
    
    
ForcePlayerSuicide(client
    
g_bIsSurvivorInDeathAnimation[client] = false 
    
    
return Plugin_Continue 


// block all player actions if they're in the dying animation
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;

It's basically a modified version of this to go with this extension.
How would I go about setting character type to get the correct names to show up?

Also, If anyone wants to test this plugin and compile it, ragdoll deaths are the default as I made it with this extension's fix in mind (it works!), I just need to know how to assign their names correctly and we're golden.
__________________
DeathChaos25 is offline