Thx, i have another question if i want to use the double shot on attack2 (i mean when player press right click use the double shot, i dont want to hold down secondary attack and then press primary attack to use it) i can change to secondary attack right? or i need to use CmdStart?
this is fine?
PHP Code:
public OnCmdStart(id, uc_handle, seed)
{
if ( ! is_user_alive(id) )
return;
static buttons, oldbuttons
buttons = get_uc(uc_handle, UC_Buttons);
oldbuttons = pev(id, pev_oldbuttons);
if( ( buttons & IN_ATTACK2 ) && !( oldbuttons & IN_ATTACK2 ) )
{
static iEnt
iEnt = find_ent_by_owner(-1, "weapon_m3", id)
if( g_iOldClip>get_pdata_int(iEnt, m_iClip, 4) )
{
g_fLastAttack[g_iShotgunOwner] = (get_gametime()+0.5);
if( !g_bDoubleShot )
{
if( g_iOldClip>1 && get_pcvar_num(g_iCvarShotGunDoubleShot) && pev(g_iShotgunOwner, pev_button)&IN_ATTACK2 && g_bHasUltraM3[g_iShotgunOwner])
{
static Float:s_fAngleDifference, Float:s_fOldAngle;
set_pdata_float(iEnt, m_flNextPrimaryAttack, 0.0, 4);
set_pdata_float(iEnt, m_flNextSecondaryAttack, 0.0, 4);
set_pev(g_iShotgunOwner, pev_punchangle, g_fBackupAngle);
s_fOldAngle = g_fBackupAngle[0];
g_bDoubleShot = true;
ExecuteHamB(Ham_Weapon_PrimaryAttack, iEnt);
g_bDoubleShot = false;
pev(g_iShotgunOwner, pev_punchangle, g_fBackupAngle);
s_fAngleDifference = (g_fBackupAngle[0]-s_fOldAngle);
set_pdata_float(iEnt, m_flNextPrimaryAttack, 2.00, 4);
set_pdata_float(iEnt, m_flNextSecondaryAttack, 2.00, 4);
if( g_fBackupAngle[0]>-25.0 && g_fBackupAngle[0]<0.0 )
{
s_fAngleDifference *= 2.1;
g_fBackupAngle[0] = (s_fOldAngle+s_fAngleDifference);
if( g_fBackupAngle[0]<-25.0 )
g_fBackupAngle[0] = -25.0;
set_pev(g_iShotgunOwner, pev_punchangle, g_fBackupAngle);
}
}
}
}
}
}