AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Catch when player touches a wall which blocks you (https://forums.alliedmods.net/showthread.php?t=146580)

meTaLiCroSS 12-29-2010 14:51

Catch when player touches a wall which blocks you
 
Title? :-/

Exolent[jNr] 12-29-2010 14:52

Re: Catch when player touches a wall, but not the floor
 
Hook player touch and check if player is on ground or was on ground.

meTaLiCroSS 12-29-2010 15:01

Re: Catch when player touches a wall, but not the floor
 
Quote:

Originally Posted by Exolent[jNr] (Post 1381865)
Hook player touch and check if player is on ground or was on ground.

That wont work.

What will happen when I touch a wall on mid-air?
What will happen when I touch a wall on ground?

ConnorMcLeod 12-29-2010 15:33

Re: Catch when player touches a wall, but not the floor
 
Why do you want to detect that ?

meTaLiCroSS 12-29-2010 15:54

Re: Catch when player touches a wall, but not the floor
 
Quote:

Originally Posted by ConnorMcLeod (Post 1381909)
Why do you want to detect that ?

I'm doing something like l4d's charger infected. The only thing that I want to do is to catch when while charging he touches a wall for stopping his speed boost.

Another good way that I was thinking is to detect if something is in front of him... but this didn't worked at all:

PHP Code:

register_touch("player""*""fw_Player_Touch")
public 
fw_Player_Touch(iIdiOther)
{
    if(
g_bIsAlive[iId] && g_bBoostActivated[iId] && !IsAlive(iOther))
    {
        
// debug print added here, it's called correctly.
        
static Float:vecOrigin[3], Float:vecDirection[3]
        
entity_get_vector(iIdEV_VEC_originvecOrigin)
        
velocity_by_aim(iId16vecDirection// a little bit ahead him
        
xs_vec_add(vecOriginvecDirectionvecOrigin)
        
        
engfunc(EngFunc_TraceHullvecOriginvecOrigin0HULL_HUMAN /* or HULL_HEAD? */iId0)
    
        if(
get_tr2(0TR_StartSolid) || get_tr2(0TR_AllSolid) || !get_tr2(0TR_InOpen))
        {
                
// Disabling...
        
}
    }



madeitout 12-31-2010 12:39

Re: Catch when player touches a wall, but not the floor
 
maybe calculate the distance to the floor

PHP Code:

stock Float:fm_distance_to_floor(indexignoremonsters 1) {
    new 
Float:start[3], Float:dest[3], Float:end[3];
    
pev(indexpev_originstart);
    
dest[0] = start[0];
    
dest[1] = start[1];
    
dest[2] = -8191.0;

    
engfunc(EngFunc_TraceLinestartdestignoremonstersindex0);
    
get_tr2(0TR_vecEndPosend);

    
pev(indexpev_absminstart);
    new 
Float:ret start[2] - end[2];

    return 
ret ret 0.0;



meTaLiCroSS 03-09-2011 16:15

Re: Catch when player touches a wall, but not the floor
 
Bump.

frk_14 03-10-2011 15:03

Re: Catch when player touches a wall, but not the floor
 
why dont check the velocity before set it?
and if touch a another player(not "catched") boost again :S
try use a task or another method to ignore the first touch to remove the boost.

madeitout 03-11-2011 11:45

Re: Catch when player touches a wall, but not the floor
 
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define MAX_DISTANCE_ALLOWED    20.0

new Maxplayers;

public 
plugin_init()
{
    
register_forward(FM_Touch"fw_touch");
    
Maxplayers get_maxplayers();
}

public 
fw_touch(ident)
    if (
<= id <= Maxplayers && !(<= ent <= Maxplayers))
        if (
fm_distance_to_floor(id))
        {
            
client_print(idprint_center"You are touching a wall and not the ground");

            
set_pev(idpev_gravity0.0001);
            
set_task(1.0"reset_grav"id);
        }

public 
reset_grav(id)
    
set_pev(idpev_gravity1.0);

stock Float:fm_distance_to_floor(index)
{
    static 
Float:start[3], Float:dest[3], Float:end[3];
    
pev(indexpev_originstart);
    
dest start;
    
dest[2] = -8191.0;

    
engfunc(EngFunc_TraceLinestartdest1index0);
    
get_tr2(0TR_vecEndPosend);

    
pev(indexpev_absminstart);
    return (
start[2] - end[2] > MAX_DISTANCE_ALLOWED) ? 1.0 0.0;



.Dare Devil. 03-11-2011 14:24

Re: Catch when player touches a wall, but not the floor
 
Quote:

Originally Posted by madeitout (Post 1431441)
PHP Code:

#include <amxmodx>
#include <fakemeta>
 
#define MAX_DISTANCE_ALLOWED    20.0
 
new Maxplayers;
 
public 
plugin_init()
{
    
register_forward(FM_Touch"fw_touch");
    
Maxplayers get_maxplayers();
}
 
public 
fw_touch(ident)
    if (
<= id <= Maxplayers && !(<= ent <= Maxplayers))
        if (
fm_distance_to_floor(id))
        {
            
client_print(idprint_center"You are touching a wall and not the ground");
 
            
set_pev(idpev_gravity0.0001);
            
set_task(1.0"reset_grav"id);
        }
 
public 
reset_grav(id)
    
set_pev(idpev_gravity1.0);
 
stock Float:fm_distance_to_floor(index)
{
    static 
Float:start[3], Float:dest[3], Float:end[3];
    
pev(indexpev_originstart);
    
dest start;
    
dest[2] = -8191.0;
 
    
engfunc(EngFunc_TraceLinestartdest1index0);
    
get_tr2(0TR_vecEndPosend);
 
    
pev(indexpev_absminstart);
    return (
start[2] - end[2] > MAX_DISTANCE_ALLOWED) ? 1.0 0.0;



This is not a right way when player jump then he is 1sec in air :nono:


All times are GMT -4. The time now is 01:57.

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