Raised This Month: $51 Target: $400
 12% 

Solved L4D / Disable Jumps in deep water


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 08-08-2020 , 14:25   L4D / Disable Jumps in deep water
Reply With Quote #1

Hi,

I would like to have a plugin to find out if a survivor player is in "deep" water (deadly) and not in light water (walkable) and then disable the jump button if in deep water in order to disable the "water hopping" spam.

I find it rather annoying to have people jumping into deep water in sacrafice and constantly spam jump to not drown.

They just float away out of reach of infected.

So the plugin should check for Player in deep water, if yes, then disable jump and post a chat to all that the player was attempting to bully.

Thx in Advance.
__________________

Last edited by finishlast; 08-13-2020 at 13:57.
finishlast is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 08-09-2020 , 00:05   Re: L4D / Disable Jumps in deep water
Reply With Quote #2

I found some useful netclass that could help you.
"m_nWaterLevel" and "m_fFlags"

PHP Code:
public Action OnPlayerRunCmd(int clientint &buttonsint &impulse)
{
    if( 
GetClientTeam(client) == && IsPlayerAlive(client) )
    {
        
int iWaterLevel GetEntProp(clientProp_Send"m_nWaterLevel"); // detect how much of client body is under water.
        
int iOnTheGround GetEntProp(clientProp_Data"m_fFlags") & FL_ONGROUND// detect client is on the ground or not.
        
PrintToChatAll("client %N, m_nWaterLevel %d, OnTheGround %d"clientiWaterLeveliOnTheGround);
        if( 
iWaterLevel >= 1// 0: no water, 1: a little, 2: half body, 3: full body under water
        
{
            if(
iOnTheGround == 0// 1: on the ground, 0: not on the ground
            
{
                if( 
buttons IN_JUMP // player uses jump key
                
{
                    
buttons &= ~IN_JUMP//block jump key
                
}
            }
        }
    }
    return 
Plugin_Continue;

__________________

Last edited by HarryPotter; 08-09-2020 at 00:05.
HarryPotter is offline
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 08-09-2020 , 07:15   Re: L4D / Disable Jumps in deep water
Reply With Quote #3

Hey thanks once again!

I found out blocking jump wasn't really doing the trick, it seems like initially jumping into deep water is always >=2.

So I just force suicide on a Player, when he jumps into water and press jump again.

If he does not press jump he just drowns normally.

Seems to work ok, I will do some more testing.

PHP Code:
#pragma semicolon 1
#pragma newdecls required 

#include <sourcemod>
#include <sdktools>

public Plugin myinfo =
{
    
// Based completely on fbef0102 idea how to determine water contact and jump
    
name "l4d_no_deep_water_jumps",
    
author "finishlast",
    
description "Prevents player from jumping on deep water. Player get's killed when trying to jump.",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=326618"
};

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max
{
    
EngineVersion test GetEngineVersion();   
    if (
test != Engine_Left4Dead && test != Engine_Left4Dead2) {
    
strcopy(errorerr_max"Plugin only supports Left 4 Dead 1 & 2.");
    return 
APLRes_SilentFailure;
    }
    return 
APLRes_Success;

}

public 
void OnPluginStart()
{

}

public 
Action OnPlayerRunCmd(int clientint &buttonsint &impulse)
{
    if( 
GetClientTeam(client) == && IsPlayerAlive(client) )
    {
        
int iWaterLevel GetEntProp(clientProp_Send"m_nWaterLevel"); // detect how much of client body is under water.
        
int iOnTheGround GetEntProp(clientProp_Data"m_fFlags") & FL_ONGROUND// detect client is on the ground or not.
        //PrintToChatAll("client %N, m_nWaterLevel %d, OnTheGround %d", client, iWaterLevel, iOnTheGround);
        
if( iWaterLevel >= 2// 0: no water, 1: a little, 2: half body, 3: full body under water
        
{
            if(
iOnTheGround == 0// 1: on the ground, 0: not on the ground
            
{
                if( 
buttons IN_JUMP // player uses jump key
                
{   
            
PrintToChatAll("[SM] %N tried to deep water jump and is regretting it now."client);
            
ForcePlayerSuicide(client);    
                }
            }
        }
    }
    return 
Plugin_Continue;

__________________

Last edited by finishlast; 08-09-2020 at 13:15.
finishlast is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 08-09-2020 , 11:45   Re: L4D / Disable Jumps in deep water
Reply With Quote #4

That code will slay anyone holding the jump key if they fell in water jump is supressed until they left go.

can try using this m_jumpSupressedUntil instead of death

i would just supress jumping until water level is nolonger 3
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 08-09-2020 , 12:51   Re: L4D / Disable Jumps in deep water
Reply With Quote #5

You are right, tested in in DT Boathouse. Silly me.

I will try your idea next. Thanks!

This seems to work.
Had to disable the chat thing or it would give false positives like in Boathouse level.

So this of cause also fixes the jump to speed up in water at boathouse level too…


PHP Code:
#pragma semicolon 1
#pragma newdecls required 

#include <sourcemod>
#include <sdktools>

public Plugin myinfo =
{
    
// Based completely on fbef0102 idea how to determine water contact and jump
    // Lux for m_jumpSupressedUntil idea instead of forceplayersuicide
    
name "l4d_no_deep_water_jumps",
    
author "finishlast",
    
description "Prevents player from jumping on deep water. ",
    
version "1.0",
    
url "https://forums.alliedmods.net/showthread.php?t=326618"
};

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max
{
    
EngineVersion test GetEngineVersion();   
    if (
test != Engine_Left4Dead && test != Engine_Left4Dead2) {
    
strcopy(errorerr_max"Plugin only supports Left 4 Dead 1 & 2.");
    return 
APLRes_SilentFailure;
    }
    return 
APLRes_Success;

}

public 
void OnPluginStart()
{

}

public 
Action OnPlayerRunCmd(int clientint &buttonsint &impulse)
{
    if( 
GetClientTeam(client) == && IsPlayerAlive(client) )
    {
        
int iWaterLevel GetEntProp(clientProp_Send"m_nWaterLevel"); // detect how much of client body is under water.
        
int iOnTheGround GetEntProp(clientProp_Data"m_fFlags") & FL_ONGROUND// detect client is on the ground or not.
        
if( iWaterLevel >= 2// 0: no water, 1: a little, 2: half body, 3: full body under water
        
{
            if(
iOnTheGround == 0// 1: on the ground, 0: not on the ground
            
{
                if( 
buttons IN_JUMP // player uses jump key
                
{   
         
SetEntPropFloat(clientProp_Send"m_jumpSupressedUntil",  GetGameTime() + 0.4);
                }
            }
        }
    }
    return 
Plugin_Continue;

__________________

Last edited by finishlast; 08-15-2020 at 05:50.
finishlast is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 08-09-2020 , 15:02   Re: L4D / Disable Jumps in deep water
Reply With Quote #6

No problem

Personally i use this to detect ground
PHP Code:
if(GetEntPropEnt(entityProp_Send"m_hGroundEntity") != -1//if is touching floor return
    
return; 
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Reply



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 23:35.


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