Raised This Month: $ Target: $400
 0% 

Entity Use (Like a button)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
milutinke
AlliedModders Donor
Join Date: Jun 2012
Location: Serbia
Old 10-21-2015 , 06:26   Re: Entity Use (Like a button)
Reply With Quote #3

I wrote this using my mobile phone.
I have not tested it, but it should work.

Code:
#include < amxmodx >
#include < amxmisc >
#include < fakemeta >

public plugin_init( ) {
	register_plugin( "Use Entity like Button", "1.0", "Milutinke (ByM)" );
	
	register_forward( FM_EmitSound, "fw_EmitSound" );
}

public fw_EmitSound( id, iChannel, szSound[ ], Float: fVol, Float: fAttn, iFlags, iPitch ) {
	if( !is_user_alive( id ) )
		return FMRES_IGNORED;
	
	if( equal( szSound, "common/wpn_denyselect.wav" ) ) {
		if( IsAimingAtEnt( id, "Entity Name Here" ) ) {
			//Your code here.
		}
		
		return FMRES_SUPERCEDE;
	}

	return FMRES_IGNORED;
}

stock bool: IsAimingAtEnt( id, const szEntityClassName[ ] ) {
	if( !strlen( szEntityClassName ) || !is_user_alive( id ) )
		return false;
		
	static iTarget, iBody, szClassName[ 32 ];
	get_user_aiming( id, iTarget, iBody );
	pev( iTarget, pev_classname, szClassName, charsmax( szClassName ) );
	
	if( equal( szEntityClassName, szClassName ) )
		return true;
		
	return true;
}
milutinke is offline
Send a message via Skype™ to milutinke
 



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 22:18.


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