Quote:
Originally Posted by spumer
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.1, TimerUpdate, _, TIMER_REPEAT);
new Handle:RagdollDeathEnabled = CreateConVar("enable_ragdoll_death", "1", "Enable Ragdolls upon Death? 0 = Disable Ragdoll Death, 1 = Enable Ragdoll Death", FCVAR_PLUGIN, true, 0.0, true, 1.0)
HookConVarChange(RagdollDeathEnabled, ConVarRagdollDeathEnabled)
g_bIsRagdollDeathEnabled = GetConVarBool(RagdollDeathEnabled)
AutoExecConfig(true, "l4d2_death_animations_restore")
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
}
public OnAllPluginsLoaded()
{
for (new client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client) && GetClientTeam(client) == 2)
{
SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
}
}
}
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=1; i<=MaxClients; i++)
{
if (IsSurvivor(i) && IsPlayerAlive(i) && !g_bIsSurvivorInDeathAnimation[i])
{
new i_CurrentAnimation = GetEntProp(i, Prop_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.03, ForcePlayerSuicideTimer, GetClientUserId(i), TIMER_FLAG_NO_MAPCHANGE)
return Plugin_Continue
}
}
}
return Plugin_Continue;
}
public Action:ForcePlayerSuicideTimer(Handle:timer, any:userid)
{
new client = GetClientOfUserId(userid)
if (client > MaxClients || !IsClientInGame(client))
return Plugin_Continue
if (g_bIsRagdollDeathEnabled == true) {
SetEntProp(client, Prop_Send, "m_isFallingFromLedge", 1)
new weapon = GetPlayerWeaponSlot(client, 1)
if (weapon > 0 && IsValidEntity(weapon)) {
SDKHooks_DropWeapon(client, weapon) // 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(client, Prop_Data, "m_ModelName", modelname, 128);
entity = CreateEntityByName("survivor_death_model");
SetEntityModel(entity, modelname);
new Float:g_Origin[3];
new Float:g_Angle[3];
GetClientAbsOrigin(client, g_Origin);
GetClientAbsAngles(client, g_Angle);
TeleportEntity(entity, g_Origin, g_Angle, NULL_VECTOR);
DispatchSpawn(entity);
SetEntityRenderMode(entity, RENDER_NONE);
DefibFix_AssignPlayerDeathModel(client, entity);
}
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, &impulse, Float: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 > 0 && client < maxclients && IsClientInGame(client) && GetClientTeam(client) == 2)
{
return true;
}
return false;
}
// blocks weapon change when in dying animation
public Action:OnWeaponSwitch(client, weapon)
{
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.
__________________