#include <sourcemod>
#include <sdktools>
#include <clientprefs>
Handle: Sound
Handle: PlaySoundTo
Handle: Message
Handle: ShowMessageTo
new Handle: HearSound
bool: CanHearTheSound[ MAXPLAYERS + 1 ]
public Plugin:myinfo = {
name = "NoScope Message & Sound",
author = "tre3fla",
description = "Arata un mesaj in chat cand cineva da noscope si reda un sunet",
version = "1.0",
url = "http://extreamcs.com/forum"
}
public OnPluginStart( ) {
Sound = CreateConVar( "sm_noscope_play_sound", "1", "0=dezactivat, 1=reda un sunet cand cineva da no scope" )
PlaySoundTo = CreateConVar( "sm_noscope_sound", "1", "1=toti jucatorii aud sunet, 2=doar cel care a dat noscope" )
Message = CreateConVar( "sm_noscope_show_message", "1", "0=dezactivat, 1=arata mesaj in chat cand cineva da no scope" )
ShowMessageTo = CreateConVar( "sm_noscope_message", "1", "1=toti jucatorii vad mesajul din chat, 2=doar cel care dat si a primit no scope" )
HearSound = RegClientCookie( "NoScopeSound", "Sunetul de no scope", CookieAccess_Protected )
RegConsoleCmd( "noscopesounds", Command_NoScopeSounds )
HookEvent( "player_death", Event_PlayerDeath )
HookEventEx( "player_connect_full", player_connect_full )
}
public OnMapStart( ) {
PrecacheSound( "*noscope/noscope.mp3" )
AddFileToDownloadsTable( "sound/noscope/noscope.mp3" )
}
public player_connect_full( Event:event, const String:name[ ], bool:dontBroadcast ) {
new client = GetClientOfUserId( GetEventInt( event, "userid" ) )
if( IsClientConnected( client ) && !IsFakeClient( client ) ) {
char HS[ 5 ]
GetClientCookie( client, HearSound, HS, sizeof( HS ) )
if( StrEqual( HS, "0" )) {
CanHearTheSound[ client ] = false
}
if( StrEqual( HS, "1" ) ) {
CanHearTheSound[ client ] = true
}
if( StrEqual( HS, "" )) {
CanHearTheSound[ client ] = true
}
}
}
public Action: Event_PlayerDeath( Handle:event, const String:name[ ], bool:dontBroadcast ) {
new victim = GetClientOfUserId( GetEventInt( event, "userid" ) )
new attacker = GetClientOfUserId( GetEventInt( event, "attacker" ) )
if( IsValidClient( attacker ) && IsValidClient( victim ) && victim != attacker ) {
char Weapon[ 64 ]
GetEventString( event, "weapon", Weapon, sizeof( Weapon ) )
if( StrContains( Weapon, "awp" ) != -1 || StrContains( Weapon, "ssg08" ) != -1 ) {
decl String: AttackerName[ 32 ]
GetClientName( attacker, AttackerName, sizeof( AttackerName ) )
decl String: VictimName[ 32 ]
GetClientName( victim, VictimName, sizeof( VictimName ) )
if( StrContains( Weapon, "awp" ) != -1 && GetEntProp( attacker, Prop_Data, "m_iFOV" ) == 0 && !( GetEntityFlags( attacker ) & FL_ONGROUND ) ) {
if( GetConVarBool( Sound ) ) {
switch( GetConVarInt( PlaySoundTo ) ) {
case 1: {
PlaySoundToAll( )
}
case 2: {
EmitSoundToClient( attacker, "*noscope/noscope.mp3" )
}
}
}
if( GetConVarBool( Message ) ) {
switch( GetConVarInt( ShowMessageTo ) ) {
case 1 : {
PrintToChatAll( "*\x03 %s\x01 did a\x02 KQLY style\x01 to\x0C %s\x01!", AttackerName, VictimName )
}
case 2: {
PrintToChat( attacker, "* You did a\x02 KQLY style\x01 to\x0C %s\x01!", VictimName )
PrintToChat( victim, "*\x09 %s\x01 did you a\x02 KQLY style\x01!", AttackerName )
}
}
}
}
else if( StrContains( Weapon, "awp" ) != -1 && GetEntProp( attacker, Prop_Data, "m_iFOV" ) == 0 ) {
if( GetConVarBool( Sound ) ) {
switch( GetConVarInt( PlaySoundTo ) ) {
case 1: {
PlaySoundToAll( )
}
case 2: {
EmitSoundToClient( attacker, "*noscope/noscope.mp3" )
}
}
}
if( GetConVarBool( Message ) ) {
switch( GetConVarInt( ShowMessageTo ) ) {
case 1 : {
PrintToChatAll( "*\x03 %s\x02 noscoped\x04 %s\x01! Git rekt n00b!", AttackerName, VictimName )
}
case 2: {
PrintToChat( victim, "* \x03%s\x02 noscoped\x04 you!", AttackerName )
PrintToChat( attacker, "*\x04 You\x02 noscoped\x02 %s", VictimName )
}
}
}
}
if( StrContains( Weapon, "ssg08" ) != -1 && GetEntProp( attacker, Prop_Data, "m_iFOV" ) == 0 && !( GetEntityFlags( attacker ) & FL_ONGROUND ) ) {
if( GetConVarBool( Sound ) ) {
switch( GetConVarInt( PlaySoundTo ) ) {
case 1: {
PlaySoundToAll( )
}
case 2: {
EmitSoundToClient( attacker, "*noscope/noscope.mp3" )
}
}
}
if( GetConVarBool( Message ) ) {
switch( GetConVarInt( ShowMessageTo ) ) {
case 1 : {
PrintToChatAll( "*\x03 %s\x02 jumpscouted and noscoped\x0C %s", AttackerName, VictimName )
}
case 2: {
PrintToChat( attacker, "* You\x02 jumpscouted and noscoped\x0C %s\x01!", VictimName )
PrintToChat( victim, "*\x09 %s\x02 jumpscouted and noscoped\x0C you", AttackerName )
}
}
}
}
else if( StrContains( Weapon, "ssg08" ) != -1 && !( GetEntityFlags( attacker ) & FL_ONGROUND ) ) {
if( GetConVarBool( Sound ) ) {
switch( GetConVarInt( PlaySoundTo ) ) {
case 1: {
PlaySoundToAll( )
}
case 2: {
EmitSoundToClient( attacker, "*noscope/noscope.mp3" )
}
}
}
if( GetConVarBool( Message ) ) {
switch( GetConVarInt( ShowMessageTo ) ) {
case 1 : {
PrintToChatAll( "*\x03 %s\x02 jumpscouted\x0C %s", AttackerName, VictimName )
}
case 2: {
PrintToChat( attacker, "* You\x02 jumpscouted\x0C %s\x01!", VictimName )
PrintToChat( victim, "*\x09 %s\x02 jumpscouted\x0C you", AttackerName )
}
}
}
}
else if( StrContains( Weapon, "ssg08" ) != -1 && GetEntProp( attacker, Prop_Data, "m_iFOV" ) == 0 ) {
if( GetConVarBool( Sound ) ) {
switch( GetConVarInt( PlaySoundTo ) ) {
case 1: {
PlaySoundToAll( )
}
case 2: {
EmitSoundToClient( attacker, "*noscope/noscope.mp3" )
}
}
}
if( GetConVarBool( Message ) ) {
switch( GetConVarInt( ShowMessageTo ) ) {
case 1 : {
PrintToChatAll( "*\x03 %s\x02 noscoped\x0C %s", AttackerName, VictimName )
}
case 2: {
PrintToChat( attacker, "* You\x02 noscoped\x0C %s\x01!", VictimName )
PrintToChat( victim, "*\x09 %s\x02 noscoped\x01 you!", AttackerName )
}
}
}
}
}
}
}
public Action: Command_NoScopeSounds( client, args ) {
if( CanHearTheSound[ client ] ) {
CanHearTheSound[ client ] = false
SetClientCookie( client, HearSound, "0" )
PrintToChat( client, "*\x02 The\x04 noscope\x02 sound has been disabled" )
}
else {
CanHearTheSound[ client ] = true
SetClientCookie( client, HearSound, "1" )
PrintToChat( client, "*\x04 The\x02 noscope\x04 sound has been enabled" )
}
}
public PlaySoundToAll( ) {
for( new i = 1; i < MaxClients; i++ ) {
if( IsClientInGame( i ) && CanHearTheSound[ i ] ) {
EmitSoundToClient( i, "*noscope/noscope.mp3" )
}
}
}
stock bool: IsValidClient( int client ) {
if( client > 0 && client <= MaxClients && IsClientInGame( client ) ) {
return true
}
else {
return false
}
}