PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#define MAX_PLAYERS 32
enum _:CvarsSettings
{
PluginEnabled,
DisplayMessageType,
PluginPrefix
}
new pCvars[CvarsSettings]
new szPluginPrefix[25]
enum _:PlayerScopeData
{
Float:ScopeTime,
ScopeType
}
new ScopeData[MAX_PLAYERS+1][PlayerScopeData]
new gMsgSync
new MsgSayText
new PluginForwardQuick, PluginForwardNoScope, g_iReturn
public plugin_init()
{
new const PluginVersion[] = "1.2"
register_plugin("Quick and No Scope Detector", PluginVersion, "EFFx")
gMsgSync = CreateHudSyncObj()
pCvars[PluginEnabled] = register_cvar("qsd_enabled","1")
pCvars[DisplayMessageType] = register_cvar("qsd_messagetype","hud")
pCvars[PluginPrefix] = register_cvar("qsd_chatprefix","[Quick&NoScopeDetector]")
PluginForwardQuick = CreateMultiForward("client_NoScoped", ET_STOP, FP_CELL, FP_CELL, FP_CELL)
PluginForwardNoScope = CreateMultiForward("client_QuickScoped", ET_STOP, FP_CELL, FP_CELL, FP_CELL)
if(!PluginForwardQuick)
{
log_amx("client_NoScoped forward is not used by any other plugin.")
}
if(!PluginForwardNoScope)
{
log_amx("client_QuickScoped forward is not used by any other plugin.")
}
register_event("DeathMsg","checkQuickScopeKill","a","1>0", "4=scout","4=sg550", "4=awp", "4=g3sg1")
register_event("CurWeapon","fw_EvCurWeapon","b","1=1","2=3","2=13", "2=18", "2=24")
register_event("SetFOV","Zoom","b","1<90")
MsgSayText = get_user_msgid("SayText")
}
public plugin_prechache() precache_generic("sound/scoped.mp3")
public plugin_natives()
{
register_library("quicknoscoped")
}
public plugin_end()
{
DestroyForward(PluginForwardQuick)
DestroyForward(PluginForwardNoScope)
}
public Zoom(id)
{
if(is_user_alive(id))
{
ScopeData[id][ScopeTime] = _:get_gametime()
}
}
public fw_EvCurWeapon(id)
{
ScopeData[id][ScopeType] = cs_get_user_zoom(id)
}
public checkQuickScopeKill()
{
if(!get_pcvar_num(pCvars[PluginEnabled]))
return
new KillerName[32],VictimName[32],WeaponName[17]
new iKiller = read_data(1)
new iVictim = read_data(2)
new Float:GameTime = get_gametime()
new bool:bNoScope = bool:(ScopeData[iKiller][ScopeType] == CS_SET_NO_ZOOM)
new bool:bQuickScope = bool:(GameTime - ScopeData[iKiller][ScopeTime] <= 0.20)
if(bNoScope || bQuickScope)
{
get_user_name(iKiller,KillerName,charsmax(KillerName))
get_user_name(iVictim,VictimName,charsmax(VictimName))
bNoScope ? ExecuteForward(PluginForwardNoScope, g_iReturn, iKiller, iVictim, get_user_weapon(iKiller)) : ExecuteForward(PluginForwardQuick, g_iReturn, iKiller, iVictim, get_user_weapon(iKiller))
read_data(4,WeaponName,charsmax(WeaponName))
QSD_ChatMessage
(
"^4%s^1 Holy shit!^4 %s^1 %s^3 %s^1 with his^4 %s",
get_pcvar_string(pCvars[PluginPrefix],szPluginPrefix,charsmax(szPluginPrefix)),
szPluginPrefix,
KillerName,
bNoScope ? "just NO SCOPED" : "made a^4 QUICK SCOPE^1 on" ,
VictimName,
WeaponName
)
if(bNoScope)
{
set_hudmessage(random(256), random(256), random(256), 0.04, 0.67, 1, 1.00, 3.00, 0.10, 0.20, -1);
show_hudmessage(0, "%s has just No Scoped on %s", KillerName, VictimName);
client_cmd(0, "mp3 play sound/scoped.mp3")
}
}
}
QSD_ChatMessage(const message[],withPrefixRemoved,any:...)
{
static szMsg[191]
vformat(szMsg,charsmax(szMsg),message,3)
replace_all(szMsg, charsmax(szMsg),"!g","^4")
replace_all(szMsg, charsmax(szMsg),"!y","^1")
replace_all(szMsg, charsmax(szMsg),"!t","^3")
new const replaceIcons[] = {"^4","^3","^1"}
new szMessageType[45]
get_pcvar_string(pCvars[DisplayMessageType],szMessageType,charsmax(szMessageType))
switch(szMessageType[0])
{
case 'H','h':
{
for(new i;i < sizeof replaceIcons;i++)
{
replace_all(szMsg,charsmax(szMsg),replaceIcons[i],"")
}
set_hudmessage(0,255,0,-1.0,0.25,1,1.0,5.0)
ShowSyncHudMsg(0,gMsgSync,szMsg[withPrefixRemoved])
}
case 'L','l':
{
for(new i;i < sizeof replaceIcons;i++)
{
replace_all(szMsg,charsmax(szMsg),replaceIcons[i],"")
}
log_amx(szMsg[withPrefixRemoved])
}
default:
{
new Players[32],iPlayersNum,PlayerID
get_players(Players,iPlayersNum,"ch")
for(new i;i < iPlayersNum;i++)
{
PlayerID = Players[i]
message_begin(MSG_ONE_UNRELIABLE,MsgSayText, .player = PlayerID)
write_byte(PlayerID)
write_string(szMsg)
message_end()
}
}
}
}