HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4. new const sound_file[] = "fart_sounds.ini"
  5.  
  6. new Float:LastFart[33]
  7.  
  8. new Trie:tSounds
  9. new total_sounds
  10.  
  11. public plugin_precache()
  12. {
  13. tSounds = TrieCreate()
  14. if( !tSounds )
  15. {
  16. set_fail_state( "Trie hiba!" )
  17. }
  18.  
  19. new fdir[128]
  20. get_configsdir( fdir, 127 )
  21. format( fdir, 127, "%s/%s", fdir, sound_file )
  22.  
  23. if( file_exists( fdir ) )
  24. {
  25. new file = fopen( fdir, "rt" )
  26.  
  27. if( file )
  28. {
  29. new sound[64]
  30. new num[3]
  31.  
  32. while( !feof( file ) )
  33. {
  34. fgets( file, sound, 63 )
  35. remove_quotes( sound )
  36. trim( sound )
  37.  
  38. if( sound[0] && sound[0] != ';' )
  39. {
  40. precache_sound( sound )
  41. num_to_str( ++total_sounds, num, 2 )
  42. TrieSetString( tSounds, num, sound )
  43. }
  44. }
  45. }
  46. else
  47. {
  48. set_fail_state( "Hibas hang a konfig fajl megnyitasakor." )
  49. }
  50. }
  51. else
  52. {
  53. set_fail_state( "A hang konfig fajlja nem letezik!" )
  54. }
  55.  
  56. if( !total_sounds )
  57. {
  58. set_fail_state( "Nincs hang mert megvan terhelve!" )
  59. }
  60. }
  61.  
  62. public plugin_init()
  63. {
  64. register_plugin( "Fart Mod", "1.2", "Wrecked" )
  65.  
  66. register_cvar( "fart_mod", "1.2", FCVAR_SERVER | FCVAR_SPONLY )
  67.  
  68. register_clcmd( "fart", "CmdFart" )
  69. }
  70.  
  71. public CmdFart( id )
  72. {
  73. new Float:Time = get_gametime()
  74.  
  75. if( Time - LastFart[id] >= 3.0 )
  76. {
  77. LastFart[id] = Time
  78.  
  79. new rnum = random_num( 1, total_sounds )
  80. new strnum[3]
  81. new sound[64]
  82. num_to_str( rnum, strnum, 2 )
  83. TrieGetString( tSounds, strnum, sound, 63 )
  84.  
  85. emit_sound( id, CHAN_WEAPON, sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  86. }
  87. }
  88.