TraceAttack deal damage for no reason. (It shouldn't deal any).
I want to show the result video. It is only a few seconds but you will see.
Link:
https://drive.google.com/file/d/1tTm...ew?usp=sharing
P1 is me and P2 is my helper.
1. I hit him with "att" command. Working fine. (do nothing) Expected prints.
2. I say start then he hits me with his knife or anything. (do nothing) Expected prints.
3. I hit him again with "att" command. I take the damage from the 2. point and it wasn't expected.
I had a bind to "att" so that's why you can't see I writed to console.
Same results with multiple players. If you traceattack someone. Then anybody else he will receive the first one's damage. Same results with different team members.
As I know the TraceAttack should deal any damage. It's only for the blood and directions. If I use TraceAttack as a CT on a T the result should be the same (with no damage) just with bloods.
Here is the code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <fakemeta_util>
new g_beam_sprite, g_log[128];
public plugin_init() {
register_clcmd("att", "cmd_att");
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage_Post", 1)
RegisterHam(Ham_TraceAttack, "player", "fw_TraceAttack_Post", 1);
}
public plugin_precache() {
g_beam_sprite = precache_model("sprites/laserbeam.spr")
}
public cmd_att(id) {
new Float: origin[3], Float: view_ofs[3], Float: v_angle[3], Float: direction[3], Float: end_origin[3];
pev(id, pev_origin, origin);
pev(id, pev_view_ofs, view_ofs);
xs_vec_add(origin, view_ofs, origin);
pev(id, pev_v_angle, v_angle);
angle_vector(v_angle, ANGLEVECTOR_FORWARD, v_angle);
xs_vec_add_scaled(origin, v_angle, 100.0, end_origin);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMPOINTS);
write_coord_f(origin[0]);
write_coord_f(origin[1]);
write_coord_f(origin[2]);
write_coord_f(end_origin[0]);
write_coord_f(end_origin[1]);
write_coord_f(end_origin[2]);
write_short(g_beam_sprite);
write_byte(0);
write_byte(0);
write_byte(10);
write_byte(10);
write_byte(0);
write_byte(255);
write_byte(255);
write_byte(80);
write_byte(170);
write_byte(0);
message_end();
new trace = create_tr2();
engfunc(EngFunc_TraceLine, origin, end_origin, DONT_IGNORE_MONSTERS, id, trace);
new victim_id = get_tr2(trace, TR_pHit);
if ( victim_id == -1 ) {
victim_id = 0
set_tr2(trace, TR_pHit, victim_id);
}
new Float: damage = 50.0;
formatex(g_log, charsmax(g_log), "CMD ATT! FROM %n TO %n WITH %.2f", id, victim_id, damage);
client_print(0, print_chat, g_log);
log_to_file("att.log", g_log);
ExecuteHamB(Ham_TraceAttack, victim_id, id, damage, direction, trace, DMG_NEVERGIB|DMG_BULLET);
free_tr2(trace);
}
public fw_TakeDamage_Post(victim_id, inflictor, attacker_id, Float:damage, bits) {
formatex(g_log, charsmax(g_log), "TAKE DAMAGE! FROM %n TO %n WITH %.2f", attacker_id, victim_id, damage);
client_print(0, print_chat, g_log);
log_to_file("att.log", g_log);
return HAM_IGNORED;
}
public fw_TraceAttack_Post(victim_id, attacker_id, Float: damage, Float: direction[3], trace, damagebits) {
formatex(g_log, charsmax(g_log), "TRACE ATTACK! FROM %n TO %n WITH %.2f", attacker_id, victim_id, damage);
client_print(0, print_chat, g_log);
log_to_file("att.log", g_log);
return HAM_IGNORED;
}
The server is using this one plugin only so nothing modify the results.