Quote:
Originally Posted by fysiks
Are you absolutely sure it works with 1.8.2? Did you test it in the exact same situation on both versions of AMX Mod X?
|
Yes was running for the last 3+years on 1.8.2
Getting this error in logs after i let it run for a while.
Code:
L 12/28/2018 - 21:50:39: [AMXX] Displaying debug trace (plugin "nowalls.amxx", version "0.0.1")
L 12/28/2018 - 21:50:39: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 12/28/2018 - 21:50:39: [AMXX] [0] nowalls.sma::CBasePlayer_TraceAttack (line 22)
This one seems to work strange.
Code:
#include <amxmodx>
#include <fakemeta>
new normalTrace[33], lastTrace[33], cvEnabled, weapon, dummy;
// plugin load
public plugin_init()
{
register_plugin("No Walls","0.13","Avalanche");
register_cvar("nowalls_version","0.13",FCVAR_SERVER);
cvEnabled = register_cvar("nowalls_enabled","1");
register_event("ResetHUD","event_resethud","b");
register_clcmd("fullupdate","cmd_fullupdate");
register_forward(FM_TraceLine,"fw_traceline");
register_forward(FM_PlayerPostThink,"fw_playerpostthink");
}
// reset normal trace id on join or leave
public client_connect(id)
{
normalTrace[id] = 0;
}
public client_disconnect(id)
{
normalTrace[id] = 0;
}
// player spawns, and some other such things
public event_resethud(id)
{
lastTrace[id] = 0;
}
// block forced resethud call
public cmd_fullupdate(id)
{
return PLUGIN_HANDLED;
}
// traceline hook, meat and bones of the entire plugin
public fw_traceline(Float:vecStart[3],Float:vecEnd[3],ignoreM,id,ptr) // pentToSkip == id, for clarity
{
if(!is_user_connected(id))
return FMRES_IGNORED;
// grab normal trace
if(!normalTrace[id])
{
normalTrace[id] = ptr;
return FMRES_IGNORED;
}
// ignore normal trace
else if(ptr == normalTrace[id])
return FMRES_IGNORED;
// no functionality
if(!get_pcvar_num(cvEnabled))
return FMRES_IGNORED;
// not a player entity, or player is dead
if(!is_user_alive(id))
return FMRES_IGNORED;
// not shooting anything
if(!(pev(id,pev_button) & IN_ATTACK))
return FMRES_IGNORED;
weapon = get_user_weapon(id,dummy,dummy);
// using a shotgun, expect multiple tracelines
if(weapon == CSW_M3 || weapon == CSW_XM1014)
return FMRES_IGNORED;
// this is a second traceline, for shooting through walls
if(ptr == lastTrace[id])
{
// values sure to throw off any traceline
set_tr(TR_vecEndPos,Float:{4096.0,4096.0,4096.0});
set_tr(TR_AllSolid,1);
set_tr(TR_pHit,0);
set_tr(TR_iHitgroup,0);
set_tr(TR_flFraction,1.0);
return FMRES_SUPERCEDE;
}
// remeber traceline index for next time
lastTrace[id] = ptr;
return FMRES_IGNORED;
}
// finished client calculations, reset our traceline index
public fw_playerpostthink(id)
{
lastTrace[id] = 0;
}