 |
|
Senior Member
Join Date: May 2008
Location: Poland
|

04-08-2009
, 17:26
Re: Precache sounds from file
|
#7
|
Quote:
Originally Posted by FiFiX
But I want play it from plugin.
It would be:
Code:
#include < amxmodx >
#include < amxmisc >
new g_szPrecached [ 32 ] [ 64 ]
public plugin_init ( )
{
register_plugin ( "PrecacheSound", "1.0", "FiFiX" )
}
public plugin_precache ( )
{
new szPath [ 64 ]
get_configsdir ( szPath, sizeof ( szPath ) - 1 )
format ( szPath, sizeof ( szPath ) - 1, "%s/sounds.ini", szPath )
if ( !file_exists ( szPath ) )
return
new iCount
for ( new a = 0; a < file_size ( szPath, 1 ); a ++ )
{
new szText [ 64 ]
new iLen
read_file ( szPath, a, szText, sizeof ( szText ) - 1, iLen )
if ( ( szText [ 0 ] != ';' ) && (szText [ 0 ] != '/' ) && file_exists ( szText ) )
{
g_szPrecached [ iCount++ ] = szText
precache_sound ( szText )
}
}
}
public Command_PlaySound ( )
{
client_cmd ( 0, "spk ^"%s^"", g_szPrecached [ random ( 32 ) ] )
return PLUGIN_HANDLED
}
And in plugin just add:
Code:
Command_PlaySound();
|
Hey, how to add here line which will log precached files into log_amx and how to make if extention is different than mp3 or wav plugin logs unknow extention and precache another file.
|
|
|
|