Raised This Month: $ Target: $400
 0% 

Solved [L4D2] Survivors can't jump after being hit


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Forgetest
Member
Join Date: Aug 2020
Old 04-17-2023 , 03:53   Re: [L4D2] Survivors can't jump after being hit
Reply With Quote #8

Seems messed up with the wrong prop, should be m_jumpSupressedUntil.

Code:
SetEntPropFloat(client, Prop_Send, "m_jumpSupressedUntil", -1.0);
And there's no reason to use a repeat timer. Attached below is a sample plugin, hope it helps for your scripting.

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdkhooks> // SDKHook_OnTakeDamagePost

bool g_bLateLoad// whether map has started when this plugin is loaded

public APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    switch (
GetEngineVersion())
    {
    case 
Engine_Left4DeadEngine_Left4Dead2// L4D & 2 only
        
{
            
g_bLateLoad late;
            return 
APLRes_Success;
        }
    }
    
    
strcopy(errorerr_max"Plugin supports L4D & 2 only.");
    return 
APLRes_Failure;
}

public 
void OnPluginStart()
{
    if (
g_bLateLoad)
    {
        
// find all clients in game and hook them all since we're late here
        
for (int i 1<= MaxClients; ++i)
        {
            if (
IsClientInGame(i)) OnClientPutInServer(i);
        }
    }
}

// calls whenever a client joins, bot or human
public void OnClientPutInServer(int client
{
    
SDKHook(clientSDKHook_OnTakeDamagePostSDK_OnTakeDamage_Post);
}

// a sdkhook that calls whenever a player takes any damage, like punched by CI
void SDK_OnTakeDamage_Post(int victimint attackerint inflictorfloat damageint damagetype)
{
    if (!
IsClientInGame(victim)) // who cares
        
return;
    
    
// Generally incapped and dead players are immovable so we just ignore here
    
if (IsIncapacitated(victim) || !IsPlayerAlive(victim))
        return;
    
    
// If the player cannot jump after hit,
    
if (GetGameTime() < GetEntPropFloat(victimProp_Send"m_jumpSupressedUntil"))
    {
        
// invalidates the timestamp so the player can jump again.
        
SetEntPropFloat(victimProp_Send"m_jumpSupressedUntil", -1.0);
    }
}

stock bool IsIncapacitated(int client)
{
    return 
view_as<bool>(GetEntProp(clientProp_Send"m_isIncapacitated"1));


Last edited by Forgetest; 04-17-2023 at 03:56.
Forgetest is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:07.


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