#include <sourcemod>
#include <emitsoundany>
#define PREFIX "\x01★ \x04[GO]\x01"
public Plugin:myinfo =
{
name = "Sank Sounds",
author = "kzu1337",
description = "Play a sound when someone type a word from the list below.",
version = "2.0",
url = ""
};
//new String: szSoundsList [ ] [ ] =
{
};
new String: szSoundsKzu [ ] [ ] =
{
"kzu"
};
new bool: CountDown [ MAXPLAYERS + 1 ];
new bool: SoundsOff [ MAXPLAYERS + 1 ];
new bool: StopSounds [ MAXPLAYERS + 1 ];
public OnPluginStart ( )
{
RegConsoleCmd ( "say", Command_Say );
RegConsoleCmd ( "sm_soundson", CommandSoundsOn );
RegConsoleCmd ( "sm_soundsoff", CommandSoundsOff );
HookEvent ( "round_prestart", EventRoundPreStart );
HookEvent ( "round_end", EventRoundEnd );
}
public OnClientPutInServer ( client )
{
CountDown [ client ] = false;
}
public EventRoundPreStart ( Handle: hEvent, const String: szEventName [ ], bool: bDontBroadcast )
{
for ( new j = 1; j <= MaxClients; j++)
{
if ( !IsClientInGame ( j ) || IsFakeClient( j ) )
continue;
StopSounds [ j ] = false;
}
}
public Action: EventRoundEnd ( Handle: event, const String: name [ ], bool: dontBroadcast )
{
for ( new j = 1; j <= MaxClients; j++)
{
if ( !IsClientInGame ( j ) || IsFakeClient( j ) )
continue;
StopSounds [ j ] = true;
}
}
public OnMapStart ( )
{
for ( new i = 0; i < sizeof ( szSoundsList ); i++ )
{
decl String: buffer [ 80 ], String: buffer2 [ 128 ];
Format ( buffer2, sizeof ( buffer2 ), "kzusank/%s.mp3", szSoundsList [ i ] );
PrecacheSoundAny ( buffer2, true );
Format ( buffer, sizeof ( buffer ), "kzusank/%s.mp3", szSoundsList [ i ] );
AddFileToDownloadsTable ( buffer );
}
for ( new i = 0; i < sizeof ( szSoundsKzu ); i++ )
{
decl String: buffer [ 80 ], String: buffer2 [ 128 ];
Format ( buffer2, sizeof ( buffer2 ), "sunetejucatori/figuri.mp3", szSoundsKzu [ i ] );
PrecacheSoundAny ( buffer2, true );
Format ( buffer, sizeof ( buffer ), "sunetejucatori/figuri.mp3", szSoundsKzu [ i ] );
AddFileToDownloadsTable ( buffer );
}
}
public Action: Command_Say ( client, args )
{
if ( !IsValidClient ( client ) )
return Plugin_Handled;
if ((GetAdminFlag ( GetUserAdmin ( client ), Admin_Root ) ) || ( GetAdminFlag ( GetUserAdmin ( client ), Admin_Custom6 ) ) )
{
if ( !CountDown [ client ] && !StopSounds [ client ] )
{
decl String:text [ 192 ];
GetCmdArgString ( text, sizeof ( text ) );
for ( new i = 0; i < sizeof ( szSoundsList ); i++ )
{
if ( StrContains ( text, szSoundsList [ i ], false ) != -1 )
{
for ( new j = 1; j <= MaxClients; j++)
{
if ( !IsClientInGame ( j ) || IsFakeClient( j ) || SoundsOff [ j ] )
continue;
new String: szSound [ 256 ];
FormatEx ( szSound, sizeof ( szSound ), "kzusank/%s.mp3", szSoundsList [ i ] );
EmitSoundToClientAny ( j, szSound, _, _, _, _, 1.0 );
}
decl String: gAuth [ 21 ];
GetClientAuthString ( client, gAuth, sizeof( gAuth ) );
if ( GetAdminFlag ( GetUserAdmin ( client ), Admin_Root ) || StrEqual ( gAuth, "STEAM_0:0:176251290" ) || StrEqual ( gAuth, "STEAM_0:1:68348751" ) || StrEqual ( gAuth, "STEAM_0:1:176919247" ) )
CountDown [ client ] = false;
else
{
CountDown [ client ] = true;
CreateTimer ( 9.0, Remove_CountDown, GetClientUserId ( client ) );
}
}
}
for ( new i = 0; i < sizeof ( szSoundsKzu ); i++ ) {
if ( StrContains ( text, szSoundsKzu [ i ], false ) != -1 )
{
for ( new j = 1; j <= MaxClients; j++)
{
if ( !IsClientInGame ( j ) || IsFakeClient( j ) || SoundsOff [ j ] )
continue;
new String: szSound [ 256 ];
FormatEx ( szSound, sizeof ( szSound ), "sunetejucatori/figuri.mp3", szSoundsKzu [ i ] );
EmitSoundToClientAny ( j, szSound, _, _, _, _, 1.0 );
}
decl String: gAuth [ 21 ];
GetClientAuthString ( client, gAuth, sizeof( gAuth ) );
if ( GetAdminFlag ( GetUserAdmin ( client ), Admin_Root ) || StrEqual ( gAuth, "STEAM_0:0:176251290" ) || StrEqual ( gAuth, "STEAM_0:1:68348751" ) || StrEqual ( gAuth, "STEAM_0:1:176919247" ) )
CountDown [ client ] = false;
else
{
CountDown [ client ] = true;
CreateTimer ( 9.0, Remove_CountDown, GetClientUserId ( client ) );
}
}
}
}
}
return Plugin_Continue;
}
public Action: CommandSoundsOn ( client, args )
{
if ( !SoundsOff [ client ] )
{
PrintToChat ( client, "%s You have already sounds \x04on\x01 !", PREFIX );
return Plugin_Handled;
}
SoundsOff [ client ] = false;
PrintToChat ( client, "%s Sounds \x04On\x01 !", PREFIX );
return Plugin_Handled;
}
public Action: CommandSoundsOff ( client, args )
{
if ( SoundsOff [ client ] )
{
PrintToChat ( client, "%s You have already sounds \x02off\x01 !", PREFIX );
return Plugin_Handled;
}
SoundsOff [ client ] = true;
PrintToChat ( client, "%s Sounds \x02Off \x01!", PREFIX );
return Plugin_Handled;
}
public Action: Remove_CountDown ( Handle:timer, any:user_index )
{
new client = GetClientOfUserId ( user_index );
if ( !client )
return;
CountDown [ client ] = false;
}
stock IsValidClient ( client )
{
if ( !( 1 <= client <= MaxClients ) || !IsClientInGame ( client ) )
return false;
return true;
}