#include <amxmodx>
#include <fun>
#include <cstrike>
#include <engine>
new gmsgSetFOV
new Zooming[32]
new laststate[32]
new gLastWeapon[32]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("Bullseye","1.0","AssKicR¨& Freecode")
register_event("ResetHUD","newRound","b")
register_event("CurWeapon","changeweapon","be","1=1")
register_cvar("amx_bullseye","1");
register_clcmd("bullseye_zoom", "bullseye_kd",0,"zoom")
gmsgSetFOV = get_user_msgid("SetFOV")
set_task(0.01,"check_reload",0,"",0,"b")
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public newRound(id)
{
if ( is_user_alive(id))
{
bullseye_zoomout(id)
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_sound("weapons/zoom.wav")
precache_sound("common/wpn_denyselect.wav");
}
//----------------------------------------------------------------------------------------------
public bullseye_zoom(id)
{
Zooming[id]=4
message_begin(MSG_ONE, gmsgSetFOV, {0,0,0}, id)
write_byte(60) //Zooming AUG/SIG style
message_end()
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public bullseye_zoomonce(id)
{
Zooming[id]=1
emit_sound(id,CHAN_WEAPON, "weapons/zoom.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
message_begin(MSG_ONE, gmsgSetFOV, {0,0,0}, id)
write_byte(40) //Zooming once
message_end()
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public bullseye_zoomtwice(id)
{
Zooming[id]=2
emit_sound(id,CHAN_WEAPON, "weapons/zoom.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
message_begin(MSG_ONE, gmsgSetFOV, {0,0,0}, id)
write_byte(20) //Zooming twice
message_end()
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public bullseye_zoomtrice(id)
{
Zooming[id]=3
emit_sound(id,CHAN_WEAPON, "weapons/zoom.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
message_begin(MSG_ONE, gmsgSetFOV, {0,0,0}, id)
write_byte(1) //Zooming trice
message_end()
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public bullseye_zoomout(id)
{
Zooming[id]=0
message_begin(MSG_ONE, gmsgSetFOV, {0,0,0}, id)
write_byte(90) //not Zooming
message_end()
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public check_zoom(id)
{
if (is_user_alive(id))
{
new temp,temp2
new wpn_id = get_user_weapon(id,temp,temp2)
gLastWeapon[id]=wpn_id
if ( wpn_id==CSW_AWP || wpn_id==CSW_SCOUT || wpn_id==CSW_SG552 || wpn_id==CSW_G3SG1 || wpn_id==CSW_AUG || wpn_id==CSW_SG550 || wpn_id==CSW_KNIFE || wpn_id==CSW_C4 || wpn_id==CSW_HEGRENADE || wpn_id==CSW_FLASHBANG || wpn_id==CSW_SMOKEGRENADE )
{
emit_sound(id,CHAN_ITEM, "common/wpn_denyselect.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
else
{
if (get_cvar_num("amx_bullseye")==1)
{
if (Zooming[id]==3)
{
bullseye_zoomout(id)
}
else if (Zooming[id]==2)
{
bullseye_zoomtrice(id)
}
else if (Zooming[id]==1)
{
bullseye_zoomtwice(id)
}
else
{
bullseye_zoomonce(id)
}
}
else
{
if (Zooming[id]!=0)
{
bullseye_zoomout(id)
}
else
{
bullseye_zoom(id)
}
}
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public changeweapon(id)
{
new clip,temp
new wpn_id = get_user_weapon(id,clip,temp)
if (gLastWeapon[id]!=wpn_id) bullseye_zoomout(id)
gLastWeapon[id]=wpn_id
if ( wpn_id==CSW_AWP || wpn_id==CSW_SCOUT || wpn_id==CSW_SG552 || wpn_id==CSW_G3SG1 || wpn_id==CSW_AUG || wpn_id==CSW_SG550 || wpn_id==CSW_KNIFE || wpn_id==CSW_C4 || wpn_id==CSW_HEGRENADE || wpn_id==CSW_FLASHBANG || wpn_id==CSW_SMOKEGRENADE ) return PLUGIN_CONTINUE
if ( clip == 0 )
{
if (Zooming[id]!=0)
{
laststate[id]=Zooming[id]
bullseye_zoomout(id)
new parm[2]
parm[0]=id
parm[1]=wpn_id
set_task(float(3),"zoom_return",0,parm,2)
set_user_maxspeed(id,-1.0);
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public bullseye_kd(id)
{
check_zoom(id)
return PLUGIN_HANDLED
}
//------------------------------------------------------------------------------------------
public check_reload()
{
for(new id = 1; id <= get_maxplayers(); ++id)
{
if (is_user_alive(id))
{
new clip,temp
new wpn_id = get_user_weapon(id,clip,temp)
if ( wpn_id==CSW_AWP || wpn_id==CSW_SCOUT || wpn_id==CSW_SG552 || wpn_id==CSW_G3SG1 || wpn_id==CSW_AUG || wpn_id==CSW_SG550 || wpn_id==CSW_KNIFE || wpn_id==CSW_C4 || wpn_id==CSW_HEGRENADE || wpn_id==CSW_FLASHBANG || wpn_id==CSW_SMOKEGRENADE )
{
//nottin
}
else
{
if (get_user_button(id)&IN_RELOAD)
{
if (CheckMaxAmmo(id))
{
laststate[id]=Zooming[id]
bullseye_zoomout(id)
new parm[2]
parm[0]=id
parm[1]=wpn_id
set_task(float(3),"zoom_return",0,parm,2)
}
}
else
{
//nottin
}
}
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public zoom_return(parm[])
{
new id=parm[0]
new clip,ammo
new wpn_id = get_user_weapon(id,clip,ammo)
if (parm[1]==wpn_id)
{
if (get_cvar_num("bullseye_zoommode")==1)
{
if (laststate[id]==3)
{
bullseye_zoomtrice(id)
}
else if (laststate[id]==2)
{
bullseye_zoomtwice(id)
}
else if (laststate[id]==1)
{
bullseye_zoomonce(id)
}
else
{
bullseye_zoomout(id)
}
}
else
{
if (laststate[id]!=0)
{
bullseye_zoom(id)
}
else
{
bullseye_zoomout(id)
}
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public CheckMaxAmmo(id)
{
new clip,temp
new wpn_id = get_user_weapon(id,clip,temp)
switch (wpn_id) {
case CSW_M3: if (clip!=8) return true
case CSW_XM1014: if (clip!=7) return true
case CSW_MP5NAVY: if (clip!=30) return true
case CSW_TMP: if (clip!=30) return true
case CSW_P90: if (clip!=50) return true
case CSW_MAC10: if (clip!=30) return true
case CSW_UMP45: if (clip!=25) return true
case CSW_AK47: if (clip!=30) return true
case CSW_SG552: if (clip!=30) return true
case CSW_M4A1: if (clip!=30) return true
case CSW_AUG: if (clip!=30) return true
case CSW_SCOUT: if (clip!=10) return true
case CSW_AWP: if (clip!=10) return true
case CSW_G3SG1: if (clip!=20) return true
case CSW_SG550: if (clip!=30) return true
case CSW_M249: if (clip!=100) return true
case CSW_USP: if (clip!=12) return true
case CSW_GLOCK18: if (clip!=20) return true
case CSW_DEAGLE: if (clip!=7) return true
case CSW_P228: if (clip!=13) return true
case CSW_ELITE: if (clip!=30) return true
case CSW_FIVESEVEN: if (clip!=20) return true
}
return false
}
//----------------------------------------------------------------------------------------------