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

No Walls Plugin amx1.9


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mark.uG
AlliedModders Donor
Join Date: Oct 2014
Old 12-28-2018 , 15:59   No Walls Plugin amx1.9
Reply With Quote #1

Any reason why this won't work for 1.9?

Code:
	/*
		<^>
	
		Author 	: hornet
		Plugin  : No Shoot Through Walls
		
		<^>
		
		This plugin is free software; you can redistribute it and/or modify it
		under the terms of the GNU General Public License as published by the
		Free Software Foundation; either version 2 of the License, or (at
		your option) any later version.
		
		This plugin is distributed in the hope that it will be useful, but
		WITHOUT ANY WARRANTY; without even the implied warranty of
		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
		General Public License for more details.
		
		You should have received a copy of the GNU General Public License
		along with this plugin; if not, write to the Free Software Foundation,
		Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
		
		<^>
	*/

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#include <xs>

#define VERSION		"0.0.1"

new g_pEnabled;

public plugin_init()
{
	register_plugin( "No Shoot Through Walls", VERSION, "hornet" );
	
	g_pEnabled = register_cvar( "nowalls_enabled", "1" );
	
	RegisterHam( Ham_TraceAttack, "player", "CBasePlayer_TraceAttack" );
}

public CBasePlayer_TraceAttack( iVictim, iAttacker, Float:flDamage, Float:vDirection[ 3 ], ptr, Bits )
{
	if( get_pcvar_num( g_pEnabled ) && iAttacker && get_user_weapon( iAttacker ) != CSW_KNIFE )
	{
		static Float:vStart[ 3 ], Float:vEnd[ 3 ], Float:flFraction;
		
		get_tr2( ptr, TR_vecEndPos, vEnd );
		get_tr2( ptr, TR_flFraction, flFraction );
		
		xs_vec_mul_scalar( vDirection, -1.0, vDirection );
		xs_vec_mul_scalar( vDirection, flFraction * 9999.0, vStart );
		xs_vec_add( vStart, vEnd, vStart );
		
		new iTarget = trace_line( iVictim, vEnd, vStart, vEnd );
		
		if( !iTarget )
			return HAM_SUPERCEDE;
	}
	
	return HAM_IGNORED;
}
Mark.uG is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-28-2018 , 17:54   Re: No Walls Plugin amx1.9
Reply With Quote #2

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?
__________________

Last edited by fysiks; 12-28-2018 at 17:55.
fysiks is offline
Mark.uG
AlliedModders Donor
Join Date: Oct 2014
Old 12-28-2018 , 23:19   Re: No Walls Plugin amx1.9
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
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;
 }

Last edited by Mark.uG; 12-29-2018 at 00:22.
Mark.uG is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-29-2018 , 02:07   Re: No Walls Plugin amx1.9
Reply With Quote #4

Well, the error is because there is no user connected when that function is being called. The second code you posted checks for this properly first (is_user_connected()).

So, the version of AMX Mod X doesn't matter with regards to this error.
__________________

Last edited by fysiks; 12-29-2018 at 02:08.
fysiks is offline
Old 12-29-2018, 06:33
klippy
This message has been deleted by klippy. Reason: actually doesn't matter
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 18:47.


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