Hello guys,
I'm currently working on a function where a player can evade bullets.
First, my simple example.
Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#define PLUGIN "Godmodetest"
#define VERSION "1.0"
#define AUTHOR "DA"
new fLastShotFired[32];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward ( FM_TraceLine, "TRIGGER_TraceLine" );
register_event ( "CurWeapon", "on_CurWeapon", "be", "1=1" );
}
public on_CurWeapon( id )
{
fLastShotFired[id] = halflife_time();
}
// Called when a user looks somewhere
public TRIGGER_TraceLine( Float:v1[3], Float:v2[3], noMonsters, pentToSkip )
{
new iAttacker = pentToSkip;
new iVictim = get_tr(TR_pHit);
// Make sure we have a valid victim
if ( is_user_alive( iVictim ) )
{
// We need to have a valid player!
if ( is_user_alive( iAttacker ) )
{
new Float:fTime = halflife_time();
new Float:fDifference = fTime - fLastShotFired[iAttacker];
if ( fDifference < 0.1 && fDifference > 0.0 )
{
client_print( 0, print_chat, "He is the god!" );
set_tr( TR_flFraction, 1.0 );
return FMRES_SUPERCEDE;
}
}
}
return FMRES_IGNORED;
}
How you see that I make it with Trigger_TraceLine. Why?
Because in my real plugin the player should have only a
chance to evade a bullet.
Well. I've tested this function on my localmachine but it's not working. Maybe you have an idea why or better - a better way to do it.
Thanks in advance for any help.
DA
__________________