View Single Post
SEGA EMPRESS ERIS
Senior Member
Join Date: Sep 2010
Location: THE-MILKY-WAY-GALAXY
Old 02-25-2021 , 20:20   Re: L4D2 Custom Weapon Reload Animation Bug (Any Fix?)
Reply With Quote #6

Quote:
Originally Posted by SpaceWashingMachine View Post
Right yeah sorry I just extracted the code from another plugin of mine, here try this:
PHP Code:
#include <sourcemod>

public Plugin:myinfo 
{
    
name "[L4D2] Reload Animation Fix",
    
author "SpaceWashingMachine",
    
description "Fixes reload animations sometimes playing again after reload ends.",
    
version "1.0",
    
url ""
}

public 
OnPluginStart()
{
     
HookEvent("weapon_reload"ReloadAnimFix); 
}

public 
ReloadAnimFix(Handle:hEventString:sName[], bool:bDontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(hEvent"userid"));
    new 
weapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon");

    
CreateTimer(0.1timerFixReloadAnimEntIndexToEntRef(weapon), TIMER_FLAG_NO_MAPCHANGE TIMER_REPEAT);
}

public 
Action:timerFixReloadAnim(Handle:timerany:ref)
{
    new 
weapon EntRefToEntIndex(ref);
    if(
weapon == INVALID_ENT_REFERENCE || weapon <= MaxClients || !IsValidEntity(weapon))
        return 
Plugin_Stop;

    if(
GetEntProp(weaponProp_Send"m_bInReload") == 0)
    {
        
SetEntPropFloat(weaponProp_Send"m_flTimeWeaponIdle"GetGameTime() + 2.0);
        return 
Plugin_Stop;
    }

    return 
Plugin_Continue;

Thanks this one worked. is there a plugin for custom weapon reload animations too? to match custom reload speeds or the default if they arent sychronized?

thank you for your time. <3
__________________
SEGA EMPRESS ERIS is offline