hi, you can check code by Destroman, it detects when player touch wall with head or by right-left side:
Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#define PLUGIN "Wall touch helper"
#define VERSION "1.0"
#define AUTHOR "Destroman"
new iconstatus;
new const FL_ONGROUND2 = (FL_ONGROUND | FL_PARTIALGROUND | FL_INWATER | FL_CONVEYOR | FL_FLOAT);
#define is_on_ladder(%1) (pev(%1, pev_movetype) == MOVETYPE_FLY)
new Float:wall_time;
new bool:g_touch_wall[33];
new wall_count[33];
enum _:coord_t
{
Float:xx,
Float:yy,
Float:zz
};
#define vector_side(%0,%1,%2,%3) (%3[xx] = %0[xx] + %1 * %2[xx], %3[yy] = %0[yy] + %1 * %2[yy], %3[zz] = %0[zz] + %1 * %2[zz])
public plugin_init()
{
register_plugin( PLUGIN, VERSION , AUTHOR);
RegisterHam(Ham_Touch, "player", "ham_touch", false);
register_forward(FM_PlayerPreThink, "player_pre_think", 0);
iconstatus = get_user_msgid("StatusIcon");
register_clcmd("say /wt", "walltouch");
register_clcmd("say_team /wt", "walltouch");
register_clcmd("say /walltouch", "walltouch");
register_clcmd("say_team /walltouch", "walltouch");
}
public client_putinserver(id)
{
if(!is_user_bot(id))
{
g_touch_wall[id] = true;
wall_count[id] = 0;
}
}
public ham_touch(id, ent)
{
if(is_user_alive(id) && !is_user_bot(id))
{
if(g_touch_wall[id])
{
if(!(pev(id, pev_flags) & FL_ONGROUND2) && !is_on_ladder(id) && !(pev(id, pev_flags) & FL_DUCKING))
{
new Float:origin[3];
entity_get_vector(id, EV_VEC_origin, origin);
new Float:temp_origin[3];
for(new i = 0; i < 4; i++)
{
temp_origin = origin;
temp_origin[i / 2] += ((i % 2) ? -1.0 : 1.0);
temp_origin[2] += 22;
if(trace_hull(temp_origin, HULL_HUMAN, id, 1) && get_gametime() - wall_time > 0.05)
{
wall_time = get_gametime();
take_damage(id, origin);
wall_count[id]++;
break;
}
}
}
}
}
}
public player_pre_think(id)
{
if(is_user_alive(id) && !is_user_bot(id) && g_touch_wall[id])
{
if((pev(id, pev_flags) & FL_ONGROUND2) && !is_on_ladder(id) && !(pev(id, pev_flags) & FL_DUCKING))
{
new Float:origin[3];
entity_get_vector(id, EV_VEC_origin, origin);
origin[2] += 44.99;
if(!is_hull_vacant(origin, HULL_HUMAN))
{
draw_warning(id);
}
else
{
hide_warning(id);
}
}
else
{
hide_warning(id);
}
}
else if(!g_touch_wall[id])
{
hide_warning(id);
}
return FMRES_IGNORED;
}
stock draw_warning(id)
{
message_begin(MSG_ONE_UNRELIABLE, iconstatus, _, id);
write_byte(1);
write_string("flash_beam");
write_byte(255);
write_byte(0);
write_byte(0);
message_end();
return PLUGIN_HANDLED;
}
stock hide_warning(id)
{
message_begin(MSG_ONE_UNRELIABLE, iconstatus, _, id);
write_byte(0);
write_string("flash_beam");
write_byte(0);
write_byte(90);
write_byte(255);
message_end();
return PLUGIN_HANDLED;
}
public walltouch(id)
{
if(g_touch_wall[id])
{
g_touch_wall[id] = false;
client_print(id, print_chat, "Wall touch helper disabled");
}
else
{
g_touch_wall[id] = true;
client_print(id, print_chat, "Wall touch helper enabled");
}
return PLUGIN_HANDLED;
}
stock take_damage(id, Float:player_origin[3])
{
const Float:LENGTH = 64.0;
const Float:CHECK_LENGTH = 1.0;
new Float:temp_roof[3], Float:temp_forward[3], Float:temp_right[3], Float:temp_left[3];
new Float:roof_side[3], Float:forward_side[3], Float:right_side[3], Float:left_side[3];
new Float:shot_side[3];
new Float:view_angles[3];
temp_roof = player_origin;
pev(id, pev_angles, view_angles);
engfunc(EngFunc_MakeVectors, view_angles);
global_get(glb_v_forward, shot_side);
vector_side(temp_roof, LENGTH, shot_side, temp_roof);
roof_side = player_origin;
roof_side[2] = player_origin[2] +1.0;
forward_side = player_origin;
temp_forward = player_origin;
global_get(glb_v_forward, shot_side);
vector_side(forward_side, CHECK_LENGTH, shot_side, forward_side);
vector_side(temp_forward, LENGTH, shot_side, temp_forward);
right_side = player_origin;
temp_right = player_origin;
global_get(glb_v_right, shot_side);
vector_side(right_side, CHECK_LENGTH, shot_side, right_side);
vector_side(temp_right, LENGTH, shot_side, temp_right);
left_side = player_origin;
temp_left = player_origin;
global_get(glb_v_right, shot_side);
vector_side(left_side, -CHECK_LENGTH, shot_side, left_side);
vector_side(temp_left, -LENGTH, shot_side, temp_left);
if(!is_hull_vacant(roof_side, HULL_HUMAN))
{
temp_roof[2] = player_origin[2] + 1.0;
draw_damage(id, temp_roof);
}
else if(!is_hull_vacant(right_side, HULL_HUMAN))
{
temp_right[2] = player_origin[2] + 1.0;
draw_damage(id, temp_right);
}
else if(!is_hull_vacant(left_side, HULL_HUMAN))
{
temp_left[2] = player_origin[2] + 1.0;
draw_damage(id, temp_left);
}
else if(!is_hull_vacant(forward_side, HULL_HUMAN))
{
temp_forward[2] = player_origin[2] + 1.0;
draw_damage(id, temp_forward);
}
}
stock draw_damage(id, Float:origin[3])
{
new send_origin[3];
send_origin[0] = floatround(origin[0]);
send_origin[1] = floatround(origin[1]);
send_origin[2] = floatround(origin[2]);
message_begin(MSG_ONE, get_user_msgid("Damage"), _, id);
write_byte(1); // damage save
write_byte(1); // damage take
write_long(DMG_GENERIC); // example dmg - DMG_POISON
write_coord(send_origin[0]); // x
write_coord(send_origin[1]); // y
write_coord(send_origin[2]); // z //must be upper
message_end();
if(wall_count[id] == 10 || wall_count[id] == 100 || wall_count[id] == 1000)
{
client_print(id, print_chat, "To disable wall touch alert type /wt or /walltouch in chat");
}
}
stock bool:is_hull_vacant(const Float:origin[3], hull)
{
engfunc(EngFunc_TraceHull, origin, origin, IGNORE_MONSTERS, hull, 0, 0);
if (!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid) && get_tr2(0, TR_InOpen))
{
return true;
}
return false;
}