I'm trying to get cz bots to stop when shooting to increase their accuracy, then continue to move as normal. I have got it to where they will stop when shooting but can't move again. Here is what I have so far.
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>
// any of the buttons on the right will count as moving
#define IN_MOVING (IN_FORWARD|IN_BACK|IN_MOVELEFT|IN_MOVERIGHT| IN_JUMP)
// Tracks players Shots-Fired: [0]=WeaponID, [1]=Ammo
new g_iCurrWeapon[33][2]
public plugin_init()
{
register_event( "CurWeapon", "Event_ShotFired", "b" )
}
public Event_ShotFired( id )
{
// Players current weapon data..
new wID = read_data( 2 )
new wAmmo = read_data( 3 )
if( g_iCurrWeapon[id][0] != wID ) // User Changed Weapons..
{
g_iCurrWeapon[id][0] = wID
g_iCurrWeapon[id][1] = wAmmo
return PLUGIN_CONTINUE
}
if( g_iCurrWeapon[id][1] < wAmmo ) // User Reloaded..
{
g_iCurrWeapon[id][1] = wAmmo
return PLUGIN_CONTINUE
}
if( g_iCurrWeapon[id][1] == wAmmo ) // User did something else, but didn't shoot..
{
return PLUGIN_CONTINUE
}
// This far means user shot his/her gun..
// Save new weapon data..
g_iCurrWeapon[id][1] = wAmmo
g_iCurrWeapon[id][0] = wID
// Do Stuff here..
// he is alive and using movement keys
if( is_user_alive(id) && is_user_bot(id) && (pev(id, pev_button) & IN_MOVING) )
{
// make sure he is using a gun
if( wID != CSW_HEGRENADE && wID != CSW_FLASHBANG && wID != CSW_SMOKEGRENADE
&& wID != CSW_C4 && wID != CSW_KNIFE )
{
set_user_maxspeed( id , 0.1)
}
}
return PLUGIN_CONTINUE
}