#include <amxmodx>
#include <amxmisc>
new const sound_file[] = "fart_sounds.ini"
new Float:LastFart[33]
new Trie:tSounds
new total_sounds
public plugin_precache()
{
tSounds = TrieCreate()
if( !tSounds )
{
set_fail_state( "Trie hiba!" )
}
new fdir[128]
get_configsdir( fdir, 127 )
format( fdir, 127, "%s/%s", fdir, sound_file )
if( file_exists( fdir ) )
{
new file = fopen( fdir, "rt" )
if( file )
{
new sound[64]
new num[3]
while( !feof( file ) )
{
fgets( file, sound, 63 )
remove_quotes( sound )
trim( sound )
if( sound[0] && sound[0] != ';' )
{
precache_sound( sound )
num_to_str( ++total_sounds, num, 2 )
TrieSetString( tSounds, num, sound )
}
}
}
else
{
set_fail_state( "Hibas hang a konfig fajl megnyitasakor." )
}
}
else
{
set_fail_state( "A hang konfig fajlja nem letezik!" )
}
if( !total_sounds )
{
set_fail_state( "Nincs hang mert megvan terhelve!" )
}
}
public plugin_init()
{
register_plugin( "Fart Mod", "1.2", "Wrecked" )
register_cvar( "fart_mod", "1.2", FCVAR_SERVER | FCVAR_SPONLY )
register_clcmd( "fart", "CmdFart" )
}
public CmdFart( id )
{
new Float:Time = get_gametime()
if( Time - LastFart[id] >= 3.0 )
{
LastFart[id] = Time
new rnum = random_num( 1, total_sounds )
new strnum[3]
new sound[64]
num_to_str( rnum, strnum, 2 )
TrieGetString( tSounds, strnum, sound, 63 )
emit_sound( id, CHAN_WEAPON, sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
}
}