P1xeL

Untitled

Jun 30th, 2012
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4. #include <orpheu>
  5. #include <orpheu_memory>
  6.  
  7. #define GetPlayerByClientStruct(%0) ( ( %0 - g_client_t_address ) / 20200 + 1 )
  8.  
  9. new g_top_client
  10. new g_client_t_address
  11. new g_player_voice_status[ 32 ]
  12.  
  13. new g_fwdVoiceRecordOn
  14. new g_fwdVoiceRecordOff
  15.  
  16. public plugin_init()
  17. {
  18. register_forward( FM_Voice_SetClientListening, "fwd_Voice_SetClientListening" )
  19. OrpheuRegisterHook( OrpheuGetFunction( "SV_ParseVoiceData" ), "SV_ParseVoiceData" )
  20. RegisterHam( Ham_Spawn, "player", "hamPlayerSpawn" )
  21.  
  22. g_fwdVoiceRecordOn = CreateMultiForward( "client_voicerecord_on", ET_IGNORE, FP_CELL )
  23. g_fwdVoiceRecordOff = CreateMultiForward( "client_voicerecord_off", ET_IGNORE, FP_CELL )
  24.  
  25. new svs = OrpheuMemoryGet( "svs_ptr" )
  26.  
  27. g_client_t_address = OrpheuMemoryGetAtAddress( svs + 4, "engineInt" )
  28. arrayset( g_player_voice_status, 0, 32 )
  29. g_top_client = 0
  30. }
  31.  
  32. public SV_ParseVoiceData( info )
  33. {
  34. // Flag user as it's using voicerecord
  35. new player = GetPlayerByClientStruct( info )
  36. g_player_voice_status[ player - 1 ] = 1
  37.  
  38. }
  39.  
  40. public hamPlayerSpawn( id )
  41. {
  42. set_top_client()
  43. g_player_voice_status[ id - 1 ] = 0
  44. }
  45.  
  46. public fwd_Voice_SetClientListening( receiver, sender, bool:listen )
  47. {
  48. new result
  49. // Detect +voicerecord
  50. if( receiver == 1 && g_player_voice_status[ sender - 1 ] )
  51. {
  52. ExecuteForward( g_fwdVoiceRecordOn, result, sender )
  53. }
  54.  
  55. // Detect -voicerecord
  56. if( receiver == g_top_client && g_player_voice_status[ sender - 1 ] )
  57. {
  58. ExecuteForward( g_fwdVoiceRecordOff, result, sender )
  59. g_player_voice_status[ sender - 1 ] = 0
  60. }
  61.  
  62. return FMRES_IGNORED
  63. }
  64.  
  65. public client_disconnect( id )
  66. {
  67. set_top_client()
  68. g_player_voice_status[ id - 1 ] = 0
  69. }
  70.  
  71. stock set_top_client()
  72. {
  73. new players[ 32 ], num
  74.  
  75. get_players( players, num )
  76.  
  77. for( num--; num >= 0; num-- )
  78. {
  79. if( players[ num ] > g_top_client )
  80. g_top_client = players[ num ]
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment